MCPiranha — MCP security scanner
MCPiranha is an open-source MCP security scanner for Model Context Protocol servers. Find prompt injection, tool poisoning, unsafe client configurations, vulnerable packages and risky Python/JavaScript/TypeScript code before giving servers access to your files and credentials.
For developers building MCP servers and people using Claude Desktop, Claude Code, Cursor, VS Code, Codex CLI and other MCP clients.
Static scans do not start servers or run package code. Live inspection and tool invocation are explicit opt-ins. Reports show both findings and what the scanner could actually inspect.
Quick start · Try the demo · Common tasks · Reading results · Limits · Full usage guide
Quick start
Requires Python 3.12+ on Windows, macOS or Linux. Docker is needed for sandboxed local server connections, not static scans.
Scan your configured MCP servers without starting them:
uvx mcpiranha scan --offline --no-lock
Or point at a configuration: uvx mcpiranha scan .mcp.json --offline --no-lock.
For a permanent installation, use pipx install mcpiranha, then mcpiranha scan.
Use mcpiranha --help to list commands, or mcpiranha scan --help for scan options
and short descriptions. Every command supports --help.
On Windows, the same commands work in PowerShell. Quote paths containing spaces:
mcpiranha scan "path:C:\Users\you\My Server" --offline.
Sandboxed connections and behavioral tracing require Docker Desktop using Linux containers.
Without a target, mcpiranha scan discovers supported client configurations on your machine
and in the current project. Supported clients and config paths include
Claude Desktop/Code, Cursor, VS Code, Codex CLI and others on macOS, Linux and Windows.
Registry/advisory lookups use the network by default and send package names and versions to
registries and OSV. Add --offline for local or saved evidence only.
Try the demo
No MCP server required. Scan an inert snapshot containing tool-poisoning instructions:
git clone https://github.com/ethanroubal/MCPiranha.git
cd MCPiranha
uvx mcpiranha scan fixtures/metadata/poisoned-important/snapshots.json --offline --no-lock
Example findings (excerpt):
HIGH MCP-TP-005 Instructions involving credentials or sensitive files
HIGH MCP-TP-009 Parameter shaped to exfiltrate data
Exit code 1 means findings were detected. The sample is JSON data; the scanner does not read
the credential files named in it. Report a false alarm, missed detection or setup issue.
Common tasks
| Task | Command |
|---|---|
| Scan a client configuration | mcpiranha scan .mcp.json |
| Scan a source directory explicitly | mcpiranha scan path:./server-source --offline |
| Inspect an npm release without installing it | mcpiranha scan npm:@scope/server@1.2.3 |
| Inspect a PyPI release without installing it | mcpiranha scan pypi:some-server==1.2.3 |
| Select one server from a config | mcpiranha scan .mcp.json --server search |
| Inspect live tools, prompts and resources | mcpiranha scan .mcp.json --server search --connect |
| Inspect risky combinations of servers | mcpiranha flows .mcp.json |
| Export GitHub code-scanning results | mcpiranha scan .mcp.json -f sarif -o scan.sarif |
--server selects an exact name or ID and can be repeated. Add --client cursor to narrow
client discovery. Unmatched selectors fail before acquisition. Cross-server checks use only
the selected servers; scan the whole configuration to assess their interactions.
What it checks
| Area | Examples |
|---|---|
| Model-facing content | Prompt injection, hidden instructions, encoded payloads, secret-export links |
| Source behavior | Shell/SQL injection, path traversal, SSRF, secret harvesting, persistence |
| Client configuration | Embedded secrets, insecure endpoints, excessive approval settings |
| Supply chain | Known vulnerabilities/malware, dependency risks, publisher/provenance changes |
| Cross-server interactions | Untrusted content combined with private-data access or code execution |
| Opt-in runtime behavior | Synthetic credential access, process activity and unexpected network destinations |
See the rule catalog for individual checks and severity guidance.
Reading results
A finding includes severity, confidence, evidence, location and remediation. Severity is potential impact; confidence is certainty in the analysis. A high-severity static finding can have medium confidence and still need review.
Coverage is reported per server for configuration, tools, source, package/dependency checks, dynamic tracing and invocation. Read it alongside the findings:
| Coverage status | Meaning |
|---|---|
completed |
Evidence was collected within the supported analysis model; not proof of safety |
partial |
Some evidence or analysis was omitted; the report explains why |
skipped |
That stage did not run, such as tool listing during a static scan |
failed / unknown |
The stage failed or its completeness cannot be established |
Unresolved local imports or exhausted analysis budgets mark source coverage partial. Completion does not establish that arbitrary dynamic calls, custom classes or validators were understood.
Use in CI
mcpiranha scan path:./server-source --offline --strict \
--require-coverage source --fail-on high -f json -o scan.json
| Exit code | Meaning |
|---|---|
0 |
No unsuppressed finding at or above the threshold; requested checks passed |
1 |
Findings meet the configured failure threshold |
2 |
Scan/input failure, a strict-mode warning, or an unmet coverage requirement |
--strict fails on scan warnings, including partial source analysis. Repeat
--require-coverage to require additional stages. Requirements apply to every selected server;
a static scan cannot satisfy tool-listing coverage. Saved evidence can satisfy a coverage
requirement but does not imply a fresh connection or lookup.
Reviewed exceptions belong in .mcpiranha.yaml, with a reason and
optional expiration. Suppressed findings remain visible in JSON and SARIF.
Live inspection and change detection
# Start/list the selected server; no tool invocation
mcpiranha scan .mcp.json --server search --connect --save-snapshots ./captures
# Pin launch settings and tool definitions, then detect subsequent changes
mcpiranha lock .mcp.json --connect
mcpiranha verify .mcp.json --connect
Local package servers run in a Docker sandbox by default, with dummy credentials, a read-only
filesystem and runtime networking disabled. Remote URLs require --connect; OAuth is available
with --oauth. Tool calls require explicit --invoke NAME and can have side effects.
For synthetic-credential tracing, bounded fuzzing, remote authentication and sandbox options, see the usage guide.
Limits
Detection is bounded and heuristic. A clean report does not prove that a server is safe.
Novel paraphrases, unresolved/dynamic calls, arbitrary heap objects, custom validators,
filesystem races and dormant runtime triggers remain gaps. Registry dependency resolution may
differ from an installed environment; Docker image source is not analyzed.
basename() alone does not establish containment; use a checked path or filename allowlist.
The labeled evaluation records attacks, benign controls, misses, false alarms and implementation fingerprints. Its examples were used during development; passing that set is not an independent estimate of real-world accuracy. Tests also cover two existing vulnerable/fixed release pairs. Broader independent validation remains necessary.
Development and documentation
CI checks Windows, macOS and Linux, isolated wheel installations, and pinned vulnerable/fixed release pairs. Release tags must pass these checks before the tested artifacts reach PyPI.
uv sync --all-extras
uv run pytest -q
uv run ruff check .
uv run pyright
- Advanced usage and runtime scanning
- Testing and optional Docker/registry checks
- Detection-quality evaluation
- Rules · Client support · Architecture
- Changelog · Adding rules
The optional local classifier is experimental.
Feedback from scans of real MCP servers helps improve detection. Share a sanitized minimal example through GitHub issues, including your scanner version and what you expected. Licensed under Apache-2.0.
Metadata
Release files for MCPiranha 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcpiranha-0.4.1.tar.gz | 198.7 kB | With provenance | Details for mcpiranha-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcpiranha-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for mcpiranha-0.4.1-py3-none-any.whl |
Total release size: 442.3 kB
Release files / mcpiranha-0.4.1.tar.gz
| Download URL | mcpiranha-0.4.1.tar.gz |
|---|---|
| Size | 198.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe0576fb9410facb34ea990c930c309dc87477bb61c99928be91aa867b812492
|
|
BLAKE2b-256 checksum How to use checksums |
3dd19f5dcdd91ca83ee03723f63fc08eb8ca9ba239588dbb97637cb7e644aaaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logRelease files / mcpiranha-0.4.1-py3-none-any.whl
| Download URL | mcpiranha-0.4.1-py3-none-any.whl |
|---|---|
| Size | 243.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e758508bee679f9ddfb7698eebfe8c296bab3d1930cd12f56f44e9c882f4cdfa
|
|
BLAKE2b-256 checksum How to use checksums |
361ec106643792ca7de179a0a8005fa5e896ac7436255b738fc744519727aa6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logSecurity for MCPiranha 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mcpiranha-0.4.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.