What happened?
Just noticed this inconsistency after updating to the latest Librechat commit.
- Substitution of MCP server environment variables from customUserVars entries appears to no longer be working. My assumption is that this is a consequence of 8780a78.
- Substituting MCP server headers from customUserVars entries does appear to still be working.
What I see still working:
- In api/server/services/MCP.js::createMCPTool::_call, the value of
config?.configurable?.userMCPAuthMap?.[`${Constants.mcp_prefix}${serverName}`] correctly contains the substituted values of the environment variables from customUserVars for the current user
- The MCP auth information from createMCPTool correctly makes it into MCPManager::callTool, where
processMCPEnv is called and the substitution connection.setRequestHeaders(currentOptions.headers || {}) is made. I'm assuming this is why headers still work with customUserVars.
- When I reinitialize a MCP server that isn't working, I can see in the handler for
router.post('/:serverName/reinitialize', ...) in api/server/routes/mcp.js that freshly-computed values of customUserVars correctly contain the substituted values of the environment variables.
- After reinitializing, the freshly-computed values of customUserVars are visible in UserConnectionManager::getUserConnection and MCPConnectionFactory::create.
What I see not working:
- In api/src/mcp/MCPConnectionFactory.ts::constructor, the value of
oauth?.customUserVars which is passed into processMCPEnv when creating all MCP servers (I don't use any oauth servers) is undefined. This is the 2nd of 2 total places where processMCPEnv is called with a customUserVars value, so I'm assuming this is the problem area from 8780a78.
- In api/src/mcp/ConnectionsRepository.ts::get, the value of
this.oauthOpts (which is passed to the MCPConnectionFactory constructor as the object containing customUserVars) is undefined too. This seems to be because neither MCPManager or MCPServersRegistry initialize an instance of ConnectionsRepository with an argument for the constructor's second parameter oauthOpts.
- After reinitializing, even though the freshly-computed values of customUserVars seem to be propagated all the way through to the server (I can see in the freshly-created server process that the environment variables are populated), the old broken instance of the server is not destroyed, and is not used by Librechat for future MCP tool calls. So from a user's perspective, nothing changes after reinitializing. There are just multiple servers running now behind the scenes.
Past this point, it's hard for me to tell what's going on. But when MCPConnectionFactory::create is first called while Librechat is starting up, what I can see is that there's no customUserVars information available for that first instance of any created MCPConnection for a MCP server.
Version Information
$ git rev-parse HEAD
a6fd32a
Steps to Reproduce
- Add a MCP server to librechat.yaml, with at least one customUserVars entry, and an env entry referencing the customUserVars entry.
- Enable that MCP server in Librechat and populate the credentials for the user variable.
- Verify on the MCP server that the environment variable configured in the
env entry just contains the {{PLACEHOLDER}} text, not the substituted value.
What browsers are you seeing the problem on?
No response
Relevant log output
No errors or warnings occur, and no relevant debug diagnostics exist in the refactored code paths.
Screenshots
No response
Code of Conduct
What happened?
Just noticed this inconsistency after updating to the latest Librechat commit.
What I see still working:
config?.configurable?.userMCPAuthMap?.[`${Constants.mcp_prefix}${serverName}`]correctly contains the substituted values of the environment variables from customUserVars for the current userprocessMCPEnvis called and the substitutionconnection.setRequestHeaders(currentOptions.headers || {})is made. I'm assuming this is why headers still work with customUserVars.router.post('/:serverName/reinitialize', ...)in api/server/routes/mcp.js that freshly-computed values of customUserVars correctly contain the substituted values of the environment variables.What I see not working:
oauth?.customUserVarswhich is passed intoprocessMCPEnvwhen creating all MCP servers (I don't use any oauth servers) isundefined. This is the 2nd of 2 total places whereprocessMCPEnvis called with a customUserVars value, so I'm assuming this is the problem area from 8780a78.this.oauthOpts(which is passed to the MCPConnectionFactory constructor as the object containingcustomUserVars) isundefinedtoo. This seems to be because neitherMCPManagerorMCPServersRegistryinitialize an instance ofConnectionsRepositorywith an argument for the constructor's second parameteroauthOpts.Past this point, it's hard for me to tell what's going on. But when MCPConnectionFactory::create is first called while Librechat is starting up, what I can see is that there's no customUserVars information available for that first instance of any created MCPConnection for a MCP server.
Version Information
$ git rev-parse HEAD
a6fd32a
Steps to Reproduce
enventry just contains the{{PLACEHOLDER}}text, not the substituted value.What browsers are you seeing the problem on?
No response
Relevant log output
No errors or warnings occur, and no relevant debug diagnostics exist in the refactored code paths.Screenshots
No response
Code of Conduct