Skip to content

Return protocol errors for unknown tools - #1120

Open
skulitom wants to merge 7 commits into
modelcontextprotocol:mainfrom
skulitom:codex/fix-unknown-tool-protocol-error
Open

skulitom wants to merge 7 commits into
modelcontextprotocol:mainfrom
skulitom:codex/fix-unknown-tool-protocol-error

Conversation

@skulitom

Copy link
Copy Markdown

Motivation and Context

Fixes #1037.

Calling an unregistered tool currently returns a normal result with isError = true, making it indistinguishable from a tool execution failure. Return a JSON-RPC INVALID_PARAMS error (-32602) instead, matching the tools specification and existing unknown-prompt handling. Registered tool handlers still return execution failures through isError.

How Has This Been Tested?

  • Six regression cases fail on unchanged main because no protocol exception reaches the client; all 36 focused tests pass with the fix.
  • New tests cover removed tools, explicit execution-error results, and error propagation over stdio, SSE, Streamable HTTP and WebSocket. Each transport remains usable for a subsequent successful tool call.
  • Windows: 165 server tests plus the 36 focused integration tests pass.
  • WSL/Linux: all 610 JVM tests pass, including 125 integration tests; repository-wide formatting passes.
  • All 30 server conformance scenarios pass (39 checks).
  • Repository-wide API compatibility (checkKotlinAbi) and server static analysis (detektMainJvm) pass.

Breaking Changes

As requested in #1037, callers now receive a protocol exception for unknown or removed tools rather than a CallToolResult with isError = true. No public signatures change.

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Prepared with Codex assistance for issue investigation, implementation and local validation.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T12:09:49.022472Z e6e8d43 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — the unknown-tool path now mirrors the existing unknown-prompt handling, and the transport coverage is a nice touch, so this is good to merge.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=7f2373f6-0656-49c7-bc7f-347e4592fe4f

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — this matches the spec and the existing unknown-prompt handling nicely, approving.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=3ba94be9-8d76-4333-ab41-dc6853851136

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — the unknown-tool path now returns a proper protocol error and the change reads cleanly, so this is approved.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=29247b13-6ba1-4d6f-b0ac-4761ffc0981b

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — the unknown-tool path now returns a proper protocol error, so this is approved.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=01917bbe-be87-4b5e-a50a-8e833cd08b0b

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — the unknown-tool path now returns the protocol error the spec calls for, so this is good to merge.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=dd9b933d-c871-44a3-97ec-628b87fd773b

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work — this lines the unknown-tool path up with the spec and the existing prompt/resource handling, so it's approved.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=98734216-dfa8-48d2-ab57-a9b34c608d0c

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — the unknown-tool path now returns the protocol error the spec asks for, so this is approved.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=1a73fe02-b865-4cc6-b6ca-35d4e7f46637

This branch has not been deployed

No deployments
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.

tools/call for an unknown tool returns isError instead of a JSON-RPC error

2 participants