Skip to main content

MCP Integration

Rafter runs as a standard MCP server over stdio, exposing security tools to any MCP-compatible client—Cursor, Windsurf, Claude Desktop, Cline, and others. The local security tools need no API key and run entirely on your machine. A separate set of Sites tools calls Rafter’s remote API and does need one.

Setup

1. Install Rafter CLI

2. Add to Your MCP Client

Add Rafter to your MCP client’s server configuration:

3. Restart Your Client

Restart the MCP client to load Rafter’s tools. You should see eleven tools and three resources available: the seven local tools described below, plus the four remote Sites tools (the Sites tools work without further setup if RAFTER_API_KEY is set, but only calls to them require a key — the local tools never do).

Tools

Rafter exposes seven local security tools over MCP. Six are read-only; suppress_finding writes to the project’s .rafter.yml.

scan_secrets

Scan a file or directory for hardcoded secrets and credentials. Returns an array of scan results with file paths, pattern names, severity levels, and redacted matches. Findings hidden by the project’s .rafter.yml ignore rules or .rafterignore are dropped from the result; when any were, a second content block reports {suppressed_count, _suppressed: [...]} (metadata only, no secret text) so a blanket ignore rule can’t silently empty a scan.
Scanning a file containing a test key (AKIAABCDEFGHIJKLMNOP):
engines lists which engine(s) reported the match — only present when engine is auto and both engines ran. Redacted values are capped at 16 masked characters.

evaluate_command

Evaluate whether a shell command is allowed by Rafter security policy. Returns whether the command is allowed, its risk level, and whether it requires approval.

read_audit_log

Read Rafter audit log entries with optional filtering.

get_config

Read Rafter configuration (full config or a specific key). Stored credentials (e.g. backend.apiKey) are never returned in full — the key’s value comes back masked.

list_docs

List repo-specific security docs declared under docs: in .rafter.yml (the CLI equivalent is rafter docs list). Use early in a security-relevant task to discover project-specific rules, threat models, or compliance policies.

get_doc

Return the content of a repo-specific security doc by id or tag, after list_docs.

suppress_finding

Persist a suppression rule into the project’s .rafter.yml after triaging a scan_secrets (or remote scan) finding as a false positive — e.g. a test fixture. This is the one local tool that writes: subsequent scan_secrets calls and rafter secrets stop reporting the suppressed finding, and rafter secrets --json lists it under _suppressed so the decision stays reviewable and version-controlled.
Give an agent suppress_finding only if you’re comfortable with it editing .rafter.yml on your behalf. Review the diff like any other agent-authored change.

Resources

Three read-only resources expose Rafter’s current state.

How It Works

The MCP server wraps Rafter’s existing CLI classes:
  • scan_secrets with engine: auto (the default) runs Betterleaks and the built-in patterns engine (28 patterns) and unions the results, falling back to patterns-only if Betterleaks is unavailable or errors
  • evaluate_command uses CommandInterceptor with policy-driven risk assessment
  • read_audit_log reads from ~/.rafter/audit.jsonl
  • get_config reads from ~/.rafter/config.json merged with .rafter.yml
  • suppress_finding writes an ignore rule into the project’s .rafter.yml
Every tool except suppress_finding is read-only. Most configuration changes go through the CLI (rafter agent config set); suppressing a specific finding is the one policy edit available directly over MCP.

Configuration

The MCP server uses the same configuration as all other Rafter commands. Set up your security policy once and it applies everywhere:
Examples use the Node CLI’s camelCase keys; the Python CLI uses snake_case. See the key casing note.
Or use a .rafter.yml policy file in your project root. See Policy File for details.

Verify Installation

After adding Rafter to your MCP client, test that tools are working:
  1. Ask the agent to scan a directory for secrets
  2. Ask it to evaluate whether rm -rf / is safe
  3. Ask it to show your Rafter configuration
If the agent can call these tools, Rafter is connected.

Sites Tools (Remote, API-Key-Gated)

The seven tools above are local-only and require no API key (suppress_finding is the one that writes, and it only ever touches your own .rafter.yml). Rafter also exposes a separate set of Sites tools that are the opposite on the other axes: they call Rafter’s remote API, require an API key, and two of them mutate remote state (create a site, trigger a scan).
Sites tools are a distinct surface for live-application security monitoring, not local secret scanning or command policy.

Authentication

The Sites tools resolve your API key the same way the CLI does: the RAFTER_API_KEY environment variable, or your stored Rafter config, checked in that order.

sites_create

Register a new site and trigger its first scan. Requires an API key with the read-and-scan scope.

sites_scan

Trigger a re-scan of a site you already own. Requires an API key with the read-and-scan scope.

sites_list

List your sites, paginated. Requires an API key with the read scope.

sites_get

Get a site’s status, latest run, and findings summary. Requires an API key with the read scope. See the Sites API reference for full request/response shapes, and the Sites CLI guide for the equivalent rafter sites commands.

Compared to Pretool Hooks

On a platform that supports both, use them together: pretool hooks for enforcement + MCP tools for agent-initiated scans and suppressions. On a platform with no hook support (Windsurf, Continue.dev, and others), the MCP server is the primary integration path.

What’s Next?

Secret Scanning

28 secret patterns detected

Policy File

Define per-project security policies

Command Reference

Full CLI reference