MCP (Model Context Protocol)
Audience: Customer — this page documents the Rulecatch MCP server for Claude Code.
Rulecatch provides an MCP Server and MCP API that allow AI assistants to query violation data, rules, and fix plans directly within their context window.
Architecture
The MCP integration consists of two components:
| Component | Purpose | Runs On |
|---|---|---|
@rulecatch/mcp-server |
MCP Server (stdio transport, Pro/Enterprise only) | Developer's machine |
| MCP API | Read-only Express API | Rulecatch infrastructure |
Flow
Claude Code ──MCP Protocol──▶ MCP Server ──HTTP──▶ MCP API ──▶ MongoDB (stdio) (local) (remote)
- Claude Code connects to the MCP Server via stdio
- User invokes a tool (e.g.,
rulecatch_violations) - MCP Server validates input and calls the MCP API
- MCP API authenticates the request and queries MongoDB
- Results flow back to Claude Code's context
Installation
The MCP Server is automatically installed when you run the AI-Pooler init in full mode (with an API key):
npx @rulecatch/ai-pooler init --api-key=dc_your_key_here
This registers both the hooks and the MCP Server in your Claude Code settings. The MCP Server uses the same config as the AI-Pooler (~/.claude/rulecatch/config.json).
The init command adds the following to ~/.claude/settings.json:
{
"mcpServers": {
"rulecatch": {
"command": "node",
"args": ["~/.claude/rulecatch/mcp-server.js"]
}
}
}
Note: The MCP Server is only available in full mode (with an API key). It is not installed in monitor-only mode.
MCP Server
The MCP Server (@rulecatch/mcp-server) runs locally on the developer's machine using stdio transport. It:
- Creates an
McpServerinstance - Reads API key from local config
- Initializes an
ApiClientfor HTTP communication - Registers 6 tools via
registerTools() - Logs to stderr only (stdout is reserved for JSON-RPC)
Configuration
The MCP Server reads from ~/.claude/rulecatch/config.json:
apiKey— For authenticating with the MCP APIregion— Determines which MCP API endpoint to use (us→mcp.rulecatch.ai,eu→mcp-eu.rulecatch.ai)
MCP API
A separate Express service (mcp.rulecatch.ai) providing read-only access to Rulecatch data.
| Property | Value |
|---|---|
| Default port | 3003 |
| CORS | Enabled |
| Auth | API key required (middleware) |
| Region-aware | Yes (RULECATCH_REGION env var) |
| Headers | X-Rulecatch-Service: mcp-api, X-Rulecatch-Region: {region} |
Tools
rulecatch_summary
Get a high-level overview of violations and development activity.
Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
period |
string | No | Time period: 24h, 7d, 30d (default: 7d) |
Output:
- Total violations (by severity)
- Correction rate
- Activity metrics (sessions, tokens, cost)
API Endpoint: GET /api/v1/mcp/summary
rulecatch_violations
List violations with optional filters.
Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
severity |
string | No | Filter by: error, warning, info |
corrected |
boolean | No | Filter by fix status |
rule |
string | No | Filter by rule name |
file |
string | No | Filter by file path/hash |
limit |
number | No | Max results (default: 20) |
Output:
- List of violations with rule name, severity, file, line, corrected status, timestamp
API Endpoint: GET /api/v1/mcp/violations
rulecatch_violation_detail
Get full details for a specific violation.
Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | Violation ID |
Output:
- Full violation record including matched conditions, event data, and rule details
API Endpoint: GET /api/v1/mcp/violations/{id}
rulecatch_rules
List all active rules for the user.
Input:
No parameters required.
Output:
- List of active rules with name, category, severity, conditions, and enabled status
API Endpoint: GET /api/v1/mcp/rules
rulecatch_fix_plan
Generate a fix plan showing uncorrected violations grouped by file.
Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
string | No | Focus on a specific file |
Output:
- Files with violations grouped together
- Each file lists its uncorrected violations
- Violations include rule name, severity, line number, and matched conditions
API Endpoint: GET /api/v1/mcp/fix-plan
rulecatch_top_rules
Get the most frequently violated rules, ranked by count.
Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
period |
string | No | Time period (default: 7d) |
severity |
string | No | Filter by severity: error, warning, info |
category |
string | No | Filter by rule category |
limit |
string | No | Max rules to return (default: 10, max: 25) |
Output:
- Ranked list of most-violated rules with counts, correction rates, percentage of total, and category breakdown
API Endpoint: GET /api/v1/mcp/top-rules
Input Validation
All tool inputs use Zod schemas for validation. Invalid inputs return human-readable error messages.
Response Format
All tools return formatted text responses (not JSON). This is intentional — the output is designed to be readable by AI assistants in their context window:
Violations Summary (Last 7 Days)
Total: 15 violations
Errors: 3
Warnings: 8
Info: 4
Correction Rate: 73%
Activity:
Sessions: 12
Cost: $4.52
Tokens: 1.2M
Error Handling
- Authentication failures return "Invalid or missing API key"
- Network errors return descriptive messages
- All errors are formatted as text content, not thrown exceptions
MCP API Routes
| Method | Path | Description |
|---|---|---|
GET |
/api/v1/mcp/summary |
Violations + activity overview |
GET |
/api/v1/mcp/violations |
List violations with filters |
GET |
/api/v1/mcp/violations/:id |
Full violation detail |
GET |
/api/v1/mcp/rules |
List active rules |
GET |
/api/v1/mcp/fix-plan |
Uncorrected violations by file |
GET |
/api/v1/mcp/top-rules |
Most violated rules ranked by count |
Deployment
| Region | Domain |
|---|---|
| US | mcp.rulecatch.ai |
| EU | mcp-eu.rulecatch.ai |
The MCP API runs in its own container, separate from the ingest API and dashboard.
Type Definitions
Key types used by the MCP Server:
| Type | Description |
|---|---|
SummaryResponse |
Violations + activity overview |
ViolationListItem |
Single violation in a list |
ViolationsResponse |
Paginated violation list |
ViolationDetailResponse |
Full violation with matched conditions |
RuleItem |
Single rule |
RulesResponse |
List of active rules |
FixPlanFile |
File with grouped violations |
FixPlanResponse |
Complete fix plan |
See Also
- API Overview — Ingest API (separate service)
- Authentication — API key authentication
- Rules and Templates — What rules are available
- Region Isolation — US/EU deployment