Skip to main content

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 pass
  • status: "fail" becomes a pytest failure with the detail as the message
  • status: "skip" becomes a pytest skip
  • skip: true in the YAML skips the test (for known bugs)

The Go binary handles all MCP protocol interaction. The plugin is a thin bridge.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_mcp_assert-0.8.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_mcp_assert-0.8.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_mcp_assert-0.8.0.tar.gz.

File metadata

  • Download URL: pytest_mcp_assert-0.8.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

Hashes for pytest_mcp_assert-0.8.0.tar.gz
Algorithm Hash digest
SHA256 a9a0b81dcd667160edee6b454bc444abc926df1123dab217d3020e97e72e1910
MD5 9b216e105b5dd56adfb33a53bb3cf1a2
BLAKE2b-256 c515a7c5d3578c5a113f007c53f221017d74f16d5467f8f0f3131077c5eaf17e

See more details on using hashes here.

File details

Details for the file pytest_mcp_assert-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_mcp_assert-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cc9f7d62dada4dc29c96bbaf5af8f9fdf5f3172684f643cac8a8c575b96529c
MD5 c8a03180a1ea1cda40fd92f84220150e
BLAKE2b-256 5a74cddb3b86dd3a8e31f7b36e6c4479c357a627e8a6e0e31baec7e6e82a3176

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page