mcp-witness

Analyzer (Phase 1)

Static analyzer for MCP servers. Spec: ../docs/static-rules.md.

Status

Implemented (Layer 1 — Python AST + captured JSON):

Not yet implemented:

Layout

File Purpose
discover.py Walks a path, parses Python files with ast, finds @.tool decorated functions
rules.py The three detection rules, plus the rule registry
analyze.py analyze_path() — orchestrator: discover then run all rules
types.py Finding, DiscoveredTool dataclasses
__main__.py CLI
lint_scenarios.py YAML lint tool (separate CLI: mcp-witness-lint-scenarios)
tests/ Rule fixtures (vulnerable + safe examples) + tests; scenario-lint tests

Usage

# Analyze an MCP server source tree:
mcp-witness-analyze /path/to/some-mcp-server

# JSON output, gate at high severity:
mcp-witness-analyze --format json --fail-on critical ./src

# Lint scenario files:
mcp-witness-lint-scenarios scenarios/

Running the tests

pip install -e ".[dev]"
pytest analyzer/tests/

False-positive expectations

Layer 1 is heuristic. Expected v0.1 precision (vibes-tuned, not corpus-tuned):