Skip to content

Conversation

@kooba
Copy link

@kooba kooba commented Jan 16, 2026

When discovering MCP server capabilities, listing tools (and other resources) would often fail because the error code was being read incorrectly.

MCP servers return a -32601 (Method not found) error for unsupported capabilities, but the transport layer (e.g., Streamable HTTP) wraps these errors. The previous code only checked for e.code === -32601, missing cases where the code was embedded in the error message string.

This fix properly detects the error in both forms, allowing capability discovery to continue gracefully instead of failing entirely.

Changes

  • Reuse existing getErrorCode helper from errors.ts for consistent error code extraction
  • Check both direct error code and message string for -32601

Jakub Borys added 2 commits January 14, 2026 16:44
…ty discovery

When MCP servers return a -32601 (Method not found) error for unsupported
capabilities like resources/templates/list, the error may be wrapped by the
transport layer (e.g., Streamable HTTP). The previous code only checked for
e.code === -32601, but wrapped errors have the code embedded in the message
string instead.

This fix checks both:
1. Direct error code property (e.code === -32601)
2. Error code in message string (contains '"code":-32601')

This allows capability discovery to gracefully continue when servers don't
support certain methods, instead of failing the entire discovery process.
@changeset-bot
Copy link

changeset-bot bot commented Jan 16, 2026

⚠️ No Changeset found

Latest commit: 21a3ce1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 16, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@787

commit: 21a3ce1

@mattzcarey mattzcarey self-assigned this Jan 16, 2026
@mattzcarey
Copy link
Contributor

this is very silly of the transport. Will have a look, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants