> ## 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 mcp serve — MCP Server for External Agents

> kode mcp serve starts a stdio MCP server so external agents like Claude Desktop can call Kode's Context Engine and verification pipeline as tools.

`kode mcp serve` starts Kode as a [Model Context Protocol](https://modelcontextprotocol.io) server over stdio. External agents — such as Claude Desktop — connect to it and can invoke Kode's Context Engine and Verification-on-Write pipeline as structured tool calls. This lets any MCP-capable agent use Kode's verification gates and code generation without leaving its own interface.

## Synopsis

```bash theme={null}
kode mcp serve
kode mcp serve --project-dir /path/to/project
```

## Flags

| Flag            | Type   | Default                   | Description                                    |
| --------------- | ------ | ------------------------- | ---------------------------------------------- |
| `--project-dir` | string | current working directory | Project root that Kode's tools operate against |

## How it works

`kode mcp serve` uses stdin/stdout for the MCP wire protocol (JSON-RPC over stdio). All Kode diagnostic output and logging is redirected to stderr so it does not interfere with the protocol stream. The server exposes Kode's Context Engine and pipeline as typed tools that the connecting agent can call by name.

<Note>
  Because `kode mcp serve` communicates over stdio, you do not invoke it directly in a terminal during normal use. Instead, you register it in your MCP client's configuration file so the client spawns the process automatically. See the [Claude Desktop integration guide](/guides/mcp-integration) for the exact configuration snippet.
</Note>

## Claude Desktop integration

To use `kode mcp serve` with Claude Desktop, add an entry to Claude's MCP configuration file (typically `~/.config/claude/mcp.json` or the platform equivalent):

```json theme={null}
{
  "mcpServers": {
    "kode": {
      "command": "kode",
      "args": ["mcp", "serve", "--project-dir", "/path/to/your/project"]
    }
  }
}
```

Claude Desktop will spawn `kode mcp serve` automatically when it starts and route tool calls to Kode's Context Engine.

<Tip>
  Set `--project-dir` to the absolute path of the repository you are working in. If you switch projects frequently, create one MCP config entry per project with a descriptive name like `"kode-backend"` or `"kode-frontend"`.
</Tip>

## Related

* [Claude Desktop MCP integration guide](/guides/mcp-integration) — full setup walkthrough
* [`kode loop`](/cli/loop) — the pipeline exposed as an MCP tool via `kode mcp serve`
