Skip to content

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

Open
sarvesh1327 wants to merge 1 commit into
modelcontextprotocol:mainfrom
sarvesh1327:fix/resource-not-found-error-code
Open

fix: return resource-not-found error code#2818
sarvesh1327 wants to merge 1 commit 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

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.

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

1 participant