---
title: MCP Setup
description: Connect GitKB's local MCP server to your agent client and verify the intended knowledge base.
---

# MCP Setup

GitKB exposes **134 MCP tools** (`110` core via `git-kb mcp`, `21` code intelligence via `git-kb code mcp`, and `3` semantic search via `git-kb semantic mcp`) for documents, workspaces, sync, code intelligence, and project context. The [MCP Tools Reference](/docs/reference/mcp-tools/) lists them by category.

## How it works

Your client launches `git-kb mcp` as a local stdio server. MCP initialization and tool discovery can complete before the daemon is running. A tool operation connects to the per-KB daemon and starts it when needed.

Run the client in your project directory so GitKB discovers its `.kb/`. If the client launches servers elsewhere, configure `GITKB_ROOT` with the absolute project path.

## Claude Code

The [Claude scaffold](/docs/getting-started/claude-code/) writes the root `.mcp.json` for you:

```bash
git-kb init claude
```

For manual setup, add the server to `.mcp.json`:

```json
{
  "mcpServers": {
    "gitkb": {
      "command": "git-kb",
      "args": ["mcp"]
    }
  }
}
```

## Codex

Register the local server:

```bash
codex mcp add gitkb -- git-kb mcp
codex mcp list
```

You can also configure it in Codex's `config.toml`:

```toml
[mcp_servers.gitkb]
command = "git-kb"
args = ["mcp"]

[mcp_servers.gitkb.env]
GITKB_ROOT = "/absolute/path/to/your-project"
```

The explicit root is useful when the server's working directory differs from the project. Codex supports user and trusted project configuration; see the [official OpenAI MCP documentation](https://developers.openai.com/codex/mcp).

For GitKB workflow skills and project instructions, also run `git-kb init codex`. The optional hook bundle has its own MCP entry; see [Codex](/docs/getting-started/codex/) before combining installation methods.

## Other clients

The same stdio command works with MCP clients that can launch local processes:

| Client                  | GitKB scaffold         | MCP configuration                                                          |
| ----------------------- | ---------------------- | -------------------------------------------------------------------------- |
| Cursor                  | `git-kb init cursor`   | `.cursor/mcp.json`                                                         |
| Windsurf                | `git-kb init windsurf` | Use the global MCP settings described by the scaffold                      |
| OpenCode                | `git-kb init opencode` | `opencode.json`                                                            |
| oh-my-pi                | `git-kb init oh-my-pi` | `.omp/mcp.json`                                                            |
| Grok Build              | `git-kb init grok`     | `.grok/config.toml`                                                        |
| Cline and other clients | Manual                 | Add command `git-kb` with arguments `["mcp"]` in the client's MCP settings |

Use `git-kb init <harness> --help` for its options, and `--dry-run` to preview generated files. Harnesses differ in whether they use project or global MCP configuration; the [harness reference](/docs/reference/agent-harnesses/) covers the supported integrations.

For JSON clients that accept the `mcpServers` format, the server entry can include an explicit root:

```json
{
  "mcpServers": {
    "gitkb": {
      "command": "git-kb",
      "args": ["mcp"],
      "env": {
        "GITKB_ROOT": "/absolute/path/to/your-project"
      }
    }
  }
}
```

## Verify an operation

Restart or reconnect the client after changing configuration. Ask:

> "Use GitKB to list the documents in this project's knowledge base."

The assistant should call `kb_list`. Confirm that the returned documents belong to the intended project. Tool discovery alone verifies the stdio connection; a successful KB operation also exercises the daemon path.

MCP writes follow the workspace-first model. Creating or updating a document normally leaves pending edits; use `kb_status`, `kb_diff`, and a scoped `kb_commit` to record them. Some tools offer an explicit `commit` option; inspect their schemas for that behavior.

## Troubleshooting

| Problem                                 | Check                                                                           |
| --------------------------------------- | ------------------------------------------------------------------------------- |
| Server command not found                | Make `git-kb` available to the client's process, or configure its absolute path |
| Tools do not appear                     | Check the client's MCP status and reconnect after editing configuration         |
| Tools list works but an operation fails | Run `git-kb daemon status` and `git-kb doctor --json` in the project            |
| Wrong KB loaded                         | Set `GITKB_ROOT` in the server environment and reconnect                        |
| Remote sync operation fails             | Check authentication and run `git-kb sync status origin --json`                 |

## Next steps

- [MCP Tools Reference](/docs/reference/mcp-tools/) — Tool inventory and parameters
- [Claude Code](/docs/getting-started/claude-code/) — Rules, skills, and hooks
- [Codex](/docs/getting-started/codex/) — Project instructions and optional hooks
- [Agent Workflows](/docs/guides/agent-workflows/) — Turn tool operations into committed task evidence
