🐛 fix: MCP Name Normalization breaking User Provided Variables (#8644)

This commit is contained in:
Dustin Healy 2025-07-24 07:44:58 -07:00 committed by GitHub
parent 01470ef9fd
commit 1fe977e48f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 172 additions and 13 deletions

View file

@ -3,17 +3,14 @@ import { Constants } from 'librechat-data-provider';
import type { PluginAuthMethods } from '@librechat/data-schemas';
import type { GenericTool } from '@librechat/agents';
import { getPluginAuthMap } from '~/agents/auth';
import { mcpToolPattern } from './utils';
export async function getUserMCPAuthMap({
userId,
tools,
appTools,
findPluginAuthsByKeys,
}: {
userId: string;
tools: GenericTool[] | undefined;
appTools: Record<string, unknown>;
findPluginAuthsByKeys: PluginAuthMethods['findPluginAuthsByKeys'];
}) {
if (!tools || tools.length === 0) {
@ -23,11 +20,9 @@ export async function getUserMCPAuthMap({
const uniqueMcpServers = new Set<string>();
for (const tool of tools) {
const toolKey = tool.name;
if (toolKey && appTools[toolKey] && mcpToolPattern.test(toolKey)) {
const parts = toolKey.split(Constants.mcp_delimiter);
const serverName = parts[parts.length - 1];
uniqueMcpServers.add(`${Constants.mcp_prefix}${serverName}`);
const mcpTool = tool as GenericTool & { mcpRawServerName?: string };
if (mcpTool.mcpRawServerName) {
uniqueMcpServers.add(`${Constants.mcp_prefix}${mcpTool.mcpRawServerName}`);
}
}