mcp-tuning
A script-first MCP debugging/testing library for Jupyter notebooks and plain Python scripts.
It is designed to help you iterate on MCP servers (implemented in any language) by providing a small, synchronous client API:
- Connect via
stdio(subprocess),http, orsse - Explore: tools / resources / prompts
- Call tools with JSON arguments
- Save/replay input-only cases (tool + args)
- Export logs / history / last result as JSON for repeatable debugging
Start with examples/notebooks/01_mcp_inspector_demo.ipynb.
Requirements
- Python 3.12+
uv
Install (uv)
uv sync
uv sync --extra notebook --extra test
Run (Jupyter)
uv run jupyter lab
Quickstart (stdio)
Prefer argv lists for stdio servers (avoids shell quoting issues) and make sure the server runs in an environment that has its dependencies installed.
from mcp_tuning import connect_stdio
# Example 1: connect to the built-in mock server (minimal dependencies)
import sys
c = connect_stdio([sys.executable, "src/mcp_tuning/_mock_server.py"])
print(c.server_info())
print([t.name for t in c.tools()])
print(c.call("add", {"a": 1, "b": 2}).result)
c.close()
Connect to the FastMCP example server (requires mcp installed in the interpreter that runs the server):
from mcp_tuning import connect_stdio
c = connect_stdio([".venv/Scripts/python.exe", "examples/servers/simple_stdio_server.py"])
print([t.name for t in c.tools()])
print(c.call("add", {"a": 1, "b": 2}).result)
c.close()
Public API Reference
The public API is intentionally small and exported at the top-level mcp_tuning package.
Connect functions
connect_stdio(command, *, cwd=None, env=None) -> Clientcommand:list[str](recommended) orstr- defaults to running the subprocess with the repo root as
cwd(more reliable in notebooks)
connect_http(rpc_url, *, headers=None) -> Clientconnect_sse(*, sse_url, rpc_url, headers=None) -> Client
Client
Client (alias: MCPClient) is the main entry point for notebooks and scripts.
-
Lifecycle
close()server_info() -> dict | None
-
Explore
tools(timeout_s=30) -> list[ToolItem]tool(name, timeout_s=30) -> ToolItem | Noneresources(timeout_s=30) -> list[ResourceItem]read_resource(uri, timeout_s=60) -> Anyprompts(timeout_s=30) -> list[PromptItem]get_prompt(name, arguments=None, timeout_s=60) -> Any
-
Call
call(name, arguments=None, timeout_s=60) -> CallResultlast() -> CallResult | None
-
Rendering (notebook-friendly)
show(obj, mode='auto'|'json'|'text'|'markdown', compact=True, max_depth=5, max_items=60) -> Nonedumps(obj, compact=True, max_depth=5, max_items=60) -> str
-
Cases (input-only: tool + args)
save_case(tool, arguments, note=None, root=None) -> Pathcases(root=None) -> list[Path]load_case(path) -> CallCasereplay_case(case, timeout_s=60) -> CallResultreplay_case_path(path, timeout_s=60) -> CallResult
-
Exports
export_logs(root=None) -> Pathexport_history(root=None) -> Pathexport_last(root=None) -> Path
Models (data types)
The following types are also exported for type hints and inspection:
ToolItem,ResourceItem,PromptItemCallCase(stores tool + args + metadata)CallResult(includesok/result/error/stderr_tail/ts)LogEvent
Files & Folders
examples/notebooks/: example notebooks (script-first)examples/servers/: example MCP serversdocs/: detailed documentation (start atdocs/index.md)cases/: saved cases (*.json)exports/: exported logs/history/results (*.json)
Troubleshooting
- Timeouts usually mean the server did not start correctly (missing deps, wrong executable, wrong paths).
- For the FastMCP example, run the server with
.venv/Scripts/python.exe.
- For the FastMCP example, run the server with
- Notebook working directories are often not the repo root; this library defaults stdio subprocess
cwdto the repo root. - On timeouts, the error message includes a stderr tail (stdio) to help you debug server startup failures.
Tests
python -m pytest
Metadata
Release files for mcp-tuning 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mcp_tuning-0.1.0.tar.gz | 108.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_tuning-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 135.0 kB
Release files / mcp_tuning-0.1.0.tar.gz
| Download URL | mcp_tuning-0.1.0.tar.gz |
|---|---|
| Size | 108.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a43a89a749965d46ea35c87bc3f43e43b8dbc049ee48ebd088f1d0350897d7d5
|
|
BLAKE2b-256 checksum How to use checksums |
0fc467c49341970b3300c70607fe5a8e5747c2abff2425b84a88ec88fea4b32f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / mcp_tuning-0.1.0-py3-none-any.whl
| Download URL | mcp_tuning-0.1.0-py3-none-any.whl |
|---|---|
| Size | 26.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e45b8e1b413401c59f448761fdaa5d8ae56c13369b84661e6e98769357c314f
|
|
BLAKE2b-256 checksum How to use checksums |
3b0ec73fd91780b8b60f304473343901cc2050b149432f6501bae9b8172aef6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for mcp-tuning 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.