MCP security starts with an audit, not a marketplace star rating. Every Model Context Protocol server you attach to Claude Code, Cursor, Codex, or OpenCode can read files, call APIs, and push text straight into the model's tool context. This guide is a practical MCP security audit you can run on a developer laptop: inventory configs, pin packages, scan offline, and record what still needs runtime proof.
The first two sentences answer the search intent: MCP security means controlling who launches which server, with which credentials, exposing which tool descriptions—before the agent connects.
TL;DR
| Question | Answer |
|---|---|
| Am I affected? | Yes, if any MCP server can touch secrets, prod APIs, or writable paths |
| Is there a fix? | Pin versions, deny risky launchers, review tool schemas, patch SDK CVEs |
| Does data leave my machine? | Remote MCP and tools with network access can exfiltrate data the server can read |
| Fast first step? | List every MCP JSON path, then beam scan each file with --mcp offline |
| Primary spec sources? | MCP security best practices and OWASP MCP cheat sheet |
What is MCP security?
MCP security is how you keep Model Context Protocol integrations from becoming undeclared root access for the model. The protocol is intentionally flexible: a config file can spawn npx @some-scope/server@latest, open an HTTP listener, or pass through OAuth tokens.
The MCP local server compromise section states that many client hosts run the subprocess as the same user as the IDE—so a malicious or hijacked server inherits your SSH keys, cloud profiles, and browser cookies reachable from that user.
OWASP's DevSecOps MCP guidance adds the agent angle: permission prompts are not a security boundary against a manipulated agent; isolation and egress control matter.
This audit does not replace those documents—it operationalizes them on paths you actually have.
Step 1 — Inventory every MCP config scope
Claude Code's security documentation notes that project .mcp.json is not the full picture: user-scoped servers, IDE connectors, and plugins also load. Your audit must catch all scopes.
| Scope | Typical location (verify on your OS) | Why it matters |
|---|---|---|
| Project | .mcp.json in repo root | Committed to git; CI and teammates inherit it |
| User / CLI | Dotfile MCP JSON for your agent CLI | Survives project switches |
| IDE | Editor MCP settings JSON | May differ from terminal CLI |
| Plugins | Bundled manifests in marketplace plugins | Easy to miss in code review |
Export each file path into an evidence table: client, path, last git commit, reviewer, date. Redact tokens in the copy you store.
Cross-check against our MCP server security review for per-server evidence fields.
Step 2 — Pin every package and command
The OWASP MCP cheat sheet warns that npx package@latest is an open-ended supply chain. Your audit should flag:
- Floating semver (
^,latest, branch names) - Shell wrappers (
bash -c,cmd /c) around downloads - Docker
:latesttags without digest - Remote HTTP/SSE URLs with no ownership record
Good pin example (illustrative):
{
"mcpServers": {
"docs": {
"command": "npx",
"args": ["-y", "@acme/[email protected]"]
}
}
}
Findings to record: package name, resolved version in lockfile (if any), maintainer org, and whether the team built the server in-house.
For dependency drift behind uvx, see Corelight's MCP uvx findings—pins are necessary but not sufficient when installers pull transitive wheels at launch time.
Step 3 — Offline MCP security scan
Run static analysis before you approve a server in the client UI.
beam scan /absolute/path/.mcp.json --mcp
Beam's scanning documentation states the command does not execute configured servers—it parses JSON, checks version-pin heuristics, and matches risky patterns in referenced text.
Treat output as review leads:
- A clean scan does not clear a server for production.
- A hit does not prove malice—legitimate tools sometimes trigger heuristics.
Pair scanning with the attack classes in MCP security: tool poisoning and rug pulls: poisoning, shadowing, rug pulls, and toxic multi-tool flows.
Model Context Protocol security fundamentals (quick)
If your team asks "is model context protocol secure?", the honest answer from the spec authors is "secure enough only with client and server controls you enforce." Fundamentals every audit should verify:
- Explicit user consent before tool invocation (host responsibility)
- No token passthrough to arbitrary downstream APIs
- Least-privilege OAuth scopes per server
- Tool schema integrity—descriptions and annotations are untrusted
- Network exposure minimized for local servers (prefer stdio when appropriate)
The MCP security tutorial repeats sandboxing guidance for server authors; your audit checks whether you actually run vendors' recommendations on the workstation.
Step 4 — Review tool manifests as injection surface
When a server ships a tool list (checked in or fetched at build time), review every description field—not only names.
The MCP tool specification requires clients to treat annotations from untrusted servers as untrusted hints. A readOnlyHint flip without description changes is a known rug-pull pattern; hash the full JSON schema including inputSchema, outputSchema, and annotations as OWASP recommends.
Document a tool_manifest_sha256 per server. Re-audit when the hash changes—even if the semver pin did not.
Step 5 — Map credentials and network egress
For each server, answer:
- Which environment variables or files does the launch command require?
- Does the server open a listening port (HTTP/SSE) on localhost?
- Can tools fetch arbitrary URLs (SSRF path into metadata services)?
Advisories such as Todoist MCP DNS rebinding show that localhost listeners are part of MCP security, not only cloud APIs.
Deny production admin tokens at the audit stage. Prefer scoped service accounts with rotation.
Common MCP security mistakes (and what auditors catch)
Teams fail audits in predictable ways. None require a novel exploit—only drift.
Mistake: "We only use official connectors." Official connectors still run with your credentials and can change behavior when the vendor updates OAuth scopes. Record connector version and note which human approved production use.
Mistake: "stdio is local, so it's safe." stdio avoids an extra TCP listener, but the child process can still read ~/.aws, hit the public internet, and write anywhere your UID allows. The MCP specification's local-server section is explicit that host compromise equals user compromise without extra isolation.
Mistake: "We scanned clean last quarter." Rug pulls change tool metadata without bumping package version if the server is remote or the manifest is fetched at session start. Hash manifests per session week, not per fiscal quarter.
Mistake: "Developers self-serve MCP." Self-service without registry approval reintroduces npm typosquats—same class as malicious MCP packages documented on npm. Central IT does not need to block experimentation, but production repos need an allowlist.
Mistake: "The model will refuse harmful tools." Models follow tool descriptions that say "call this first" or "include env secrets in parameter X." OWASP's DevSecOps guidance assumes prompt injection can succeed—plan permissions, isolation, and egress control outside the model.
Worked example: auditing a two-server .mcp.json
Consider a repo with documentation search and issue tracker MCP entries:
{
"mcpServers": {
"docs": {
"command": "npx",
"args": ["-y", "@vendor/[email protected]"]
},
"issues": {
"command": "uvx",
"args": ["issues-mcp"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
}
}
}
| Finding | Severity | Remediation |
|---|---|---|
issues-mcp unpinned on uvx | High | Pin issues-mcp==0.9.4 with hash or vendor lockfile |
Broad GITHUB_TOKEN in repo config | High | Replace with fine-scoped PAT or org ruleset token; never commit literal secrets |
docs server unreviewed tool list | Medium | Export tools JSON from vendor release artifact; store hash in git |
No record of who approved docs | Process | Add CODEOWNERS on .mcp.json |
Run beam scan on the file, attach output to the ticket, and block merge until the pin row is green. This is the minimum bar before telling leadership MCP security is "handled."
Step 6 — Patch MCP SDKs on the same cadence as servers
Your agent bundles MCP client libraries. Track advisories for:
An MCP security audit that ignores SDK semver is incomplete—the client parses untrusted JSON and may forward OAuth material.
MCP security audit checklist
Copy this table into your ticket system:
| # | Check | Pass criteria |
|---|---|---|
| 1 | Scope inventory | Every config path documented |
| 2 | Version pins | No @latest in production profiles |
| 3 | Offline scan | beam scan --mcp run; findings triaged |
| 4 | Tool hash | Schema hashed; changes trigger re-review |
| 5 | Credentials | No personal admin tokens in env |
| 6 | Network | Listener ports noted; rebinding risk assessed |
| 7 | SDK patch | Client libraries at or above advisory floors |
| 8 | Runtime plan | OAuth, authZ, and destructive tools require human approval |
What this means if you run AI coding agents
Schedule the full audit before you let an agent touch customer code with MCP enabled. For day-to-day work:
- Add MCP JSON paths to the same CODEOWNERS rules as
CLAUDE.md - Block surprise
npxservers in org-managed agent policy where your toolchain supports it - After merge, re-run offline scans in CI if configs are committed
- Watch PreToolUse transcripts for tools you did not inventory—surprise calls mean scope drift
Align with the broader AI agent security audit checklist so MCP is not a silo. Store audit artifacts where reviewers can find them six months later—ticket IDs, scan output, and pin hashes—not chat transcripts alone.
What Beam can and cannot do here
Beam supports MCP security on-device:
- Offline
beam scan --mcpwith heuristics and version-pin checks - Local event history to spot tool calls after approval fatigue
- PreToolUse enforce (Claude Code and Codex) when workspace policy is cached and valid
Beam cannot:
- Prove a remote server's OAuth implementation
- Stop DNS rebinding against a vulnerable local HTTP MCP by itself
- Replace org-wide server allowlists or container sandboxes
State limits plainly: scanning is pattern-based, not semantic malware analysis.
Frequently asked questions
What is MCP security?
It is supply-chain and runtime control for protocol servers that extend coding agents—pins, reviews, consent, and isolation—not a single product checkbox.
What is an MCP security gateway?
Some teams place MCP behind a gateway that authenticates and policy-checks tool calls. Beam is local observability and scan tooling, not a cloud gateway; compare requirements before you conflate them.
Is MCP security certification available?
Industry bodies publish cheat sheets and testing guides (OWASP, MCP spec). There is no universal "MCP certified" label that replaces your audit.
Can I automate MCP security testing?
Yes for static configs and known CVE packages. Runtime authorization tests still need staged environments—see OWASP's MCP Security Testing Guide.
What is mcp security vs application security?
Application security covers your product code. MCP security covers third-party executables and APIs the agent invokes—a distinct entry on the same machine.
Related reading
- MCP server security review
- MCP security practical guide
- Cursor MCP config poisoning
- What is AI agent monitoring?
- MCP security solutions
- NIST-style agent practices
MCP specification links, CLI paths, and heuristic counts reflect published Beam and MCP docs as of the publication date. Re-verify before enforcing org policy.

