Skip to main content

MCP ScopeCheck

Inspect before you connect. MCP ScopeCheck is a pre-install static auditor that compares a Python MCP tool's declared contract with security-relevant behavior reachable from its source—without importing or running the server.

$ mcp-scopecheck audit examples/unsafe_docs_server

[CRITICAL] MSC001 Agent-directed instruction in tool description
[CRITICAL] MSC105 Environment data reaches network egress
[HIGH] MSC101 Read-only claim conflicts with reachable behavior
[HIGH] MSC102 Network egress is not disclosed
[HIGH] MSC103 Filesystem scope is not constrained
[HIGH] MSC104 Dangerous filesystem default

The paired hardened fixture retains its intended filesystem-read capability but returns Findings (0) and exits 0.

Status: v0.1.x vertical slice. v0.1.1 corrects repository identity and release automation without changing scanner behavior.

Why this exists

An MCP tool description and its annotations are claims. They do not enforce a permission boundary. A tool named search_project_docs can still contain code that reads /, accesses environment values, starts a process, or sends data over the network.

ScopeCheck asks a narrow, evidence-backed question:

Does the tool's declared contract agree with behavior reachable from the tool's source?

That focus complements manifest scanners and runtime testing tools. It does not replace either.

Security invariant

ScopeCheck reads source as text and parses it with Python's ast module. Target modules are never imported, decorators are never invoked, and MCP servers are never started. A regression test places a real top-level side effect in a fixture and proves it does not execute during an audit.

Install from source

Python 3.11 or newer is required. The scanner has no runtime dependencies.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .

Use

mcp-scopecheck audit examples/unsafe_docs_server
mcp-scopecheck audit examples/hardened_docs_server

Audit any local Python file or directory by replacing the target path. Use --fail-on high (or low, medium, or critical) to set the exit-1 threshold.

Exit codes:

Code Meaning
0 No finding met the configured threshold
1 One or more findings met the configured threshold
2 Invalid input, no supported tools, diagnostics, or another audit error

What v0.1 detects

Rule Severity What it means
MSC001 Critical Tool description contains instructions aimed at controlling or concealing behavior from the host model/user
MSC101 High/Critical readOnlyHint=true conflicts with reachable write, network, process, or dynamic-code behavior; process and dynamic code conflicts are Critical
MSC102 High Reachable network egress is missing from the tool description
MSC103 High Path-like input reaches filesystem operations without a recognized containment check
MSC104 High A path/root parameter defaults to / or ~
MSC105 Critical Environment-derived data reaches a network call in the same reachable function
MSC106 Critical Process or shell execution is reachable
MSC107 Critical eval or exec is reachable

Observed capabilities are reported separately from findings. Filesystem reads are not automatically vulnerabilities; the contract comparison determines whether the behavior is inconsistent or insufficiently constrained.

The 5-S report

Every audit is organized around:

  • Source — what local source was inspected.
  • Surface — which MCP tools were discovered.
  • Scope — parameters and declared annotations.
  • Side effects — filesystem, environment, network, process, and dynamic-code capabilities reachable from each tool.
  • Snapshot — a deterministic SHA-256 digest of the extracted contract and capabilities.

Current boundaries

v0.1 intentionally supports:

  • Local Python files/directories
  • Module-level @mcp.tool, @mcp.tool(), and equivalent .tool decorators
  • Same-file helper-call reachability
  • Direct standard-library and common HTTP-client sinks

It does not yet prove:

  • Cross-module or dynamically dispatched call paths
  • Runtime-only tool registration
  • TypeScript/JavaScript behavior
  • Authorization correctness
  • Whether all observed data actually leaves the process, except the narrow same-function flow implemented by MSC105
  • Safety of a running MCP server

MSC103 requires a recognized containment comparison; .resolve() by itself is only normalization and does not suppress the finding. MSC105 follows direct and simple assignment propagation in lexical order within one function, but it does not model complete Python control flow.

A clean report is not proof of safe runtime behavior. See architecture and threat model.

Develop

The test suite uses only the Python standard library. Release tooling is development-only and pinned in requirements-dev.txt:

python3 -m venv .venv
.venv/bin/python -m pip install --disable-pip-version-check -r requirements-dev.txt
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m unittest discover -s tests -v
PYTHONPATH=src .venv/bin/python -m mcp_scopecheck audit examples/unsafe_docs_server
PYTHONPATH=src .venv/bin/python -m mcp_scopecheck audit examples/hardened_docs_server

Before a public release, activate that environment and run scripts/preflight.sh. It runs the same test, compile, Ruff, strict mypy, and build gates as CI; it additionally requires Gitleaks and fails closed if the scanner is unavailable.

For the source-evidence, unsafe/hardened, and exit-code demo:

scripts/demo.sh

Roadmap

  • Cross-module call graph and argument-aware data flow
  • TypeScript parser backed by a real syntax tree
  • JSON/SARIF output and stable rule schema
  • Snapshot comparison for tool-definition drift
  • Optional semantic description analysis with an explicit privacy boundary
  • Reproducible benchmark corpus with measured precision and recall

License

MIT

Download files

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

Source Distribution

mcp_scopecheck-0.1.1.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

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

mcp_scopecheck-0.1.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_scopecheck-0.1.1.tar.gz.

File metadata

  • Download URL: mcp_scopecheck-0.1.1.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mcp_scopecheck-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4938db89e2d33f7a83034b74c16a66800decee7f063d5e93ca4ed8e105fee6c1
MD5 86e80922564e06d3b698341b25f650f7
BLAKE2b-256 cd38a11a618a8651a9ce2255236829c967e177df14223f24c22060b86a7636fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_scopecheck-0.1.1.tar.gz:

Publisher: release.yml on iamudayrathore/mcp-scopecheck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_scopecheck-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mcp_scopecheck-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mcp_scopecheck-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d275127d3cf35accea14b3e3a7061ec8d0c4777fb080da27d0c99d1a088fa1af
MD5 7dc22879edbbbc279ba44944315dbc46
BLAKE2b-256 cc6a6f011b63c1f80a07f97f15e06e9fa8b070bc9911adcd9d6e2dbaed481245

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_scopecheck-0.1.1-py3-none-any.whl:

Publisher: release.yml on iamudayrathore/mcp-scopecheck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.3

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

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