Skip to content

Tests

Section 10 · From docs/MCP_INTERNALS.md on GitHub

10.1 Layout

File What it covers
conftest.py Fixtures: sample_dataset, sample_paths, workspace, layer (policy open), call
fixtures/sample_estate.py The synthetic AWS / Azure / GCP estate; write_estate(root) writes inventory and report files
_adapter_testkit.py A small registry (echo, stats, slow, sleepy, fail, touch, linked, noisy, a resource, a template with completions, a prompt) and build_layer(), used by the adapter, native, middleware and CLI tests
test_catalog_registry.py Catalog-wide invariants and wire validity
test_catalog_regressions.py Regressions found by calling every tool during the tool-reference pass
test_policy_regressions.py Privacy-layer regressions found by running the full catalog against the sample estate
test_catalog_workspace.py, _inventory, _graph, _findings, _compliance, _ontology, _resources, _prompts, _export_live_meta The catalog modules; live tools with the engine monkeypatched
test_state.py Dataset and Workspace: loading, lookup, caches, mutation, diff, path safety
test_policy.py, test_transforms.py, test_privacy_tools.py Policy and transforms (see MCP_PRIVACY.md)
test_middleware.py The five middleware classes
test_native_protocol.py The protocol engine in memory, both eras
test_native_stdio.py A real subprocess over stdio, raw and with the SDK client; python -m cloudg.mcp
test_native_http.py Real localhost sockets with urllib and, when installed, the SDK client
test_native_auth.py Token parsing and lookup
test_adapters_sdk.py mcp 2.x (MCPServer, low-level, both eras) and mcp 1.x (FastMCP, low-level); each half skips on the other major version
test_adapters_fastmcp.py fastmcp 2/3/4; skipped without fastmcp
test_adapters_export.py export_definitions, detection, build_server
test_adapters_serve.py create_layer_from_options and serving over HTTP with each flavor
test_cli_mcp.py The click commands through CliRunner

10.2 Running

.venv/bin/python -m pytest tests/mcp -q
.venv/bin/ruff check cloudg/mcp tests/mcp

On the branch with mcp 2.3.0 and no fastmcp, the suite gave 823 passed, 6 skipped, 834 warnings in 89.51s. The skips are the mcp 1.x and fastmcp sections.

10.3 The framework matrix

The adapters are only proven against the frameworks they were run with. Build one throwaway venv per target with uv, install cloudg editable plus the framework and pytest, and run the adapter-facing tests from the repository root:

cd /path/to/cloudg

uv venv /tmp/venv-mcp1 --python 3.13
uv pip install --python /tmp/venv-mcp1/bin/python -e . "mcp<2" pytest pytest-asyncio

uv venv /tmp/venv-fastmcp4 --python 3.13
uv pip install --python /tmp/venv-fastmcp4/bin/python -e . "fastmcp>=4,<5" pytest pytest-asyncio

uv venv /tmp/venv-fastmcp3 --python 3.13
uv pip install --python /tmp/venv-fastmcp3/bin/python -e . "fastmcp>=3,<4" pytest pytest-asyncio

uv venv /tmp/venv-fastmcp2 --python 3.13
uv pip install --python /tmp/venv-fastmcp2/bin/python -e . "fastmcp>=2,<3" pytest pytest-asyncio

for v in /tmp/venv-mcp1 /tmp/venv-fastmcp4 /tmp/venv-fastmcp3 /tmp/venv-fastmcp2; do
  $v/bin/python -m pytest tests/mcp/test_native_*.py tests/mcp/test_adapters_*.py \
    tests/mcp/test_middleware.py tests/mcp/test_cli_mcp.py -q
done

What those environments contained and what they gave for this release:

venv Packages Command Result
mcp 1.x mcp 1.30.0 native, adapters, middleware, CLI tests 98 passed, 28 skipped
fastmcp 4 fastmcp 4.0.11, mcp 2.3.0 test_adapters_fastmcp.py test_adapters_sdk.py 20 passed, 2 skipped
fastmcp 3 fastmcp 3.4.8, mcp 1.30.0 same 10 passed, 12 skipped, 2 warnings
fastmcp 2 fastmcp 2.14.7, mcp 1.30.0 same 10 passed, 12 skipped

The venvs used for those numbers were created with uv venv and an editable install as above; the exact uv pip install lines are a reconstruction from their contents (editable cloudg, the framework, pytest 9.1.1, pytest-asyncio 1.4.0).

When you touch an adapter, run the matrix for every framework that adapter serves, and update the version table in MCP.md section 7.