Fix MCP tool naming for OpenRouter API compatibility

- Change tool name separator from dot to double underscore (server__tool)
- Update tool discovery to use server__tool_name format
- Update tool execution routing to parse double underscore separator
- Fix OpenRouter API error: tool names must match pattern '^[a-zA-Z0-9_-]{1,64}'

This resolves the silent failure when MCP tools were present in conversations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jerome 2025-06-12 12:06:06 +01:00
commit 0a06544bda
No known key found for this signature in database

View file

@ -225,10 +225,10 @@ export function useAgentLoop(config: Partial<AgentLoopConfig> = {}): UseAgentLoo
return { result };
}
// Check if it's an MCP tool (prefixed with server name)
if (toolCall.function.name.includes('.')) {
// Extract server name from tool name (format: "server.tool_name")
const [serverName] = toolCall.function.name.split('.');
// Check if it's an MCP tool (prefixed with server name using double underscore)
if (toolCall.function.name.includes('__')) {
// Extract server name from tool name (format: "server__tool_name")
const [serverName] = toolCall.function.name.split('__');
// Find the connection ID for this server name
const connection = connections.find(conn => conn.name === serverName);