Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.trykode.xyz/llms.txt

Use this file to discover all available pages before exploring further.

Kode implements the Model Context Protocol (MCP) as an MCP server. When you run kode mcp serve, Claude Desktop and any other MCP-compatible client can invoke Kode’s Context Engine and Verification-on-Write pipeline as first-class tools — meaning Claude can build a surgical context graph of your codebase and apply verified code changes on your behalf, with the same verification gates Kode enforces in kode run and kode loop.

What Kode exposes over MCP

The server registers two tools that clients can call:
ToolDescription
kode_planUses Kode’s Tree-sitter Context Engine to build a context graph (up to 8 000 tokens) for a given task description. Returns a structured context packet with files, AST nodes, import edges, and confidence scores.
kode_apply_verifiedRuns the full Generate → Verify → Apply pipeline for a task description. Hunks are verified through the same gate that kode run uses before anything is written to disk. Returns a success message with the count of applied hunks, or the last error message if the pipeline failed.
Both tools accept a single task string as their input.

Starting the MCP server

kode mcp serve
To point the server at a specific project directory:
kode mcp serve --project-dir /path/to/project
The server runs over stdio — it reads JSON-RPC requests from stdin and writes responses to stdout. All Kode diagnostic output goes to stderr so it does not interfere with the MCP wire protocol.
The MCP server must have access to your project directory on disk. The --project-dir flag defaults to the current working directory, so run kode mcp serve from inside your project or pass the path explicitly. Claude Desktop’s working directory may differ from your shell’s, so using --project-dir with an absolute path is recommended.

Configuring Claude Desktop

Add the following entry to your Claude Desktop configuration file. On macOS the file is at ~/Library/Application Support/Claude/claude_desktop_config.json:
{
  "mcpServers": {
    "kode": {
      "command": "kode",
      "args": ["mcp", "serve", "--project-dir", "/absolute/path/to/your/project"],
      "env": {
        "KODE_LLM_API_KEY": "your-api-key"
      }
    }
  }
}
After saving the file, restart Claude Desktop. You should see kode appear in the tool list. Claude can now call kode_plan to understand your codebase and kode_apply_verified to make changes — both subject to Kode’s verification gate.
You can configure multiple Kode servers for different projects by adding additional entries under mcpServers with different keys (e.g. "kode-api", "kode-frontend") and different --project-dir values.

How the tools behave inside Claude

When Claude calls kode_plan, it receives a JSON context packet describing the files, symbols, and relationships in your codebase that are relevant to the task. Claude can use this context to understand the blast radius of a change before asking kode_apply_verified to make it. When Claude calls kode_apply_verified, Kode runs the full pipeline internally:
  1. Sends the task description to your configured LLM (same model as kode run)
  2. Parses the structured JSON hunks from the response
  3. Passes every hunk through the verification gate (syntax, imports, calls, architecture)
  4. Writes only the verified hunks to disk in your project directory
  5. Returns a success message with the count of applied hunks, or the last error message if the pipeline failed
The write is atomic — if any hunk fails verification, nothing is written for that hunk. Verified hunks from the same run are written regardless of whether other hunks in the same run failed.
Use the MCP integration when you prefer Claude Desktop’s conversational interface for exploring and scoping a change, but want Kode’s verification guarantees to catch hallucinated imports, bad call signatures, and architecture violations before anything touches your codebase. The two tools work well in combination: ask Claude to call kode_plan first to inspect the context, refine the task description in conversation, then call kode_apply_verified once you are satisfied.

Next steps

First Task

Learn the core kode run workflow that underpins both the CLI and the MCP kode_apply_verified tool.

Daemon Mode

Run Kode in the background to catch tech debt automatically without any manual invocation.