Vai al contenuto principale
S

dsh-plugin-mcp-guard

sshooting/dsh-plugin-mcp-guard

DSH plugin: read-only /mcp-guard audit of configured MCP servers for risky settings. No connections, no command execution, no file writes.

Installazione

dsh plugin --profile web add github:sshooting/dsh-plugin-mcp-guard

README

dsh-plugin-mcp-guard

One command audits every configured MCP server and flags risky settings — without ever connecting to a server or running a command.

MCP configs accumulate quickly: a plain http:// endpoint here, a permissions: ["*"] there, a bash -c wrapper "just for testing". mcp-guard inspects the config object your DSH profile already holds and turns those into a compact, scored report. It is strictly read-only: no sockets, no process spawning, no file writes, no credential values printed.

Install

dsh plugin --profile web add dsh-plugin-mcp-guard

Requires Node ^22.19.0 || >=24 and DSH >=0.2.0-rc.2 <0.3.0.

30-second demo

  1. Add your MCP servers to the bundle row in your profile (see Configuration).
  2. In any DSH session, type /mcp-guard.
  3. You get a scorecard:
[mcp-guard] 2/3 audited server(s) flagged · 4 finding(s) · 1 skipped · score 0/100 · RISK
  local-dev  [http://localhost:3000]
    HIGH   insecure-url            URL uses plain http:// instead of https://
    HIGH   wildcard-auto-approve   autoApprove entry contains a wildcard: *
  shell-tool  [stdio: bash]
    HIGH   shell-invocation        command invokes a shell with -c (arbitrary command execution)
  clean-one  [https://example.com]  OK
  legacy  DISABLED (skipped)
Fix: review the flags above; prefer HTTPS, avoid wildcard permissions/autoApprove, and drop shell -c wrappers.

Use /mcp-guard --json for machine-readable output (CI, scripts, dashboards). The JSON contains only known fields and is redacted the same way as text output.

Configuration

The bundle patch seeds an empty map. Fill it in your profile's cordis.patch.yml (or merge it into an existing MCP config):

- id: dsh-plugin-mcp-guard
  name: dsh-plugin-mcp-guard
  config:
    mcpServers:
      local-dev:
        url: http://localhost:3000
        autoApprove: ['*']
      shell-tool:
        command: bash
        args: ['-c', 'echo hi']
      clean-one:
        url: https://example.com
        permissions: [read]
      legacy:
        command: node
        args: [server.js]
        disabled: true
KeyTypeDefaultMeaning
mcpServersobject{}Map of server name to its config object.
mcpServers.<name>.urlstring—HTTP(S) endpoint. A plain http:// URL is flagged.
mcpServers.<name>.commandstring—stdio executable. Absent together with url, the server is flagged as having no endpoint.
mcpServers.<name>.argsstring[][]Arguments. Used only for shell -c detection; never printed.
mcpServers.<name>.permissionsstring[][]Any * / all entry (case-insensitive) is flagged.
mcpServers.<name>.autoApproveboolean or string[]falsetrue, a * wildcard, or a broad name (all, admin, root, execute, …) is flagged.
mcpServers.<name>.disabledbooleanfalseServer is listed as skipped and never audited.

Unknown fields are ignored and never serialized. Malformed values are narrowed to empty defaults instead of throwing.

Rules, score, and verdict

CodeSeverityTrigger
insecure-urlhighurl starts with http:// (not https://).
missing-endpointlowNeither a usable url nor a command.
wildcard-auto-approvehighautoApprove: true or an entry containing *.
broad-auto-approvemediumautoApprove entry such as all, admin, root, execute.
wildcard-permissionhighpermissions contains * or all.
shell-invocationhighcmd/sh/bash (including .exe and full paths) with -c or /c in args.

Each finding subtracts points: high 25, medium 15, low 10, clamped to 0–100. The verdict is risk if any high-severity finding exists, review if any finding exists, otherwise clean. Each finding code appears at most once per server. Disabled servers are skipped and do not affect the score.

URLs are reduced to scheme://host with userinfo, path and query removed, and commands to their basename, before redaction. Args and credential values are never emitted.

Privacy & safety

  • Reads only the in-memory mcpServers object passed to apply(ctx, config). No host filesystem or process APIs are imported.
  • No network connections to any MCP server — nothing is dialed, pinged, or handshaked.
  • No command execution, no shell, no child process. command/args are treated as inert strings.
  • No file writes, no telemetry.
  • Only known fields are serialized, and every emitted string passes through a redaction filter (credentials, query secrets, CLI flag secrets, URL userinfo).

Compatibility

ComponentSupported
DSH>=0.2.0-rc.2 <0.3.0
Node^22.19.0 || >=24.0.0
Cordis>=4.0.0 <5
Surfaceheadless and web (command registry only)

Troubleshooting

SymptomCauseFix
/mcp-guard not foundBundle row not installedRe-run dsh plugin --profile web add dsh-plugin-mcp-guard, then restart DSH.
no MCP servers configuredmcpServers is empty or missing in the row configAdd the map to the profile cordis.patch.yml; the installed patch only seeds {}.
A server shows DISABLED (skipped)disabled: true (or the string "true") is setRemove it if you want the server audited.
Flags look outdatedProfile cordis.patch.yml overrides the bundle rowThe last write wins — edit the profile row, then restart.
--json looks emptyOutput is pretty-printed JSON of the same reportPipe to a JSON parser; the top-level keys are servers, total, audited, skipped, flagged, findings, score, verdict.

Development

npm install
npm test
npm pack --dry-run

Tests are fully offline: synthetic config fixtures, no model, no network, no child processes.

License

MIT

Demo

Demo

Listed in

Plugin correlati