()
| 150 | } |
| 151 | |
| 152 | async listTools(): Promise<McpTool[]> { |
| 153 | if (!this.isConnected) { |
| 154 | throw new McpConnectionError('Not connected to server', this.config.name) |
| 155 | } |
| 156 | |
| 157 | try { |
| 158 | const result: ListToolsResult = await this.client.listTools(undefined, { |
| 159 | timeout: MCP_CLIENT_CONSTANTS.LIST_TOOLS_TIMEOUT_MS, |
| 160 | }) |
| 161 | |
| 162 | if (!result.tools || !Array.isArray(result.tools)) { |
| 163 | logger.warn(`Invalid tools response from server ${this.config.name}:`, result) |
| 164 | return [] |
| 165 | } |
| 166 | |
| 167 | return result.tools.map((tool: Tool) => ({ |
| 168 | name: tool.name, |
| 169 | description: tool.description, |
| 170 | inputSchema: tool.inputSchema as McpTool['inputSchema'], |
| 171 | serverId: this.config.id, |
| 172 | serverName: this.config.name, |
| 173 | })) |
| 174 | } catch (error) { |
| 175 | logger.error(`Failed to list tools from server ${this.config.name}:`, error) |
| 176 | throw error |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | async callTool(toolCall: McpToolCall): Promise<McpToolResult> { |
| 181 | if (!this.isConnected) { |
no test coverage detected