MCP Tools Reference

The Rulebound MCP server provides five tools for rule enforcement. Each tool accepts structured parameters and returns JSON results.

find_rules

Find relevant project rules for a given task. Should be called before starting any implementation.

Parameters:

ParameterTypeRequiredDescription
taskstringYesDescription of the task
categorystringNoFilter by category: architecture, security, style, testing, infra, workflow
tagsstringNoComma-separated tags to filter by
stackstringNoTech stack override (auto-detected if omitted)

Response:

[
  {
    "id": "security.no-eval",
    "title": "No eval() Usage",
    "category": "security",
    "severity": "error",
    "modality": "must",
    "tags": ["security", "injection"]
  }
]

Relevance Scoring:

Rules are ranked by relevance to the task using a scoring system:

  • Tag match: +3 points
  • Title keyword match: +2 points
  • Category match: +2 points
  • Phrase match in title: +5 points

If no rules score above 0, global rules (those with no stack filter) are returned.

validate_plan

Validate an implementation plan against project rules. Must be called before writing any code.

Parameters:

ParameterTypeRequiredDescription
planstringYesThe implementation plan text
taskstringNoTask context for better rule matching

Response:

{
  "status": "PASSED_WITH_WARNINGS",
  "summary": "Plan addresses most rules",
  "violations": [
    {
      "rule": "Use Constructor Injection",
      "severity": "error",
      "reason": "Field injection detected",
      "fix": "Use constructor injection with final fields"
    }
  ]
}

Status values: PASSED, PASSED_WITH_WARNINGS, FAILED

A plan is FAILED if any must modality rule is violated.

check_code

Check a code snippet against project rules. Call after writing code to verify compliance.

Parameters:

ParameterTypeRequiredDescription
codestringYesThe code snippet to check
languagestringNoProgramming language (auto-detected if omitted)
file_pathstringNoFile path for context-based matching

Response:

{
  "compliant": false,
  "violations": [
    {
      "rule": "No eval()",
      "severity": "error",
      "detail": "eval() is a security risk",
      "fix": "Use JSON.parse() or refactor logic"
    }
  ]
}

list_rules

List all available rules for the project's tech stack.

Parameters:

ParameterTypeRequiredDescription
categorystringNoFilter by category

Response:

[
  {
    "id": "style.no-console-log",
    "title": "No console.log",
    "category": "style",
    "severity": "warning",
    "modality": "should"
  }
]

validate_before_write

The most important tool for pre-write enforcement. AI agents should call this before writing any code file.

Parameters:

ParameterTypeRequiredDescription
codestringYesCode to validate before writing
file_pathstringYesTarget file path
languagestringNoLanguage override (auto-detected from extension)

Response:

{
  "approved": true,
  "file_path": "src/auth/login.ts",
  "language": "typescript",
  "violations": [],
  "message": "Code is clean -- safe to write"
}

When violations are found:

{
  "approved": false,
  "file_path": "src/auth/login.ts",
  "language": "typescript",
  "violations": [
    {
      "rule": "ts-no-eval",
      "line": 5,
      "message": "eval() is a security risk and should never be used",
      "severity": "error",
      "source": "ast"
    },
    {
      "rule": "security.no-hardcoded-secrets",
      "message": "Inline secret value",
      "severity": "error",
      "fix": "Load from environment variables",
      "source": "semantic"
    }
  ],
  "message": "2 violation(s) found -- review before writing"
}

Violations include a source field indicating whether they came from AST analysis or semantic validation.

Language Auto-Detection

When no language parameter is provided, the server detects language from:

  1. File extension (.ts -> TypeScript, .py -> Python, etc.)
  2. Code heuristics (e.g., public class -> Java, func + package -> Go)
  3. Project stack (fallback to primary stack technology)