MCP Server Overview

The Rulebound MCP (Model Context Protocol) server exposes rule enforcement as tools that AI coding agents can call directly. This enables pre-write enforcement — validating code against project rules before it is written to disk.

What is MCP?

The Model Context Protocol is an open standard for connecting AI agents to external tools and data sources. Rulebound's MCP server provides five tools that AI agents call during their workflow.

Architecture

AI Coding Agent (Claude, Copilot, etc.)
    |
    |  MCP Protocol (stdio)
    |
Rulebound MCP Server
    |
    +-- Rule Loader
    |       Reads .rulebound/rules/*.md
    |
    +-- Validator
    |       Semantic pattern matching
    |
    +-- AST Analyzer
            tree-sitter structural analysis

Available Tools

ToolPurposeWhen to Call
find_rulesFind relevant rules for a taskBefore starting implementation
validate_planValidate an implementation planBefore writing any code
check_codeCheck a code snippetAfter writing code
list_rulesList all project rulesWhen exploring project standards
validate_before_writePre-write code validationBefore writing any code file

Quick Start

# Install
pnpm add @rulebound/mcp

# Run the MCP server
npx rulebound-mcp

Agent Configuration

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "rulebound": {
      "command": "npx",
      "args": ["rulebound-mcp"],
      "cwd": "/path/to/your/project"
    }
  }
}

Claude Code

Add to .claude/settings.json:

{
  "mcpServers": {
    "rulebound": {
      "command": "npx",
      "args": ["rulebound-mcp"]
    }
  }
}

Auto-Detection

The MCP server automatically:

  • Detects project stack from project files (package.json -> TypeScript, pom.xml -> Java, etc.)
  • Finds rules directory by scanning .rulebound/rules/, rules/, and examples/rules/
  • Filters rules by stack so agents only see relevant rules

Next Steps