Skip to content

fix: return resource-not-found error code#2818

Closed
sarvesh1327 wants to merge 4 commits into
modelcontextprotocol:mainfrom
sarvesh1327:fix/resource-not-found-error-code
Closed

fix: return resource-not-found error code#2818
sarvesh1327 wants to merge 4 commits into
modelcontextprotocol:mainfrom
sarvesh1327:fix/resource-not-found-error-code

Conversation

@sarvesh1327

Copy link
Copy Markdown

Summary

  • Return the MCP resource-not-found error code (-32002) when resources/read matches no registered resource or template.
  • Add a focused UnknownResourceError path so matched template failures remain generic read failures instead of being reported as missing resources.
  • Update interaction requirements and regressions for both missing resources and template failure semantics.

Fixes #1579

Test Plan

  • uv run --frozen pytest tests/interaction/mcpserver/test_resources.py -q
  • uv run --frozen ruff check src/mcp/server/mcpserver/server.py src/mcp/server/mcpserver/resources/resource_manager.py src/mcp/server/mcpserver/resources/__init__.py src/mcp/types/jsonrpc.py src/mcp/types/__init__.py tests/interaction/mcpserver/test_resources.py tests/interaction/_requirements.py
  • uv run --frozen pyright src/mcp/server/mcpserver/server.py src/mcp/server/mcpserver/resources/resource_manager.py tests/interaction/mcpserver/test_resources.py
  • git diff --check

@Kludex

Kludex commented Jun 25, 2026

Copy link
Copy Markdown
Member

You've opened a duplicated pull request, please search opened PRs before creating new ones. Duplicated from #1582.

@Kludex Kludex closed this Jun 25, 2026
@modelcontextprotocol modelcontextprotocol locked as resolved and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastMCP read_resource() returns incorrect error code when resource not found

2 participants