Skip to content

Deprecate McpErrorCode.ResourceNotFound (-32002) and use McpErrorCode.InvalidParams (-32602) per SEP-2164#1558

Open
jayaraman-venkatesan wants to merge 1 commit intomodelcontextprotocol:mainfrom
jayaraman-venkatesan:feature/sep-2164-resource-not-found-error-code
Open

Deprecate McpErrorCode.ResourceNotFound (-32002) and use McpErrorCode.InvalidParams (-32602) per SEP-2164#1558
jayaraman-venkatesan wants to merge 1 commit intomodelcontextprotocol:mainfrom
jayaraman-venkatesan:feature/sep-2164-resource-not-found-error-code

Conversation

@jayaraman-venkatesan
Copy link
Copy Markdown
Contributor

@jayaraman-venkatesan jayaraman-venkatesan commented May 4, 2026

Fixes #1540

SEP-2164 standardizes the error code for "resource not found" from the MCP-specific -32002 to the standard JSON-RPC -32602 (Invalid Params), as part of the 2026-06-30 MCP spec release.

How Has This Been Tested?

  • Existing test suite passes locally (dotnet test) — no new tests were needed since the existing resource routing, resource builder, and exception propagation tests already cover the error code path; their assertions were updated to expect -32602.

Breaking Changes

McpErrorCode.ResourceNotFound is marked [Obsolete] but retained at its original value -32002 for backward compatibility with pre-2026-06-30 clients and servers that may still send or check for that code. New code should use McpErrorCode.InvalidParams (-32602).

Server implementors who currently throw McpErrorCode.ResourceNotFound will see a compiler warning directing them to migrate to McpErrorCode.InvalidParams.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to 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

  • McpErrorCode.ResourceNotFound = -32002 is marked [Obsolete] with a message pointing to InvalidParams
  • The default ReadResource handler in McpServerImpl now throws InvalidParams
  • McpErrorCode.InvalidParams docs updated to list Resources as a covered context
  • All internal usages (server, test servers, tests) migrated to InvalidParams

…rceNotFound (-32002) and use InvalidParams (-32602) per SEP-2164
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.

SEP-2164: Standardize resource not found error code (-32602)

1 participant