Skip to content

Context7 Platform -- Up-to-date docs for AI agents

fix(mcp): add no-op prompts/list and resources/list handlers (#2534)

Fahreddin Özcanfcdc36e2459a
diff --git a/.changeset/ctx7-1604-prompts-resources-handlers.md b/.changeset/ctx7-1604-prompts-resources-handlers.md
new file mode 100644
index 00000000..b15752fe
--- /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`, `resources/list`, and `resources/templates/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 cd541eb7..8074542b 100644
--- a/packages/mcp/src/index.ts
+++ b/packages/mcp/src/index.ts
@@ -2,6 +2,11 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
+import {
+ ListPromptsRequestSchema,
+ ListResourcesRequestSchema,
+ ListResourceTemplatesRequestSchema,
+} from "@modelcontextprotocol/sdk/types.js";
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
import { z } from "zod";
import { searchLibraries, fetchLibraryContext } from "./lib/api.js";
@@ -282,6 +287,15 @@ Do not call this tool more than 3 times per question.`,
}
);
+ server.server.registerCapabilities({ prompts: {}, resources: {} });
+ server.server.setRequestHandler(ListPromptsRequestSchema, async () => ({ prompts: [] }));
+ server.server.setRequestHandler(ListResourcesRequestSchema, async () => ({
+ resources: [],
+ }));
+ server.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => ({
+ resourceTemplates: [],
+ }));
+
return server;
}