mcp-python-sdk-inmemory-server-tests
LocalAbout mcp-python-sdk-inmemory-server-tests
This repository provides example code and tests for building reliable MCP tools. It demonstrates in-memory client sessions for catching asynchronous issues that isolated function tests may miss.
Key features
- 01Example code for MCP tool development
- 02Tests using in-memory client sessions
- 03Demonstrates asynchronous testing pitfalls
Use cases
- 01Test MCP tools beyond individual functions
- 02Detect asynchronous issues in tool behavior
MCP support
The repository demonstrates testing an MCP server with in-memory client sessions and MCP Inspector.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEmcp-python-sdk-inmemory-server-tests
This repository provides example code and tests for developing robust MCP tools.
It demonstrates how unit tests on individual functions can miss asynchronous pitfalls like asyncio.run in tools.
A more reliable testing approach using in-memory client sessions is showcased.
Commands
Setup:
curl https://get.volta.sh | bash
volta install node
npm install
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync --frozen
Run tests:
uv run pytest tests/.
Test and debug mcpserver.py with the MCP Inspector:
uv run mcp dev mcpserver.py
Format codebases:
uv run ruff format .
uv run ruff check --select I --fix .
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.