DEV Community

R VIKRAM
R VIKRAM

Posted on

Scan an MCP server before you connect it

Every MCP server you connect hands your agent a loaded toolbelt — shell, file writes, network fetches, raw SQL. Most teams audit that toolbelt after something goes wrong.

I built the MCP Server Security Scanner so the audit happens first.

The risks

  • A shell_exec tool with wildcard scope is arbitrary code execution with a friendly name.
  • A fetch-any-URL tool is exfiltration plus SSRF.
  • A secret sitting in the server env is a credential leak waiting for a log file.
  • A tool description that says "ignore previous instructions" is prompt injection baked into the server itself.

How it works

You give it the MCP server config + tool list as JSON. A stdlib-only Python pipeline applies 9 deterministic rules (R1–R9): unauthenticated transport, secret-shaped env values, arbitrary command execution, raw SQL, unrestricted fetch, broad write scope, instruction-like tool descriptions, and missing schemas. A second script validates the report, and you get a severity-ranked report with a concrete fix per finding and a BLOCK / REVIEW / PASS verdict.

It is static and script-first: it never executes, imports, or evaluates anything from the scanned input, never touches the network, and redacts suspected secrets instead of printing them.

The proof

Dry run on a fictional 7-tool sample server:

  • Verdict: BLOCK
  • 12 findings: 3 Critical, 5 High, 1 Medium, 3 Low
  • Output validator: 12 findings, severity order OK, counts match, 0 errors

The 3 Criticals: a secret-shaped value in the env, an arbitrary shell tool, and a raw-SQL tool.

The nine rules, in brief: R1 unauthenticated network transport, R2 secret-shaped env values, R3 arbitrary command execution, R4 raw SQL, R5 unrestricted network fetch, R6 broad write scope, R7 instruction-like tool descriptions, R8 missing schema or description, and R9 confined read-only tools. Each rule is deterministic — same input, same report, every run — and the validator re-checks severity ordering and count consistency so a report can't silently disagree with itself.

Limits, honestly

It analyses the declared config and tool list only — it cannot see risks inside tool implementations that aren't described in the config, and it doesn't observe runtime behaviour. Severity ranks are opinionated heuristics, not a CVE lookup. PASS means no rule fired, not "provably secure".

Try it

Scan before you connect. What does your MCP audit look like today — if it exists at all?

Top comments (0)