# CocoIndex Code MCP server

> Provides AST-based semantic code search for local repositories using incremental re-indexing and natural language queries.

- Repository: https://github.com/cocoindex-io/cocoindex-code
- Page: https://hostedmcp.org/servers/cocoindex-io/cocoindex-code
- Transport: stdio
- Stars: 2982
- License: Apache-2.0
- Latest version: 0.2.43

## Install

### Claude Code

```sh
claude mcp add cocoindex-code -- uvx cocoindex-code
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "cocoindex-code": {
      "command": "uvx",
      "args": [
        "cocoindex-code"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "cocoindex-code": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "cocoindex-code"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"cocoindex-code","type":"stdio","command":"uvx","args":["cocoindex-code"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "cocoindex-code": {
      "command": "uvx",
      "args": [
        "cocoindex-code"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add cocoindex-code -- uvx cocoindex-code
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.cocoindex-code]
command = "uvx"
args = ["cocoindex-code"]
```

### Gemini CLI

```sh
gemini mcp add -s user cocoindex-code uvx -- cocoindex-code
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "cocoindex-code": {
      "command": "uvx",
      "args": [
        "cocoindex-code"
      ]
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `COCOINDEX_CODE_DB_PATH_MAPPING` | no | no |  |
| `COCOINDEX_CODE_ROOT_PATH` | no | no | Root directory of the codebase to index. Set it when the client does not start the server inside the codebase. If unset, the server uses its working directory. |
| `COCOINDEX_DISABLE_USAGE_TRACKING` | no | no |  |
| `COCOINDEX_LMDB_MAP_SIZE` | no | no |  |

## FAQ

### How do I install CocoIndex Code with local embeddings?

You can install the batteries-included version using pipx or uv with the [full] extra, which includes sentence-transformers for local embeddings.

### What is the difference between the full and slim installation styles?

The 'full' version includes local embeddings so no API key is required, while the 'slim' version requires a cloud embedding provider and an API key.

### What tools does the MCP server expose?

The MCP server exposes a 'search' tool that allows searching the codebase using semantic similarity with parameters for query, limit, offset, and filters.
