From 7abf296f117570dd228552f85a35364ad32ce1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fahreddin=20=C3=96zcan?= Date: Thu, 30 Apr 2026 12:44:50 +0300 Subject: [PATCH 1/2] fix(mcp): add no-op prompts/list and resources/list handlers Some MCP clients (e.g. opencode) call prompts/list and resources/list unconditionally and treat -32601 Method not found as fatal, rather than honoring the negotiated capabilities. Advertise empty prompts/resources capabilities and register no-op handlers so those clients can load the server. --- .../ctx7-1604-prompts-resources-handlers.md | 5 +++++ packages/mcp/src/index.ts | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .changeset/ctx7-1604-prompts-resources-handlers.md diff --git a/.changeset/ctx7-1604-prompts-resources-handlers.md b/.changeset/ctx7-1604-prompts-resources-handlers.md new file mode 100644 index 00000000..a2e337fb --- /dev/null +++ b/.changeset/ctx7-1604-prompts-resources-handlers.md @@ -0,0 +1,5 @@ +--- +"@upstash/context7-mcp": patch +--- + +Advertise empty `prompts` and `resources` capabilities with no-op `prompts/list` and `resources/list` handlers. Some MCP clients (e.g. opencode) call these unconditionally and treat `-32601 Method not found` as a fatal connection error rather than honoring the negotiated capabilities, which previously prevented the server from loading. diff --git a/packages/mcp/src/index.ts b/packages/mcp/src/index.ts index cc0d9f78..f66e1a40 100644 --- a/packages/mcp/src/index.ts +++ b/packages/mcp/src/index.ts @@ -2,6 +2,10 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; +import { + ListPromptsRequestSchema, + ListResourcesRequestSchema, +} from "@modelcontextprotocol/sdk/types.js"; import { z } from "zod"; import { searchLibraries, fetchLibraryContext } from "./lib/api.js"; import { ClientContext } from "./lib/encryption.js"; @@ -316,6 +320,17 @@ Workflow: call first without researchMode. If that doesn't answer the question, } ); + // Advertise empty prompts/resources capabilities with no-op handlers. + // Some clients (e.g. opencode) call prompts/list and resources/list + // unconditionally and treat -32601 as a fatal connection error rather than + // honoring the negotiated capabilities, which would otherwise prevent the + // server from loading. + server.server.registerCapabilities({ prompts: {}, resources: {} }); + server.server.setRequestHandler(ListPromptsRequestSchema, async () => ({ prompts: [] })); + server.server.setRequestHandler(ListResourcesRequestSchema, async () => ({ + resources: [], + })); + return server; } From 88d31e030c3d09a27f9ade93ae278c4b855ae8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fahreddin=20=C3=96zcan?= Date: Thu, 30 Apr 2026 12:46:07 +0300 Subject: [PATCH 2/2] remove explanatory comments --- packages/mcp/src/index.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/mcp/src/index.ts b/packages/mcp/src/index.ts index f66e1a40..7fbac41e 100644 --- a/packages/mcp/src/index.ts +++ b/packages/mcp/src/index.ts @@ -320,11 +320,6 @@ Workflow: call first without researchMode. If that doesn't answer the question, } ); - // Advertise empty prompts/resources capabilities with no-op handlers. - // Some clients (e.g. opencode) call prompts/list and resources/list - // unconditionally and treat -32601 as a fatal connection error rather than - // honoring the negotiated capabilities, which would otherwise prevent the - // server from loading. server.server.registerCapabilities({ prompts: {}, resources: {} }); server.server.setRequestHandler(ListPromptsRequestSchema, async () => ({ prompts: [] })); server.server.setRequestHandler(ListResourcesRequestSchema, async () => ({