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 0.1.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 0.1.0
File Size Uploaded Provenance Actions
mcp_mock-0.1.0.tar.gz 9.1 kB Without provenance Details for mcp_mock-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 17.1 kB

Release files / mcp_mock-0.1.0.tar.gz

Download URL mcp_mock-0.1.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
da6ebdbc33594d190dcab56c622edbfd2ff138d3b5bc5ef30b6dbeff85d1594c
BLAKE2b-256 checksum
How to use checksums
fdb64ba4207e42b3445b94f2ce1eec91e5a9af3af68e864ec3922ebeeab4d644
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-0.1.0-py3-none-any.whl

Download URL mcp_mock-0.1.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bb75e6342e095f65d8594f287f772dcdb4f039d6cdab29ad313046095173cd0
BLAKE2b-256 checksum
How to use checksums
bd5fc1ebbd6a3ccb213d7db8e18f9940d94a20294d418fb2f482c75417bf9d18
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 0.1.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