fix: return INVALID_PARAMS (-32602) for resource-not-found errors by leoneperdigao · Pull Request #2325 · modelcontextprotocol/python-sdk · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/mcp/server/mcpserver/server.py
6 changes: 3 additions & 3 deletions tests/issues/test_141_resource_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from mcp import Client
from mcp.server.mcpserver import MCPServer
from mcp.server.mcpserver.exceptions import ResourceError
from mcp.shared.exceptions import MCPError
from mcp.types import (
ListResourceTemplatesResult,
TextResourceContents,
Expand Down Expand Up @@ -55,10 +55,10 @@ def get_user_profile_missing(user_id: str) -> str: # pragma: no cover
assert result_list[0].mime_type == "text/plain"

# Verify invalid parameters raise error
with pytest.raises(ResourceError, match="Unknown resource"):
with pytest.raises(MCPError, match="Unknown resource"):
await mcp.read_resource("resource://users/123/posts") # Missing post_id

with pytest.raises(ResourceError, match="Unknown resource"):
with pytest.raises(MCPError, match="Unknown resource"):
await mcp.read_resource("resource://users/123/posts/456/extra") # Extra path component


Expand Down
47 changes: 47 additions & 0 deletions tests/issues/test_1579_resource_error_code.py
Loading