diff --git a/src/hooks/useAgentLoop.ts b/src/hooks/useAgentLoop.ts index 78e9ab6..7c2e6bc 100644 --- a/src/hooks/useAgentLoop.ts +++ b/src/hooks/useAgentLoop.ts @@ -225,10 +225,10 @@ export function useAgentLoop(config: Partial = {}): 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); diff --git a/src/mcp/connection.ts b/src/mcp/connection.ts index 93b0f8a..fde9646 100644 --- a/src/mcp/connection.ts +++ b/src/mcp/connection.ts @@ -581,10 +581,11 @@ export class MCPConnectionManager implements MCPConnectionManager { const result = await this.client.listTools(); // Transform MCP tools to our Tool interface with name prefixing + // Use double underscore instead of dot to comply with OpenRouter API requirements return result.tools.map(tool => ({ type: 'function' as const, function: { - name: `${this.connection.name}.${tool.name}`, + name: `${this.connection.name}__${tool.name}`, description: `[${this.connection.name}] ${tool.description || ''}`, parameters: tool.inputSchema || {}, }, @@ -636,9 +637,9 @@ export class MCPConnectionManager implements MCPConnectionManager { throw new Error('Client not connected'); } - // Remove the server prefix from the tool name - const unprefixedName = toolName.startsWith(`${this.connection.name}.`) - ? toolName.slice(this.connection.name.length + 1) + // Remove the server prefix from the tool name (using double underscore separator) + const unprefixedName = toolName.startsWith(`${this.connection.name}__`) + ? toolName.slice(this.connection.name.length + 2) : toolName; try {