examples/testing_demo/README.md
A comprehensive example demonstrating FastMCP testing patterns with pytest-asyncio.
This example shows how to:
pyproject.tomltesting_demo/
├── pyproject.toml # Project config with pytest-asyncio setup
├── server.py # Simple MCP server with tools/resources/prompts
├── tests/
│ └── test_server.py # Comprehensive test suite
└── README.md # This file
The pyproject.toml includes the critical pytest-asyncio configuration:
[tool.pytest.ini_options]
asyncio_mode = "auto"
This eliminates the need for @pytest.mark.asyncio decorators on every async test.
The demo server (server.py) includes:
add, greet, async_multiplydemo://info, demo://greeting/{name}hello, explainThe test suite demonstrates:
async with.data attribute# Install dependencies
uv sync
# Run all tests
uv run pytest
# Run with verbose output
uv run pytest -v
# Run a specific test
uv run pytest tests/test_server.py::test_add_tool
# Run the server
uv run fastmcp run server.py
# Inspect the server
uv run fastmcp inspect server.py
For detailed information about testing FastMCP servers, see the Testing Documentation.