pytest plugin for mcp-assert: run MCP server assertions as pytest test items
Project description
pytest-mcp-assert
pytest plugin for mcp-assert. Run MCP server assertions as pytest test items.
Install
pip install pytest-mcp-assert
You also need the mcp-assert binary. Any of these:
brew install blackwell-systems/tap/mcp-assert
pip install mcp-assert
npm install -g @blackwell-systems/mcp-assert
Usage
Write assertion YAML files (see mcp-assert docs):
# evals/echo.yaml
name: echo returns the message
server:
command: my-mcp-server
assert:
tool: echo
args:
message: hello
expect:
not_error: true
contains: ["hello"]
timeout: 30s
Run with pytest:
pytest --mcp-suite evals/
Each YAML file becomes a pytest test item with pass/fail/skip semantics.
Options
| Option | pyproject.toml | Description |
|---|---|---|
--mcp-suite DIR |
mcp_suite |
Directory containing assertion YAML files |
--mcp-fixture DIR |
mcp_fixture |
Fixture directory (substituted for {{fixture}}) |
--mcp-server CMD |
Override server command for all assertions | |
--mcp-timeout DUR |
mcp_timeout |
Per-assertion timeout (default: 30s) |
--mcp-binary PATH |
Path to mcp-assert binary |
Configuration
# pyproject.toml
[tool.pytest.ini_options]
mcp_suite = "evals/"
mcp_fixture = "fixtures/"
mcp_timeout = "30s"
Then just run pytest with no extra flags.
How it works
The plugin discovers .yaml files in the suite directory, creates a pytest Item for each one, and calls mcp-assert run --suite <file> --json to execute it. The JSON result is mapped to pytest outcomes:
status: "pass"becomes a pytest passstatus: "fail"becomes a pytest failure with the detail as the messagestatus: "skip"becomes a pytest skipskip: truein the YAML skips the test (for known bugs)
The Go binary handles all MCP protocol interaction. The plugin is a thin bridge.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_mcp_assert-0.5.0.tar.gz.
File metadata
- Download URL: pytest_mcp_assert-0.5.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
057dc77bbfc901786e404b27ca11cdd482f79bf0867e0a2944182cbc847c0767
|
|
| MD5 |
51f8d09c25cd9831331c95ae61939d60
|
|
| BLAKE2b-256 |
1ce464ba3ce24dbbee67881057003b4cea563b6069c1a5ba7b818074b82bbd81
|
File details
Details for the file pytest_mcp_assert-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pytest_mcp_assert-0.5.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5409f2d8afdfabfd3a52cc1eb863dd4c20feaf93e80a20ce27eddc67b1bbfcf
|
|
| MD5 |
54e6b9338c6fe90d9dbd02832b09a23d
|
|
| BLAKE2b-256 |
cac5e9e79e57b57e0c9dc1b46db43c562e17e10c566ee3262cc00b39f8e3a634
|