| 103 | |
| 104 | /** Enumerate tools from a connected client, namespaced as mcp__<server>__<tool>. */ |
| 105 | export async function listServerTools(server: string, client: Client): Promise<McpTool[]> { |
| 106 | const result = await client.listTools() |
| 107 | return (result.tools ?? []).map((tool) => ({ |
| 108 | name: `mcp__${server}__${tool.name}`, |
| 109 | originalName: tool.name, |
| 110 | server, |
| 111 | description: tool.description, |
| 112 | inputSchema: (tool.inputSchema as Record<string, unknown>) ?? { type: "object", properties: {} }, |
| 113 | })) |
| 114 | } |
| 115 | |
| 116 | /** Call a tool on a connected client and return a text result for the model. */ |
| 117 | export async function callMcpTool( |