Skip to content

Commit

Permalink
fixup!
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Pilar <[email protected]>
  • Loading branch information
pilartomas committed Jan 3, 2025
1 parent 5af7015 commit d4def3e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/tools/mcp/mcpResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -42,7 +42,12 @@ export class MCPResourceTool extends MCPTool<ReadResourceResult> {
}

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()
Expand Down

0 comments on commit d4def3e

Please sign in to comment.