Test MCP Tools

The current Python SDK can connect a Client directly to an MCPServer object, giving you fast tests without ports or subprocesses.

import pytest
from mcp.client import Client
from server import mcp

@pytest.mark.anyio
async def test_lookup():
    async with Client(mcp) as client:
        result = await client.call_tool("lookup", {"id":"A-1"})
        assert result is not None

Test more than the happy path

Snapshot schemas selectively

Schema snapshots can catch accidental breaking changes, but make them readable and reviewable rather than snapshotting entire noisy protocol responses.