mcp-scanner

module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0

README

mcp-scanner

A security scanner for Model Context Protocol servers. It scans live servers, source trees, and packages, and reports both findings and coverage gaps. SAFE requires every required analyzer to finish without a reported coverage gap:

COMPLETED + SAFE      required analysis ran, nothing blocking
COMPLETED + UNSAFE    required analysis ran, something blocking
PARTIAL   + UNKNOWN   an analyzer could not finish
ERROR     + UNKNOWN   an analyzer failed
SKIPPED   + UNKNOWN   no analyzer produced usable analysis

Timeouts, crashes, unexplained files, and missing statuses downgrade the scan. An analyzer error is never self-excusing; only an explicit best-effort policy can exempt it. Skips that could hide source, such as a symlink to a source directory outside the scan root, also record a limit. Every limit downgrades the scan.

Install

go install github.com/devlab-group/mcp-scanner/cmd/mcp-scanner@latest

GitHub releases include prebuilt binaries for Linux, macOS and Windows, SHA256SUMS, and a build provenance attestation for each binary. Verify the checksum and attestation before running a downloaded binary:

sha256sum --check --ignore-missing SHA256SUMS
gh attestation verify mcp-scanner_linux_amd64 \
  --repo devlab-group/mcp-scanner \
  --signer-workflow devlab-group/mcp-scanner/.github/workflows/dist.yml \
  --source-ref refs/tags/vX.Y.Z

The attestation check verifies that the binary came from this repository's release workflow and the specified tag. The checksum detects download damage; because it comes from the same release as the binary, it cannot establish the binary's origin. The attestation provides that check.

Signature matching requires libyara and a tagged build:

# Debian, Ubuntu
sudo apt install libyara-dev pkg-config

# Fedora, RHEL
sudo dnf install yara-devel pkgconf-pkg-config

# macOS
brew install yara pkg-config
make build-yara

See the YARA installation guide for source builds. If /usr/local/lib is outside the linker path, run sudo ldconfig or set LD_LIBRARY_PATH=/usr/local/lib. Builds without the tag report YARA as unavailable.

Use

Scan a remote server:

mcp-scanner remote https://mcp.example.com/mcp

Scan a trusted stdio server as a child process:

mcp-scanner stdio -- npx -y @example/mcp-server

This runs the target on your machine with your privileges. For untrusted code, use source or package, which do not execute it. runtime stdio runs only an absolute, statically linked ELF executable in a container and needs a trusted snapshot.

Scan the servers declared in your MCP client configuration:

mcp-scanner known-configs --run

--run scans remote entries. Stdio entries are skipped unless you also pass --include-stdio, and any skipped stdio entry makes the command exit 3.

Scan a source tree, or a published package:

mcp-scanner source ./my-mcp-server
mcp-scanner package npm:@example/mcp-server@1.4.0

Gate a pipeline:

mcp-scanner remote https://mcp.example.com/mcp --format sarif --output results.sarif --fail-on high

Exit codes:

Code Meaning
0 scan completed, policy passed
1 bad flags or configuration
2 scan completed, policy failed
3 scan could not determine an answer
4 the scanner itself broke

--fail-on defaults to high, so a pipeline that never sets it still stops on a high or critical finding. Pass --fail-on none to report without gating.

Treat exit code 3 as a pipeline failure. It means the scan did not finish.

What it checks

  • MCP protocol conformance, capability declarations against actual behaviour, and how the server handles malformed input
  • Authentication, token validation and session binding
  • Prompt injection, tool poisoning, hidden Unicode and credential harvesting in the text a server hands a model
  • Source-to-sink dataflow across files, in Go, Python, JavaScript, TypeScript, Java and Rust
  • Mismatch between what a tool says it does and what its handler reaches
  • Dependency vulnerabilities and package contents, without running install scripts
  • Optional sandboxed confirmation of static findings
  • Optional model-assisted review that supplements deterministic evidence

Scanning safely

By default, the scanner discovers capabilities without invoking real tools.

--active-probes none        connect and read declarations
--active-probes safe        also send malformed protocol messages a correct server must reject
--active-probes tool-calls  permit tools named with --allow-tool-call

safe is the default. Its tools/call probes use an invalid name or a name that does not exist, which a conforming server rejects before dispatch. A loose server may dispatch such a request before validating the name. No setting invokes arbitrary declared tools on a live server or sends intentionally destructive requests. The runtime analyzer can invoke declared tools only inside its sandbox.

Documentation

Development

make check      # gofmt, vet, test, race, vulnerability scan, version check
make build

Three rules hold the design together: SAFE must mean the analysis ran, every finding carries evidence, and every analyzer reports what it did not look at.

Security

Report vulnerabilities privately. See SECURITY.md.

License

Apache License 2.0. See LICENSE. Binaries also include the third-party components listed in THIRD_PARTY_NOTICES.

Directories

Path Synopsis
cmd
mcp-scanner command
Command mcp-scanner is the MCP security scanner CLI
Command mcp-scanner is the MCP security scanner CLI
mcp-scanner-api command
Command mcp-scanner-api serves scans and health checks over HTTP
Command mcp-scanner-api serves scans and health checks over HTTP
internal
analyzers/auth
Package auth analyzes authentication, token, and session security for a live MCP target.
Package auth analyzes authentication, token, and session security for a live MCP target.
analyzers/behavioral
Package behavioral compares what an MCP capability says it does against what its handler actually reaches, using only the graph the source pass already built: no LLM, just a fixed vocabulary matched against the description and a fixed catalogue of filesystem/network/process/credential calls matched against everything the handler statically reaches.
Package behavioral compares what an MCP capability says it does against what its handler actually reaches, using only the graph the source pass already built: no LLM, just a fixed vocabulary matched against the description and a fixed catalogue of filesystem/network/process/credential calls matched against everything the handler statically reaches.
analyzers/cisco
Package cisco sends a target's declared MCP surface to Cisco AI Defense for inspection (prompt injection, data exfiltration setups, unsafe content).
Package cisco sends a target's declared MCP surface to Cisco AI Defense for inspection (prompt injection, data exfiltration setups, unsafe content).
analyzers/llm
Package llm sends a target's declared MCP surface (tool descriptions, prompt text, server instructions) to a configured model for semantic judgement.
Package llm sends a target's declared MCP surface (tool descriptions, prompt text, server instructions) to a configured model for semantic judgement.
analyzers/promptdefense
Package promptdefense detects prompt injection, hidden content and tool poisoning in the text an MCP server hands to an LLM: tool and prompt descriptions, resource content and server instructions.
Package promptdefense detects prompt injection, hidden content and tool poisoning in the text an MCP server hands to an LLM: tool and prompt descriptions, resource content and server instructions.
analyzers/protocol
Package protocol checks MCP conformance from a snapshot.
Package protocol checks MCP conformance from a snapshot.
analyzers/readiness
Package readiness checks the declared security posture of an MCP server: whether it says anything about authentication, whether tools document themselves and mark destructive operations as such, and whether resource URIs constrain what they can reach.
Package readiness checks the declared security posture of an MCP server: whether it says anything about authentication, whether tools document themselves and mark destructive operations as such, and whether resource URIs constrain what they can reach.
analyzers/runtime
Package runtime is the analyzer that actually calls ac.Runtime: it turns a tool's declared input schema into fuzz payloads, runs them inside the sandbox with canaries planted, and reports only what an observation actually demonstrated
Package runtime is the analyzer that actually calls ac.Runtime: it turns a tool's declared input schema into fuzz payloads, runs them inside the sandbox with canaries planted, and reports only what an observation actually demonstrated
analyzers/supplychain
Package supplychain finds pinned dependencies and reports matching OSV vulnerabilities.
Package supplychain finds pinned dependencies and reports matching OSV vulnerabilities.
analyzers/taint
Package taint traces MCP-reachable values to dangerous sinks across files.
Package taint traces MCP-reachable values to dangerous sinks across files.
analyzers/virustotal
Package virustotal looks up hashes for a bounded set of files under the scan root.
Package virustotal looks up hashes for a bounded set of files under the scan root.
analyzers/yara
Package yara scans text an MCP server declares - tool and prompt descriptions, prompt text, resource contents, and server instructions - against YARA signatures.
Package yara scans text an MCP server declares - tool and prompt descriptions, prompt text, resource contents, and server instructions - against YARA signatures.
api
Package api implements the scanner's HTTP API: POST /v1/scans submits a target, GET /v1/scans/{id} polls its result, and /healthz, /readyz serve standard liveness/readiness checks.
Package api implements the scanner's HTTP API: POST /v1/scans submits a target, GET /v1/scans/{id} polls its result, and /healthz, /readyz serve standard liveness/readiness checks.
app
Package app assembles the scanner for the CLI and HTTP API
Package app assembles the scanner for the CLI and HTTP API
config
Package config loads and validates scanner configuration.
Package config loads and validates scanner configuration.
dossier
Package dossier collects everything the static pipeline knows about an MCP server's source tree into one document, for a later reviewer - a person or a model - to read without the tree at hand: languages and manifests, the MCP SDK and its version, declared server identity, and for each tool, prompt and resource its declaration, handler code and reachable behavior.
Package dossier collects everything the static pipeline knows about an MCP server's source tree into one document, for a later reviewer - a person or a model - to read without the tree at hand: languages and manifests, the MCP SDK and its version, declared server identity, and for each tool, prompt and resource its declaration, handler code and reachable behavior.
evals
Package evals runs the security benchmark corpus and scores the scanner against it.
Package evals runs the security benchmark corpus and scores the scanner against it.
httpx
Package httpx is the outbound HTTP layer for everything the scanner fetches: MCP endpoints, package registries, vulnerability data and model providers
Package httpx is the outbound HTTP layer for everything the scanner fetches: MCP endpoints, package registries, vulnerability data and model providers
llm
Package llm holds what the provider adapters (openai, anthropic, bedrock) share: request configuration, a classified error type, and the HTTP call that turns a raw response into one of them.
Package llm holds what the provider adapters (openai, anthropic, bedrock) share: request configuration, a classified error type, and the HTTP call that turns a raw response into one of them.
llm/anthropic
Package anthropic implements analyzer.LLMClient with the Anthropic Messages API
Package anthropic implements analyzer.LLMClient with the Anthropic Messages API
llm/bedrock
Package bedrock implements analyzer.LLMClient against Anthropic Claude models hosted on AWS Bedrock, calling bedrock-runtime InvokeModel directly over net/http with a hand-rolled SigV4 signature
Package bedrock implements analyzer.LLMClient against Anthropic Claude models hosted on AWS Bedrock, calling bedrock-runtime InvokeModel directly over net/http with a hand-rolled SigV4 signature
llm/openai
Package openai implements analyzer.LLMClient against the OpenAI chat completions API
Package openai implements analyzer.LLMClient against the OpenAI chat completions API
mcp/client
Package client is the wiring seam other packages depend on: it turns a model.Target into a live MCP connection (scanner.Preparer, analyzer.Dialer) or a replayed one (LoadSnapshotBytes), and implements analyzer.Session on top of the go-sdk client plus a minimal raw JSON-RPC channel for probes the typed SDK client will not build
Package client is the wiring seam other packages depend on: it turns a model.Target into a live MCP connection (scanner.Preparer, analyzer.Dialer) or a replayed one (LoadSnapshotBytes), and implements analyzer.Session on top of the go-sdk client plus a minimal raw JSON-RPC channel for probes the typed SDK client will not build
mcp/discovery
Package discovery drives the standard MCP discovery methods against an initialized session and converts the result into a model.Snapshot
Package discovery drives the standard MCP discovery methods against an initialized session and converts the result into a model.Snapshot
mcp/snapshot
Package snapshot canonicalizes, hashes, compares, saves, and loads snapshots
Package snapshot canonicalizes, hashes, compares, saves, and loads snapshots
mcp/surface
Package surface renders a snapshot's declared MCP capability surface - instructions, tools, prompts, resources, resource templates - as text for something that judges it (a model, a third-party classifier), stopping once a caller-supplied character budget is used.
Package surface renders a snapshot's declared MCP capability surface - instructions, tools, prompts, resources, resource templates - as text for something that judges it (a model, a third-party classifier), stopping once a caller-supplied character budget is used.
mcp/transport
Package transport builds SDK transports for an MCP target and enforces the scanner's own SSRF guard before any of them connect
Package transport builds SDK transports for an MCP target and enforces the scanner's own SSRF guard before any of them connect
policy
Package policy turns a scan result into a pass/fail decision and a process exit code.
Package policy turns a scan result into a pass/fail decision and a process exit code.
report
Package report holds what every output writer (json, sarif, table, summary) shares
Package report holds what every output writer (json, sarif, table, summary) shares
report/json
Package json writes sanitized ScanResult values using the versioned schema.
Package json writes sanitized ScanResult values using the versioned schema.
report/sarif
Package sarif writes a model.ScanResult as SARIF 2.1.0 (https://docs.oasis-open.org/sarif/sarif/v2.1.0/), the format GitHub code scanning and most CI security dashboards consume
Package sarif writes a model.ScanResult as SARIF 2.1.0 (https://docs.oasis-open.org/sarif/sarif/v2.1.0/), the format GitHub code scanning and most CI security dashboards consume
report/summary
Package summary writes a condensed, human-readable overview of a model.ScanResult: verdict, finding counts, coverage gaps and the most severe findings - not the full table internal/report/table produces
Package summary writes a condensed, human-readable overview of a model.ScanResult: verdict, finding counts, coverage gaps and the most severe findings - not the full table internal/report/table produces
report/table
Package table writes a model.ScanResult as a plain-text table for a terminal
Package table writes a model.ScanResult as a plain-text table for a terminal
runtime/canary
Package canary generates the fake secrets planted inside a sandbox run.
Package canary generates the fake secrets planted inside a sandbox run.
runtime/fuzz
Package fuzz generates schema-driven payloads for a tool's declared JSON Schema input.
Package fuzz generates schema-driven payloads for a tool's declared JSON Schema input.
runtime/observer
Package observer turns a raw sandbox run into []analyzer.Observation.
Package observer turns a raw sandbox run into []analyzer.Observation.
runtime/sandbox
Package sandbox implements analyzer.RuntimeExecutor on top of the Docker CLI.
Package sandbox implements analyzer.RuntimeExecutor on top of the Docker CLI.
source
Package source builds a repository graph and discovers MCP registrations.
Package source builds a repository graph and discovers MCP registrations.
source/graph
Package graph is the exported source-code model shared between the discovery pass and every analyzer that reasons about dataflow: symbols, imports, the call graph and the MCP capabilities found in it
Package graph is the exported source-code model shared between the discovery pass and every analyzer that reasons about dataflow: symbols, imports, the call graph and the MCP capabilities found in it
source/inventory
Package inventory walks regular source files within a hard root boundary and records reported skips.
Package inventory walks regular source files within a hard root boundary and records reported skips.
source/language
Package language adapts each supported source language to a common shape: its file extensions, its tree-sitter grammar, and the small set of node kinds the parser and taint walker need to recognize (a function, a call, an assignment, a string literal)
Package language adapts each supported source language to a common shape: its file extensions, its tree-sitter grammar, and the small set of node kinds the parser and taint walker need to recognize (a function, a call, an assignment, a string literal)
source/parser
Package parser turns one source file into symbols, imports and calls using the language's tree-sitter grammar and queries.
Package parser turns one source file into symbols, imports and calls using the language's tree-sitter grammar and queries.
source/queries
Package queries embeds the tree-sitter query files for every supported language, so parsing never depends on a query file being present on disk at runtime
Package queries embeds the tree-sitter query files for every supported language, so parsing never depends on a query file being present on disk at runtime
source/registration
Package registration finds where MCP tools, prompts and resources are registered, across direct SDK calls, decorators/annotations/attributes, a wrapper function that forwards into the SDK, and registration inside a loop - working entirely off the graph the parser already built, so it never re-reads source.
Package registration finds where MCP tools, prompts and resources are registered, across direct SDK calls, decorators/annotations/attributes, a wrapper function that forwards into the SDK, and registration inside a loop - working entirely off the graph the parser already built, so it never re-reads source.
supplychain
Package supplychain holds the seam between the code that downloads a package target and the analyzer that has to say something about it
Package supplychain holds the seam between the code that downloads a package target and the analyzer that has to say something about it
supplychain/archive
Package archive extracts hostile input under size and count limits.
Package archive extracts hostile input under size and count limits.
supplychain/npm
Package npm downloads a published npm package's tarball and unpacks it with internal/supplychain/archive.
Package npm downloads a published npm package's tarball and unpacks it with internal/supplychain/archive.
supplychain/osv
Package osv queries the OSV (Open Source Vulnerabilities) database for a set of ecosystem/name/version coordinates, and parses the lockfile formats that produce those coordinates in the first place
Package osv queries the OSV (Open Source Vulnerabilities) database for a set of ecosystem/name/version coordinates, and parses the lockfile formats that produce those coordinates in the first place
supplychain/pypi
Package pypi downloads and extracts PyPI sdists and wheels.
Package pypi downloads and extracts PyPI sdists and wheels.
testutil
Package testutil holds helpers shared by tests in several packages
Package testutil holds helpers shared by tests in several packages
pkg
analyzer
Package analyzer defines the contract every security analyzer implements.
Package analyzer defines the contract every security analyzer implements.
scanner
Package scanner runs analyzers against a target and turns their results into a single verdict.
Package scanner runs analyzers against a target and turns their results into a single verdict.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL