Repository navigation
Conversation
Some MCP servers advertise resource support without implementing resource-template listing. These servers return JSON-RPC -32601 when the client requests the optional method. Ignore MethodNotFound only for resource-template discovery while preserving reporting of other failures and retaining existing resources and tools. Add regression coverage for unsupported templates, supported templates, other protocol errors, and stdio integration.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Some MCP servers advertise the
resourcescapability but don't implement the optionalresources/templates/listmethod. Theresourcescapability has no separate flag for templates, so the client can't tell in advance. For example, servers built on the low-level Python SDKServeradvertiseresourcesas soon asresources/listis registered, and answer every unregistered method with JSON-RPC-32601.MCPConnectionputs every template-listing failure into the server'serrors, and those become config errors. As a result, users seeError loading resource templates for MCP Server <name>: MCP error -32601: Method not foundfor servers whose resources and tools work fine. Reported in #8412, #6226 and ihor-sokoliuk/mcp-searxng#54.This change treats a structured
McpErrorwithErrorCode.MethodNotFoundfromlistResourceTemplates()as "no templates":-32601fromresources/list,tools/listorprompts/listis still reported.Tests
core/context/mcp/MCPConnection.vitest.tsadds:core/context/mcp/fixtures/stdioResourceServer.mjsis a small fixture built on the SDK's low-levelServer, with local synthetic data and no network. The tests cover:-32603and malformed template responses;tools/listfailure;MethodNotFoundis ignored;-32602,-32001and-32000are still reported;-32601fromresources/listis still reported;Run on this branch (base
5522c6f44, Node 20.20.1):core:npx vitest run context/mcp/ tools/passes, and so doesnpx tsc -p ./ --noEmit.extensions/vscode:npx tsc -p ./ --noEmitpasses (it also type-checkscore).Notes
errortoconnected. That happens onmaintoo. The new timeout test therefore asserts the recorded errors, not the status. Happy to address it separately.MCPConnection.vitest.ts. The changes don't overlap, but whichever lands second may need a trivial rebase.