Repository navigation
[Enhancement]: Custom headers for user-created MCP servers #17829
Replies: 1 comment
|
the multi-header gap is a real gap. the workaround until the UI ships is to add them in the proposed UX looks right to me. one thing worth calling out during review: make sure header values go through the same encryption path as oauth secrets and are stripped before any client-side response serializes them, since it's easy to accidentally leak them in a "get server config" endpoint. the (disclosure: i work on 1Claw, which solves a related but different problem around keeping secrets out of model context entirely, but that's not what this issue is about.) |
Uh oh!
There was an error while loading. Please reload this page.
What features would you like to see added?
Custom headers for user-created MCP servers, configurable from the MCP server dialog.
Today a server created in the UI can authenticate with a single header only. The dialog offers None, one API key header (Bearer, Basic or one custom header name), OAuth, or OBO. The client form never sends
headers, even thoughMCPServerUserInputSchemaalready accepts them.Some MCP servers need several headers. A Mautic MCP server, for example, expects:
X-Mautic-UrlX-Mautic-Client-IdX-Mautic-Client-SecretOther common cases are a client ID plus a client secret, or a tenant URL header next to a secret. None of these can be set up from the UI. Admins can configure them in
librechat.yamlwithheadersandcustomUserVars, but that requires a config change and a restart for each server, and is not available to regular users creating their own servers.Proposed behavior:
encryptV2for DB-backed servers (stored asenc:v2:<iv:ciphertext>), decrypted on read before placeholder resolution and connection creation.headerNames.url,typeorproxy, so a stored secret cannot be redirected to a new endpoint without re-entering it. This mirrors the existingMCP_API_KEY_REENTRY_REQUIREDrule with a newMCP_HEADERS_REENTRY_REQUIRED(400).{{LIBRECHAT_OPENID_*}},{{LIBRECHAT_USER_*}},{{LIBRECHAT_GRAPH_*}},{{LIBRECHAT_BODY_*}},${VAR}) is unchanged and runs before encryption.More details
Areas affected:
client/src/components/SidePanel/MCPBuilder/MCPServerDialog/(newsections/HeadersSection.tsx,hooks/useMCPServerForm.ts,MCPServerForm.tsx).packages/api/src/mcp/registry/db/ServerConfigsDB.ts,registry/MCPServersRegistry.ts, a newregistry/headers.ts(encrypt/decrypt, keep-on-blank merge, re-entry guard),utils.ts(redactServerSecretsreturnsheaderNames),errors.ts.Compatibility:
client_secretandapiKey.key.enc:v2:values literally, so a server saved by the new code may fail to authenticate on old replicas until all replicas are updated.headerNames: string[], for editors only.Alternatives considered:
librechat.yamlwithheadersandcustomUserVars: works for admin-defined servers, but not for servers users create themselves, and needs a config change per server.Related: #6115 asks for multiple auth headers for Agent Tools (Actions). This request covers the same need for user-created MCP servers.
An implementation is open in #17827. I would like to take this and be assigned, per CONTRIBUTING.md. Happy to adjust the scope or approach based on maintainer feedback before review.
Which components are impacted by your request?
UI, Endpoints
Pictures
Screenshots of the create and edit dialogs will be added to #17827.
Code of Conduct
All reactions