Skip to main content

mcp-mock

mcp-mock is a lightweight synthetic mock server for the Model Context Protocol (MCP). It is designed for local testing, demos, and resilience experiments where you want a predictable MCP endpoint without depending on a real backend.

The current codebase includes:

  • a MockMCPServer implementation for registering tools and serving responses
  • a synthetic response generator powered by Faker
  • a chaos layer for latency and injected failures
  • a CLI entry point for running a mock server from a schema file
  • a pytest suite covering the core behaviors

Project layout

mcp-mock/
├── pyproject.toml
├── README.md
├── LICENSE
├── src/
│   └── mcp_mock/
│       ├── __init__.py
│       ├── chaos.py
│       ├── cli.py
│       ├── generator.py
│       └── server.py
└── tests/
    ├── test_chaos.py
    ├── test_cli.py
    ├── test_generator.py
    └── test_server.py

Installation

Install the package from the project root:

python -m pip install -e .

Install development dependencies as well:

python -m pip install -e ".[dev]"

Usage

CLI

Run a mock server from a JSON schema file:

mcp-mock serve --schema ./tools_schema.json

Add chaos behavior:

mcp-mock serve --schema ./tools_schema.json --latency 100 --error-rate 0.1

Python API

from mcp_mock.chaos import ChaosConfig
from mcp_mock.server import MockMCPServer

chaos = ChaosConfig(latency_ms=50, error_rate=0.05)
server = MockMCPServer(name="DemoServer", chaos=chaos)
server.register_tool(name="get_user", description="Get a user")
server.run_stdio()

Schema file format

A simple schema file can look like this:

{
  "name": "ToolServer",
  "tools": [
    {
      "name": "get_user",
      "description": "Get a user by ID"
    },
    {
      "name": "execute_sql",
      "description": "Execute a SQL query"
    }
  ]
}

Development

Run the test suite:

pytest -q

License

This project is licensed under the MIT License. See LICENSE for details.

Metadata

Release files for mcp-mock 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-mock 1.0.0
File Size Uploaded Provenance Actions
mcp_mock-1.0.0.tar.gz 9.1 kB Without provenance Details for mcp_mock-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-mock 1.0.0
File Interpreter ABI Platform Actions
mcp_mock-1.0.0-py3-none-any.whl Python 3 none any Details for mcp_mock-1.0.0-py3-none-any.whl

Total release size: 17.2 kB

Release files / mcp_mock-1.0.0.tar.gz

Download URL mcp_mock-1.0.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a7f4511274489d73b468ab5d8ef05f4aca1caafd97e5dc9f30a71959b467d573
BLAKE2b-256 checksum
How to use checksums
dc5157f6312ac15fceb5d16a58a964c329cac38804e2b5ad65adb3e13f833686
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / mcp_mock-1.0.0-py3-none-any.whl

Download URL mcp_mock-1.0.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
932dfdbb5df92f6dfd202dc1d2f773b854e61838eb83cc12514439b50550eff8
BLAKE2b-256 checksum
How to use checksums
2e379e6543e95be68af65d3dbfb0a93edf51597dfb539072a25c961a96ec3558
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for mcp-mock 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page