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. No API key required. All tools run locally.

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 eight tools and two resources available: the four local, read-only 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 four read-only security tools over MCP.

scan_secrets

Scan files or directories for hardcoded secrets and credentials. Returns an array of scan results with file paths, pattern names, severity levels, and redacted matches.

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).

Resources

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

How It Works

The MCP server wraps Rafter’s existing CLI classes:
  • scan_secrets uses RegexScanner (built-in 21+ patterns) with automatic fallback from Betterleaks (v0.8.0+; gitleaks successor)
  • 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
All tools are read-only. Configuration changes go through the CLI (rafter agent config set).

Configuration

The MCP server uses the same configuration as all other Rafter commands. Set up your security policy once and it applies everywhere:
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 four tools above are local-only, read-only, and require no API key. Rafter also exposes a separate set of Sites tools that are the opposite on every axis: they call Rafter’s remote API, require an API key, and two of them mutate state (create a site, trigger a scan).
Sites tools are not part of the “four tools” described above — they 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

For maximum security on Claude Code, use both: pretool hooks for enforcement + MCP tools for agent-initiated scans. For other platforms, the MCP server is the primary integration path.

What’s Next?

Secret Scanning

21+ secret patterns detected

Policy File

Define per-project security policies

Command Reference

Full CLI reference