> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kept.computer/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://docs.kept.computer/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://docs.kept.computer/api/mcp.
> Every agent surface: https://docs.kept.computer/.well-known/llms-manifest.json

# MCP server (/documentation/connect-ai-coding-tools/connect-claude-code-and-cursor-over-mcp)

<!-- agent-signals: reading_time_min: 11 · est_tokens: 4424 · updated: 2026-12-05 -->
Related: [HTTP API reference](/documentation/connect-ai-coding-tools/http-api.md), [Install and set up](/documentation/get-started/quickstart.md)

Connect your coding agent to Kept to get cited answers from your team's runbooks and docs. The MCP server runs on the Mac that runs Kept and exposes three read-only tools: `ask`, `search` and `list_sources`. Agents can't create, edit, delete or manage documents. The [HTTP API](./http-api-reference) is read-only in the same way.

## Before you start

1. In Kept, open **Settings → Sharing**. Under **Apps and AI tools**, turn on **Let apps and AI tools on this Mac use Kept**.
2. Create a key for the tool and name it for its use, such as “Claude Code on Sam's Mac”. Copy it when it appears. It starts with `kept_`, Kept shows it once, and Kept stores only a hash of it.
3. Add Kept to your agent using the setup below. Replace `YOUR_KEY` with your key or use the `KEPT_KEY` environment variable where shown.

<Warning>If your agent uses a cloud model, the answers and passages Kept returns go to that model's provider as part of the agent's context. Use a local model to keep those results on the Mac.</Warning>

## Set up your agent

Run the agent on the same Mac as Kept. Every client connects to `http://127.0.0.1:47822/mcp` and sends `Authorization: Bearer YOUR_KEY`. The config file and field names vary by client.

Where the client supports environment variables, put `export KEPT_KEY=kept_…` in `~/.zshrc`, open a new terminal, and reference `KEPT_KEY` as shown. Don't commit a config file that contains a key.

| Agent                                               | Where it goes                                      |
| --------------------------------------------------- | -------------------------------------------------- |
| [Claude Code](#claude-code)                         | One command                                        |
| [Codex](#codex)                                     | One command or `~/.codex/config.toml`              |
| [Cursor](#cursor)                                   | `.cursor/mcp.json` or `~/.cursor/mcp.json`         |
| [VS Code (GitHub Copilot)](#vs-code-github-copilot) | `.vscode/mcp.json`                                 |
| [Windsurf](#windsurf)                               | `~/.codeium/windsurf/mcp_config.json`              |
| [Zed](#zed)                                         | Zed's `settings.json`                              |
| [Gemini CLI](#gemini-cli)                           | `~/.gemini/settings.json`                          |
| [OpenCode](#opencode)                               | `opencode.json`                                    |
| [Cline](#cline)                                     | Cline's MCP settings                               |
| [LM Studio](#lm-studio)                             | LM Studio's `mcp.json`                             |
| [Goose](#goose)                                     | Extensions settings                                |
| [Claude Desktop](#claude-desktop)                   | `claude_desktop_config.json`, through `mcp-remote` |

After editing a config file, restart the agent or reload its MCP servers. These setups follow the clients' documentation as of November 2026. If a client doesn't connect, check its current MCP docs for a remote or HTTP server configuration.

### Claude Code

Run this command to add Kept:

<CodeGroup>
```bash title="CLI"
claude mcp add --transport http kept http://127.0.0.1:47822/mcp \
  --header "Authorization: Bearer $KEPT_KEY"
```
</CodeGroup>

Add `--scope user` to use Kept in every project. Run `claude mcp list` to see whether it's connected.

### Codex

The Codex CLI and IDE extension share one config. Set `KEPT_KEY` in the environment Codex starts from. Register Kept with the CLI or add it to `~/.codex/config.toml`. Both setups tell Codex to read the key from the environment without writing the key itself to the config file.

<CodeGroup>
```bash title="CLI"
codex mcp add kept --url http://127.0.0.1:47822/mcp --bearer-token-env-var KEPT_KEY
```

```toml title="~/.codex/config.toml"
[mcp_servers.kept]
url = "http://127.0.0.1:47822/mcp"
bearer_token_env_var = "KEPT_KEY"
```
</CodeGroup>

### Cursor

Add Kept to `.cursor/mcp.json` for one project or `~/.cursor/mcp.json` for every project:

<CodeGroup>
```json title=".cursor/mcp.json"
{
  "mcpServers": {
    "kept": {
      "url": "http://127.0.0.1:47822/mcp",
      "headers": { "Authorization": "Bearer ${env:KEPT_KEY}" }
    }
  }
}
```
</CodeGroup>

Open **Cursor Settings → MCP**. Kept should show three tools.

### VS Code (GitHub Copilot)

Add Kept to `.vscode/mcp.json` for a workspace, or run **MCP: Open User Configuration** from the Command Palette to configure it for all workspaces. The top-level key is `servers` and the server `type` is `http`:

<CodeGroup>
```json title=".vscode/mcp.json"
{
  "servers": {
    "kept": {
      "type": "http",
      "url": "http://127.0.0.1:47822/mcp",
      "headers": { "Authorization": "Bearer ${input:kept-key}" }
    }
  },
  "inputs": [
    { "id": "kept-key", "type": "promptString", "description": "Kept API key", "password": true }
  ]
}
```
</CodeGroup>

VS Code asks for the key once and stores it securely outside the config file. Use Kept from Copilot Chat in agent mode.

### Windsurf

Open `~/.codeium/windsurf/mcp_config.json` or go to **Windsurf Settings → Cascade → MCP Servers → View raw config**. Use `serverUrl` for the address:

<CodeGroup>
```json title="mcp_config.json"
{
  "mcpServers": {
    "kept": {
      "serverUrl": "http://127.0.0.1:47822/mcp",
      "headers": { "Authorization": "Bearer ${env:KEPT_KEY}" }
    }
  }
}
```
</CodeGroup>

Press refresh in the **MCP Servers** panel after saving. On Teams and Enterprise plans, an admin may need to allow remote MCP servers.

### Zed

Open Zed's settings (`⌘` + `,`) and add Kept under `context_servers`:

<CodeGroup>
```json title="settings.json"
{
  "context_servers": {
    "kept": {
      "url": "http://127.0.0.1:47822/mcp",
      "headers": { "Authorization": "Bearer YOUR_KEY" }
    }
  }
}
```
</CodeGroup>

Kept appears in the **Agent Panel** settings. The dot turns green when Kept is connected.

### Gemini CLI

Add Kept to `~/.gemini/settings.json` or `.gemini/settings.json` in a project. Use `httpUrl` for Streamable HTTP. The `url` field selects the older SSE transport.

<CodeGroup>
```json title="~/.gemini/settings.json"
{
  "mcpServers": {
    "kept": {
      "httpUrl": "http://127.0.0.1:47822/mcp",
      "headers": { "Authorization": "Bearer $KEPT_KEY" }
    }
  }
}
```
</CodeGroup>

Run `/mcp` in Gemini CLI to see Kept and its tools.

### OpenCode

Add Kept to `opencode.json` in a project or `~/.config/opencode/opencode.json` for all projects:

<CodeGroup>
```json title="opencode.json"
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "kept": {
      "type": "remote",
      "url": "http://127.0.0.1:47822/mcp",
      "headers": { "Authorization": "Bearer {env:KEPT_KEY}" },
      "oauth": false
    }
  }
}
```
</CodeGroup>

`"oauth": false` tells OpenCode to use the key without trying to sign in. Asking can take up to a minute. If OpenCode times out early, add `"timeout": 90000`.

### Cline

In VS Code, open Cline's **MCP Servers** panel, choose **Configure MCP Servers**, and add Kept:

<CodeGroup>
```json title="cline_mcp_settings.json"
{
  "mcpServers": {
    "kept": {
      "type": "streamableHttp",
      "url": "http://127.0.0.1:47822/mcp",
      "headers": { "Authorization": "Bearer YOUR_KEY" }
    }
  }
}
```
</CodeGroup>

### LM Studio

LM Studio runs models locally, so the results Kept returns stay on the Mac. Open **Program → Install → Edit mcp.json** in the right sidebar and add Kept:

<CodeGroup>
```json title="mcp.json"
{
  "mcpServers": {
    "kept": {
      "url": "http://127.0.0.1:47822/mcp",
      "headers": { "Authorization": "Bearer YOUR_KEY" }
    }
  }
}
```
</CodeGroup>

Choose a model that supports tool use. Kept's model and LM Studio's model both need memory, so use a small model in LM Studio on a 16 GB Mac.

### Goose

Use these values when Goose asks for the extension settings:

* **Type:** Streamable HTTP
* **Endpoint:** `http://127.0.0.1:47822/mcp`
* **Request headers:** `Authorization` = `Bearer YOUR_KEY`

<Tabs>
<Tab title="Goose app">Open **Extensions → Add custom extension**.</Tab>

<Tab title="CLI">Run `goose configure`, then choose **Add Extension → Remote Extension (Streamable HTTP)**.</Tab>
</Tabs>

### Claude Desktop

Claude Desktop's built-in connectors reach servers through Anthropic's cloud and can't reach `127.0.0.1` on your Mac. Run the open-source `mcp-remote` bridge on the Mac instead. The bridge needs Node.js. Open **Settings → Developer → Edit Config** and add:

<CodeGroup>
```json title="claude_desktop_config.json"
{
  "mcpServers": {
    "kept": {
      "command": "npx",
      "args": [
        "-y", "mcp-remote", "http://127.0.0.1:47822/mcp",
        "--header", "Authorization:${KEPT_AUTH}"
      ],
      "env": { "KEPT_AUTH": "Bearer YOUR_KEY" }
    }
  }
}
```
</CodeGroup>

Quit and reopen Claude Desktop. Keep the header as written, without a space after the colon: some apps split arguments at spaces. Claude Desktop sends what Kept returns to Anthropic's servers.

### Other clients

Any MCP client that supports Streamable HTTP with custom headers works. Look for a remote or HTTP server in the client's docs, then enter the address and `Authorization` header. If the client can only run local commands, use the `mcp-remote` bridge as shown for [Claude Desktop](#claude-desktop).

## Check it works

1. Ask your agent: “Use Kept to list the sources it has.” The agent should call `list_sources` and name your documents.
2. Ask a question your docs cover, such as “Using Kept, how do we roll back a deploy?” The answer should come with citations.
3. If the agent doesn't connect, check the key with `curl -H "Authorization: Bearer $KEPT_KEY" http://127.0.0.1:47822/v1/status`. A `401` means the key is wrong. If there's no response, Kept isn't open or the API is off. See [API and MCP errors](./troubleshooting#api-and-mcp-errors).

Agents decide when to call a tool based on its description. To make yours use Kept without asking for it each time, add this line to its instructions file, such as `CLAUDE.md`, `AGENTS.md` or `.cursor/rules`: “For questions about our runbooks, policies or internal docs, ask the kept MCP server and cite its sources.”

## Tools

Each tool returns `structuredContent` matching its `outputSchema`. It also returns the same JSON as text for clients that only read `content`.

### `ask`

Get an answer from your documents with numbered citations. A local model writes the answer in 5 to 60 seconds.

<ParamField body="question" type="string" required>The question in plain language. Up to 2,000 characters.</ParamField>

The result includes the answer and its citations:

```json title="ask result"
{
  "kind": "grounded",
  "answer": "Roll back with the deploy tool's previous release, then confirm the error rate drops within 10 minutes [1]. Page the payments on-call if it doesn't [2].",
  "citations": [
    { "number": 1, "source": "payments-runbook.md", "category": "Runbooks", "quote": "To roll back, run deploy rollback payments --to previous…" },
    { "number": 2, "source": "on-call.md", "category": "Runbooks", "quote": "If the error rate hasn't recovered within 10 minutes, page…" }
  ]
}
```

`kind` is `grounded` when the answer comes from your documents or `notFound` when they don't cover the question. `pinned: true` marks an answer the owner approved. If `notice` is present, show it alongside the answer.

If the answer has no `[n]` markers, `citations` contains the closest passages Kept found. Those passages don't establish which ones the model used. From the next release, `citationsAreExplicit` is `true` when each citation matches a marker and `false` when the citations are only the closest passages. Until then, Kept omits the field. Tell your agent to quote a passage as a source only when its number appears in the answer. See [the answer object](./http-api-reference#the-answer-object).

### `search`

Find the most relevant passages, best first, without generating an answer. Use it when the agent needs the exact wording.

<ParamField body="query" type="string" required>What to look for. Up to 2,000 characters.</ParamField>

<ParamField body="limit" type="integer">How many passages to return, from 1 to 20. Defaults to 6.</ParamField>

The result contains `passages`. Each passage can include `source`, `category`, `pageStart`, `pageEnd`, `heading`, `text` and `relevance` (0 to 1). See [the passage object](./http-api-reference#the-passage-object).

### `list_sources`

List the documents Kept answers from. This tool takes no input. The result contains `sources`. Each source can include `id`, `name`, `type`, `category`, `status` (`ready`, `noText` or `error`), `pages` and `addedAt`. See [the source object](./http-api-reference#the-source-object).

## When a tool fails

Kept returns a tool result with `isError: true` and a plain-language message for these failures:

* The question or query is empty or too long.
* The trial or subscription has ended. Listing sources still works.
* The AI engine isn't running or the model isn't installed.
* The client asked too many questions in the last minute.

An unknown tool name returns JSON-RPC error `-32602`.

## Protocol

The endpoint is `http://127.0.0.1:47822/mcp`. It uses Streamable HTTP and returns plain JSON without an event stream. It is stateless, with no session IDs. Send one JSON-RPC message per request. Kept doesn't support batches.

| Protocol version                         | How it works with Kept                                                                                                                                                                                                                                                                     |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `2026-07-28`                             | No handshake. Send `_meta["io.modelcontextprotocol/protocolVersion"]` with every request, plus matching `MCP-Protocol-Version` and `Mcp-Method` headers. For `tools/call`, also send `Mcp-Name`. `server/discover` returns supported versions, capabilities, server info and instructions. |
| `2025-03-26`, `2025-06-18`, `2025-11-25` | Send `initialize`, then `notifications/initialized` (Kept responds with `202`), then requests.                                                                                                                                                                                             |

| Code     | HTTP                          | Meaning                                                                                                                                                                   |
| -------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-32700` | `400`                         | The body isn't valid JSON.                                                                                                                                                |
| `-32600` | `400`                         | The body isn't a single JSON-RPC 2.0 message.                                                                                                                             |
| `-32601` | `200` (`404` on `2026-07-28`) | Method not supported.                                                                                                                                                     |
| `-32602` | `200`                         | Unknown tool.                                                                                                                                                             |
| `-32020` | `400`                         | A header doesn't match the body (`2026-07-28`).                                                                                                                           |
| `-32022` | `400`                         | Unsupported protocol version. `data.supported` lists the stateless version Kept supports (`2026-07-28`). The older versions in the table above work through `initialize`. |

Authentication, rate limits and HTTP-level errors (`401`, `402`, `403`, `429`) are the same as for the [HTTP API](./http-api-reference).

## Security

* **This Mac only.** Kept listens on `127.0.0.1`. Other computers can't reach port `47822`.
* **Keys.** Create one key per tool. Kept shows each key once, stores only its SHA-256 hash and compares hashes in constant time. Revoking a key stops it on the next request. Turning the API off stops every key.
* **Website requests.** Kept requires a loopback `Host` to stop DNS rebinding and refuses requests with a non-loopback `Origin`. Websites can't send `Authorization` without a CORS preflight, which Kept never approves.
* **Read-only access.** No tool can add, change or delete anything. Kept doesn't save questions from MCP in its history.
* **Untrusted text.** Passages contain your documents' words. Anyone who can edit a synced document can put text in front of your agent. Treat tool output as data, as you would a web page.

Something wrong or missing? [Tell us](mailto:hello@kept.computer?subject=Docs%3A%20MCP%20server).
