# MCP Server

The Model Context Protocol server that gives agents the `list_rag` and `search_rag` tools, over stdio or optionally over HTTP.

## Transports

| Transport | Start | Process | Notes |
|---|---|---|---|
| stdio | `kura mcp` | Separate process launched by the MCP client | Opens each registered database's `data.db` itself and runs no watcher; databases that fail to open are skipped |
| Streamable HTTP | `kura remote enable` | The running daemon, at `<endpoint>/mcp` | Off by default; the route is decided at daemon startup, so enabling restarts a running daemon |

Both transports share one server definition: name `kuradb`, the server instructions below, and the same two tools. Tool calls go straight to `search.Search`, so results are identical to the [HTTP API](/http-api).

## Client Setup

Claude Code, stdio:

```bash
claude mcp add kura -- kura mcp
```

Any client that reads an `mcpServers` JSON file, stdio:

```json
{
  "mcpServers": {
    "kura": { "command": "kura", "args": ["mcp"] }
  }
}
```

Claude Code, HTTP (pin the port first so the URL stays stable):

```bash
kura port set 23456
kura remote enable
claude mcp add --transport http kura http://localhost:23456/mcp
```

The server sends instructions that tell the agent to call `list_rag` when the database name is unknown, then `search_rag`, and that the server stores only indexed files, with no conversation history or session memory.

## Tool: list_rag

Takes no arguments and returns the same shape as `GET /api/list`:

```json
{ "loaded": ["notes"], "registered": [{ "db": "notes", "createAt": "2026-10-21T07:13:55Z" }] }
```

## Tool: search_rag

| Argument | Type | Required | Rule |
|---|---|---|---|
| `db` | string | Yes | Target database name; surrounding spaces are trimmed |
| `q` | string | Yes | Space-separated keywords; surrounding spaces are trimmed |
| `limit` | integer | No | 1 to 100, default 10; invalid values fall back to 10 |
| `mode` | string | No | Only `keyword`; case-insensitive, omit to use it |

The structured result is `{"keyword": [{"source": ..., "matches": [{"chunk": ..., "content": ...}]}]}`. When nothing matches, the `keyword` field is omitted and the result is `{}`. Validation failures such as an unknown database come back as a tool error with `isError: true` and a message like `invalid argument: "x" not exist`.

## Related Pages

- [Keyword Search](/keyword-search)
- [Configuration](/configuration)
- [CLI Reference](/cli-reference)
