Skip to content

Gate listTools/listPrompts/listResources/listResourceTemplates on server capability #1350

@cliffhall

Description

@cliffhall

Background

#1349 gated ManagedRequestorTasksState.refresh on the server's tasks capability so we don't fire tasks/list against servers that don't advertise it (which returned -32601 "Method not found" in the console on every connect to e.g. the NightRider example).

The same papercut exists in the other four list-fetching state managers:

  • core/mcp/state/managedToolsState.ts — calls listTools
  • core/mcp/state/managedPromptsState.ts — calls listPrompts
  • core/mcp/state/managedResourcesState.ts — calls listResources
  • core/mcp/state/managedResourceTemplatesState.ts — calls listResourceTemplates

Almost every server advertises tools/resources/prompts so the issue doesn't show up in practice today, but a "tools-only" server (or a "resources-only" server) would surface -32601 errors in the console on every connect — same root cause, same fix shape.

Screenshot

Image

Scope

Add the same capability gate to each of the four state managers:

if (!client.getCapabilities()?.tools) {
  this.tools = [];
  this.dispatchTypedEvent("toolsChange", this.tools);
  return this.getTools();
}

(swap tools/prompts/resources per file).

Resource templates are gated on capabilities.resources (the MCP spec doesn't define a separate resourceTemplates capability — listResourceTemplates is part of the resources surface).

Tests

Mirror the two new tests added in #1349's managedRequestorTasksState.test.ts:

  • Existing tests need their FakeInspectorClient to be constructed with the relevant capability so the live-path coverage is preserved.
  • Add a "refresh skips listX when capability absent" test for each state manager.
  • Add a "connect against an X-less server doesn't fire listX" test for each.

Same pattern in useManagedX.test.tsx peer files — they also need the capability set in beforeEach.

Out of scope

  • Cleanup of the existing -32601 console noise in tests that intentionally probe unsupported methods (those are deliberate).

Metadata

Metadata

Assignees

Labels

v2Issues and PRs for v2

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions