60e0ffc959
Upgrade checks / Notify on failure (push) Has been cancelled
Upgrade checks / Close issue on success (push) Has been cancelled
Schema Crash Test / Real-world schema crash test (232K schemas) (push) Has been cancelled
Run static analysis / static_analysis (push) Has been cancelled
Tests / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Tests / Tests with lowest-direct dependencies (push) Has been cancelled
Tests / MCP conformance tests (push) Has been cancelled
Tests / Integration tests (push) Has been cancelled
Tests / Package install smoke (push) Has been cancelled
Upgrade checks / Static analysis (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Upgrade checks / Integration tests (push) Has been cancelled
Update MCPServerConfig Schema / update-config-schema (push) Has been cancelled
Update SDK Documentation / update-sdk-docs (push) Has been cancelled
1.7 KiB
1.7 KiB
Provider Tests: Direct Server Calls
This document captures the design decision to test providers via direct server method calls rather than wrapping in a Client.
Problem
Provider tests were using the Client pattern:
async with Client(mcp) as client:
result = await client.call_tool("add", {"x": 1, "y": 2})
assert result.data == 3
This conflated two concerns:
- Does the provider/server work correctly?
- Does the Client-Server interaction work correctly?
Additionally, ~1,200 lines of tests in test_server_interactions.py duplicated provider tests.
Solution
Provider tests now call server methods directly:
result = await mcp.call_tool("add", {"x": 1, "y": 2})
assert result.structured_content == {"result": 3}
This establishes clear test ownership:
- Provider tests → verify server functionality
- Integration tests → verify Client-Server interaction
Result Access Patterns
Direct server calls return canonical FastMCP types, not MCP protocol types:
| Component | Access Pattern |
|---|---|
| Tool | result.structured_content or result.text |
| Resource | result.contents[0].content |
| Prompt | result.messages[0].content.text |
Error Types
Direct calls raise FastMCP exceptions:
NotFoundError- component not foundDisabledError- component disabled by visibility
Client calls raise MCP protocol errors (wrapped in McpError).
Implementation
- Consolidated duplicate tests from
test_server_interactions.pyinto provider test files - Reduced
test_server_interactions.pyfrom 1,455 → 179 lines - Only
TestMetatests remain in interactions file (require Client for context injection)
PR
- #2748 - Convert provider tests to use direct server calls