Rename McpError to MCPError and convert construction sites

This commit is contained in:
Jeremiah Lowin 2026-07-05 18:07:02 -04:00
commit fdac9f9f2e
No known key found for this signature in database
39 changed files with 217 additions and 281 deletions

View file

@ -54,7 +54,7 @@ async def test_server_tasks_true_defaults_all_components():
async def test_server_tasks_false_defaults_all_components():
"""Server with tasks=False makes all components default to mode=forbidden."""
import pytest
from mcp.shared.exceptions import McpError
from mcp.shared.exceptions import MCPError
mcp = FastMCP("test", tasks=False)
@ -78,12 +78,12 @@ async def test_server_tasks_false_defaults_all_components():
assert result.is_error
assert "does not support task-augmented execution" in str(result)
# Prompt with mode="forbidden" raises McpError when called with task=True
with pytest.raises(McpError):
# Prompt with mode="forbidden" raises MCPError when called with task=True
with pytest.raises(MCPError):
await client.get_prompt("my_prompt", task=True)
# Resource with mode="forbidden" raises McpError when called with task=True
with pytest.raises(McpError):
# Resource with mode="forbidden" raises MCPError when called with task=True
with pytest.raises(MCPError):
await client.read_resource("test://resource", task=True)
@ -174,7 +174,7 @@ async def test_component_explicit_true_overrides_server_false():
async def test_mixed_explicit_and_inherited():
"""Mix of explicit True/False/None on different components."""
import pytest
from mcp.shared.exceptions import McpError
from mcp.shared.exceptions import MCPError
mcp = FastMCP("test", tasks=True) # Server default is True
@ -240,8 +240,8 @@ async def test_mixed_explicit_and_inherited():
inherited_prompt_task = await client.get_prompt("inherited_prompt", task=True)
assert not inherited_prompt_task.returned_immediately
# Explicit False prompt (mode="forbidden") raises McpError
with pytest.raises(McpError):
# Explicit False prompt (mode="forbidden") raises MCPError
with pytest.raises(MCPError):
await client.get_prompt("explicit_false_prompt", task=True)
# Resources
@ -250,8 +250,8 @@ async def test_mixed_explicit_and_inherited():
)
assert not inherited_resource_task.returned_immediately
# Explicit False resource (mode="forbidden") raises McpError
with pytest.raises(McpError):
# Explicit False resource (mode="forbidden") raises MCPError
with pytest.raises(MCPError):
await client.read_resource("test://explicit_false", task=True)
@ -303,7 +303,7 @@ async def test_resource_template_inherits_server_tasks_default():
async def test_multiple_components_same_name_different_tasks():
"""Different component types with same name can have different task settings."""
import pytest
from mcp.shared.exceptions import McpError
from mcp.shared.exceptions import MCPError
mcp = FastMCP("test", tasks=False)
@ -320,8 +320,8 @@ async def test_multiple_components_same_name_different_tasks():
tool_task = await client.call_tool("shared_name", task=True)
assert not tool_task.returned_immediately
# Prompt inheriting False (mode="forbidden") raises McpError
with pytest.raises(McpError):
# Prompt inheriting False (mode="forbidden") raises MCPError
with pytest.raises(MCPError):
await client.get_prompt("shared_name_prompt", task=True)