tools/call
Execute remote tools on AI clients like Claude and Cline through the Model Context Protocol to enable cross-client communication and functionality.
Instructions
Execute a tool on a remote MCP client
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | Yes | ||
| arguments | Yes | ||
| targetType | No |
Implementation Reference
- src/server.ts:315-358 (handler)The primary handler function for the 'tools/call' tool. It logs the parameters, generates a unique message ID, constructs a request message with the provided method and arguments, creates a task for tracking, routes the message to the target client using the router, handles routing failure by updating task status and throwing an error, updates the task to 'processing', and returns a mock text response indicating success (with a TODO for full response handling).
private async handleToolCall(params: any): Promise<any> { console.error('Handling tool call:', JSON.stringify(params, null, 2)); const messageId = randomUUID(); const message: Message = { id: messageId, type: 'request', method: params.method, sourceClientId: 'bridge-server', payload: params.arguments, timestamp: new Date() }; console.error('Created message:', JSON.stringify(message, null, 2)); // Create task state const task = this.stateManager.createTask( messageId, 'bridge-server', this.config.maxTaskAttempts ); // Route message const success = await this.router.routeMessage(message); if (!success) { this.stateManager.updateTask(messageId, { status: 'failed', error: 'Failed to route message' }); throw new McpError(ErrorCode.InternalError, 'Failed to route message'); } // Update task state this.stateManager.updateTask(messageId, { status: 'processing' }); // TODO: Implement response waiting and timeout handling // For now, just return a mock response return { content: [ { type: 'text', text: 'Message routed successfully' } ] }; } - src/server.ts:83-97 (registration)Tool registration in the MCP server's capabilities object. Declares the 'tools/call' tool with its description and input schema (method, arguments, optional targetType). This makes the tool discoverable via tools/list.
'tools/call': { description: 'Execute a tool on a remote MCP client', inputSchema: { type: 'object', properties: { method: { type: 'string' }, arguments: { type: 'object' }, targetType: { type: 'string', enum: ['claude', 'cline'] } }, required: ['method', 'arguments'] } } - src/server.ts:125-133 (registration)Registration of the request handler for CallToolRequestSchema, which dispatches 'tools/call' requests to the handleToolCall method.
this.server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name === 'discover_client') { return this.handleClientDiscovery(request.params.arguments); } if (request.params.name === 'tools/call') { return this.handleToolCall(request.params.arguments); } throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`); }); - src/server.ts:152-166 (schema)Schema definition for 'tools/call' tool returned in response to ListToolsRequestSchema.
name: 'tools/call', description: 'Execute a tool on a remote MCP client', inputSchema: { type: 'object', properties: { method: { type: 'string' }, arguments: { type: 'object' }, targetType: { type: 'string', enum: ['claude', 'cline'] } }, required: ['method', 'arguments'] } }