From d4def3e936ca8a150cad86c13fd18ac7854d2f26 Mon Sep 17 00:00:00 2001 From: Tomas Pilar Date: Fri, 3 Jan 2025 13:20:04 +0100 Subject: [PATCH] fixup! Signed-off-by: Tomas Pilar --- src/tools/mcp/mcpResource.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools/mcp/mcpResource.ts b/src/tools/mcp/mcpResource.ts index 0e306045..18edfcd8 100644 --- a/src/tools/mcp/mcpResource.ts +++ b/src/tools/mcp/mcpResource.ts @@ -17,7 +17,7 @@ import { ToolEmitter, ToolInput } from "@/tools/base.js"; import { z } from "zod"; import { Emitter } from "@/emitter/emitter.js"; -import { ReadResourceResult } from "@modelcontextprotocol/sdk/types.js"; +import { ErrorCode, McpError, ReadResourceResult } from "@modelcontextprotocol/sdk/types.js"; import { MCPTool, MCPToolInput, MCPToolOutput } from "./base.js"; export interface MCPResourceToolInput extends MCPToolInput { @@ -42,7 +42,12 @@ export class MCPResourceTool extends MCPTool { } async inputSchema() { - const resources = await this.listResources().catch(() => []); // ignore errors, e.g. MCP server might not have resource capability + const resources = await this.listResources().catch((err) => { + if (err instanceof McpError && err.code === ErrorCode.MethodNotFound) { + return []; + } + throw err; + }); return z.object({ uri: z .string()