LibreChat/packages/api/src/mcp
Jens Schumann ad74a282d1
🪃 fix: Resolve User Vars Before the First Post-OAuth Reconnect (#14538)
* fix: resolve customUserVars before first post-OAuth-callback MCP reconnect

The OAuth callback route reconnects the user's MCP connection immediately
after storing new tokens, but never resolves customUserVars before doing
so - unlike the /reinitialize route a few hundred lines below, which does.
As a result, headers/oauth_headers templates like `{{MY_KEY}}` are sent
to the MCP server literally, unsubstituted, on this first connection
attempt, even though the user's value is already saved. The upstream
server rejects it as an invalid credential.

Fixes #14537

* refactor: share getServerCustomUserVars reader from @librechat/api

The mcp_-prefixed key shape was built by getUserMCPAuthMap but re-derived
by hand at each read site (a private helper in services/MCP.js, and the
new callback-route extraction). Export a reader from the same module that
owns the writer and reuse it at both sites, so the key shape has a single
source of truth.

* chore: sort destructured require members in routes/mcp.js

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
2026-07-30 22:17:06 -04:00
..
__tests__ 🪃 fix: Resolve User Vars Before the First Post-OAuth Reconnect (#14538) 2026-07-30 22:17:06 -04:00
oauth 🔗 fix: Resolve MCP Tool-Key Boundary Against Configured Server Names (#14448) 2026-07-27 14:45:38 -04:00
registry 🍃 fix: Strip $-Prefixed Schema Keywords Before Persisting MCP Tool Params (#14464) 2026-07-27 18:50:34 -04:00
types 🚐 fix: Reuse Request-Scoped MCP Connections per Run (#13673) 2026-06-11 01:17:14 -04:00
auth.ts 🪃 fix: Resolve User Vars Before the First Post-OAuth Reconnect (#14538) 2026-07-30 22:17:06 -04:00
cache.ts
connection.ts 🧵 fix: Harden Request-Scoped MCP Lifecycle (#14342) 2026-07-20 13:42:19 -04:00
ConnectionsRepository.ts 🔐 fix: Honor Admin-Panel MCP Allowlist Overrides Without Restart (#13814) 2026-06-17 20:14:53 -04:00
context.ts 🔗 fix: Resolve MCP Tool-Key Boundary Against Configured Server Names (#14448) 2026-07-27 14:45:38 -04:00
enum.ts
errors.ts ️ refactor: Migrate @librechat/api build to tsdown (#13595) 2026-06-08 10:54:48 -04:00
mcpConfig.ts 💰 fix: Bound MCP tools/list Pagination with Aggregate Budgets (#13909) 2026-06-23 08:34:09 -04:00
MCPConnectionFactory.ts 🧵 fix: Harden Request-Scoped MCP Lifecycle (#14342) 2026-07-20 13:42:19 -04:00
MCPManager.ts 🧵 fix: Harden Request-Scoped MCP Lifecycle (#14342) 2026-07-20 13:42:19 -04:00
parsers.ts ️ refactor: Migrate @librechat/api build to tsdown (#13595) 2026-06-08 10:54:48 -04:00
request.ts 🪢 fix: Tie MCP Cleanup To Resumable Runs (#13769) 2026-06-15 15:26:03 -04:00
tools.spec.ts 🗄️ fix: Gate Request-Scoped MCP Servers Out of Persistent Tool Cache (#13672) 2026-06-13 11:26:49 -04:00
tools.ts 🗄️ fix: Gate Request-Scoped MCP Servers Out of Persistent Tool Cache (#13672) 2026-06-13 11:26:49 -04:00
UserConnectionManager.ts 🧵 fix: Harden Request-Scoped MCP Lifecycle (#14342) 2026-07-20 13:42:19 -04:00
utils.ts 🎯 feat: Per-Tool Intent Labels for Model Specs (#14526) 2026-07-30 13:32:04 -04:00
zod.ts 🍃 fix: Strip $-Prefixed Schema Keywords Before Persisting MCP Tool Params (#14464) 2026-07-27 18:50:34 -04:00