fix: gate resource discovery on the resources capability - #213
Merged
nicobailon merged 2 commits intoJul 25, 2026
Conversation
fetchAllResources called resources/list unconditionally, while fetchAllPrompts already short-circuits on the advertised capability. Under MCP SDK v2 beta.5 the client logs a debug line and returns an empty list when the server does not advertise `resources`, so every tools-only server printed noise into the TUI on each connect. Apply the same capability gate to resource discovery. Mocked clients in the tests that assert on resources/list now advertise the capability, matching the real SDK client.
nicobailon
force-pushed
the
kotuke/fix/resources-capability-gate
branch
from
July 25, 2026 00:27
a9630e8 to
0e5c9fd
Compare
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.
Problem
Since
2.12.0moved the client to@modelcontextprotocol/client@2.0.0-beta.5, connecting a server that only advertisestoolsprints a debug line into the TUI on every Pi start:The SDK v1 client stayed silent in the same situation, so this only became visible with the v2 beta.5 migration (#210).
Cause
server-manager.tsdiscovers prompts behind a capability gate but asks for resources unconditionally:The asymmetry dates from the prompts work in
2.12.0(#203), which added the gate for prompts and left resource discovery as it was.Fix
Apply the same gate in
fetchAllResources. Nothing is functionally broken today — the SDK returns an empty list either way — but a tools-only server no longer causes a wire request or a debug line at startup.A server that serves resources without advertising the capability is not spec-compliant, and the SDK v2 client already refuses to list them, so the gate does not change what such a server yields.
Tests
__tests__/resources-capability.test.ts(new):resources/listis not called when the capability is absent, is called when it is present, and a tools-only server connects with an empty resource list. Mirrors the existing "prompts capability negotiation" case in__tests__/prompts-sdk-integration.test.ts.__tests__/fixtures/tools-only-server.mjs(new): minimal server advertisingtoolsonly — the existing fixtures all advertiseresources.resources/list(abort-signal,proxy-modes-auto-auth,server-manager-sampling) now exposegetServerCapabilities, like the real SDK client. Without it the mocks describe a server that advertises nothing, and their assertions would no longer test what they were written for.Locally on Node 24:
npx tsc --noEmit,npm test(738 passed),npm run test:oauth(107 passed) andnpm run test:conformance(all scenarios pass or match the baseline) are green.