Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Protecting MCP Servers with dmint-mcp

The Model Context Protocol (MCP) lets agents discover and invoke tools over a standard interface. A raw MCP server generally executes whatever the agent asks. dmint-mcp inserts a deterministic authorization gate between the agent and every downstream tool call:
┌─────────────────┐ │ AI Client/Agent │ (Cursor, Claude Code, Antigravity, custom MCP client) └────────┬────────┘ │ JSON-RPC tools/list, tools/call ▼ ┌─────────────────────────────────┐ │ dmint-mcp Gateway │ │ │ │ ├─ tools/list aggregation │ │ ├─ tool schema hash pinning │ │ ├─ SSRF / DNS-rebinding guard │ │ ├─ deterministic policy gate │ │ └─ approval verification │ └────────┬────────────────────────┘ │ authorized calls only ▼ ┌─────────────────────────────────┐ │ Downstream MCP server(s) │ └─────────────────────────────────┘

Supported Transports

  1. stdio — local subprocesses, for example npx @modelcontextprotocol/server-postgres or uvx mcp-server-git.
  2. streamable-http (streamable_http is also accepted) — remote MCP endpoints with TLS, SSRF filtering, optional Bearer auth, and connection-level IP pinning.
Loopback HTTP is accepted only for a local development server. Remote endpoints must use HTTPS.

Step 1: Discover Tools and Author the Policy

Use the interactive authoring command to inspect a downstream server and generate both policy and gateway configuration:
dmint create-mcp-policy \ --command npx \ --args "-y @modelcontextprotocol/server-postgres postgresql://localhost/mydb" \ --integration-id postgres \ --output policy.json \ --config-output mcp_protection.json
Review policy.json before deployment. Start with explicit allow rules for the tools you intend to expose, approval_required for sensitive mutations, and deny for operations that must never run. Precedence is always DENY > APPROVAL_REQUIRED > ALLOW.
A generated mcp_protection.json contains the policy path, approval database, and integration/tool bindings:
mcp_protection.json
{ "policy_file": "policy.json", "approval_db": "./approvals.sqlite3", "approval_ttl": 300, "disclosure_mode": "dog", "integrations": [ { "integration_id": "postgres", "transport": "stdio", "connection": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"] }, "tool_bindings": { "query": { "tool_name": "query", "capability": "postgres.query", "discovery": "exposed" } } } ] }
The policy and approval database are inside this config. There are no dmint-mcp --policy or dmint-mcp --db-path flags.

Disclosure Modes: DOG vs GOD vs CAT

When an AI agent calls a tool that is denied or requires human approval, how much information should be returned to the model?
In an adversarial setting (e.g. indirect prompt injection), disclosing internal policy rules, policy hashes, or stack fingerprints helps attackers probe and reverse-engineer your security boundary. Dmint provides three distinct disclosure modes configured via "disclosure_mode" in mcp_protection.json:
ModeNameVerbosityInternal FingerprintsRecommended For
dog (Default)TransparentHighIncluded (request_fingerprint, approval_id)Local development, trusted agent loops, debugging
catBalancedMediumOmitted (workflow ID only)Semi-trusted agents, multi-agent pipelines
godZero-KnowledgeMinimalCompletely Redacted (DMT_403)Hardened production, untrusted agents, high-risk tools
┌────────────────────────────────────────────────────────────────────────┐ │ Disclosure Mode Responses Compared │ ├─────────┬──────────────────────────────────────────────────────────────┤ │ Mode │ Response Payload returned to AI Agent on APPROVAL_REQUIRED │ ├─────────┼──────────────────────────────────────────────────────────────┤ │ dog │ { │ │ │ "status": "approval_required", │ │ │ "code": "DMT_APPROVAL_REQUIRED", │ │ │ "request_id": "7b8e1a2f-...", │ │ │ "approval_id": "c4d3e2f1-...", │ │ │ "request_fingerprint": "a3f5... (sha256 hex)", │ │ │ "message": "Trusted approval is required for this request."│ │ │ } │ ├─────────┼──────────────────────────────────────────────────────────────┤ │ cat │ Dmint enforcement [DMT_APPROVAL_REQUIRED]: approval requested│ │ │ (workflow 7b8e1a2f-...) │ ├─────────┼──────────────────────────────────────────────────────────────┤ │ god │ Dmint enforcement [DMT_403]: access denied │ └─────────┴──────────────────────────────────────────────────────────────┘

1. DOG Mode ("disclosure_mode": "dog")

Returns a structured JSON document. The AI agent can inspect the exact approval_id and request_id, pause execution, and present the reviewer with actionable metadata.

2. CAT Mode ("disclosure_mode": "cat")

Returns a concise status message with the workflow reference (request_id), but omits the cryptographic SHA-256 request_fingerprint. This prevents the agent from attempting to tamper with or correlate internal hashes.

3. GOD Mode ("disclosure_mode": "god")

Implements total information blackout. Whether an action requires approval, matches an explicit deny rule, or fails closed, the gateway returns:
Dmint enforcement [DMT_403]: access denied
The adversarial agent receives zero telemetry about whether the tool exists, whether it is an approval pause or hard deny, or what condition caused the failure.

Step 2: Understand the Protections

Tool schema hash pinning

Dmint pins the SHA-256 digest of each discovered tool schema. If the downstream schema changes, the gateway fails closed with DMT_MCP_SCHEMA_MISMATCH until an operator deliberately re-pins it.

SSRF and DNS rebinding defense

For remote streamable-http integrations the gateway:
  • rejects non-HTTP(S) schemes, userinfo, .internal/.local hosts, trailing-dot hostnames, and empty labels;
  • resolves non-loopback hostnames and rejects any DNS answer in loopback, RFC 1918 private, link-local, reserved, multicast, or cloud-metadata ranges;
  • canonicalizes IDN/Unicode hostnames to IDNA (punycode) before comparison;
  • connects to the validated IP for the lifetime of the transport while preserving the original Host header and TLS SNI;
  • refuses to fall back to an unpinned transport if the pinned backend cannot be installed.
An internal company MCP server must be reachable through an approved public/private integration path; an example host such as api.internal.company.com is rejected by the guard.

Duplicate JSON keys

The parser rejects duplicate object keys with DMT_MCP_PROTOCOL_ERROR, preventing parser-differential attacks such as {"id": 1, "id": 2}.

Approval retry (Automatic Store-Backed or Explicit Credential)

On APPROVAL_REQUIRED, the gateway persists a pending record (apr_...) and returns the approval ID. Once a human approves the request via dmint approve <approval_id> or the web dashboard, there are two ways to retry:
  1. Automatic Store-Backed Retry (Recommended for Cursor, Claude Code & Coding Agents): Simply ask the agent to retry the exact same tool call with the exact same arguments. The gateway automatically looks up the unexpired APPROVED assertion matching the request's RFC 8785 fingerprint in the approval store, verifies the Ed25519 signature, atomically transitions the record from APPROVED to CONSUMED, and forwards the clean call downstream. The LLM never needs to see or copy-paste the cryptographic token.
  2. Explicit In-Band Credential (For Stateless or Remote Orchestrators): Pass the signed assertion JSON string or object under one of the reserved argument keys (_dmint_approval, dmint_approval, or approval_credential). The gateway strips the reserved key before forwarding arguments downstream and consumes the assertion once.

Step 3: Launch the Gateway

Stdio mode for a desktop client:
dmint-mcp -c mcp_protection.json
Streamable-HTTP mode:
dmint-mcp \ -c mcp_protection.json \ --transport http \ --host 127.0.0.1 \ --port 8000 \ --auth-token "replace-with-a-long-random-token"
A non-loopback HTTP bind is refused unless an auth token is configured. Keep the bind on loopback behind a reverse proxy when possible.
Optional policy pinning:
dmint policy-digest policy.json dmint-mcp -c mcp_protection.json --expected-policy-digest <sha256-hex>

Step 4: Configure the Agent

Point the agent at dmint-mcp, not at the downstream server. Example Cursor/Claude Code configuration:
mcp.json
{ "mcpServers": { "protected-postgres": { "command": "dmint-mcp", "args": [ "-c", "/absolute/path/to/mcp_protection.json" ] } } }
For HTTP transport, use the gateway URL and the configured Bearer token in the client’s MCP server settings.
Every tools/list and tools/call now passes through Dmint’s deterministic policy evaluator. A DENY or unresolved APPROVAL_REQUIRED never reaches the downstream server.

Notification Dispatch

The MCP gateway dispatches Slack/Discord/Teams notifications when the configured webhook environment variables are present. Dispatch runs in a bounded worker thread, one notification at a time, so a slow webhook does not block the asyncio event loop. Webhook failures are logged and never change the authorization decision. Core (Dmint) itself does not dispatch webhooks.

Next Steps