# Cortex MCP server

> Provides a self-hosted intelligence layer for homelab logs, metrics, and AI transcripts using SQLite and FTS5 search.

- Repository: https://github.com/dinglebear-ai/cortex
- Page: https://hostedmcp.org/servers/dinglebear-ai/cortex
- Official: yes
- Transport: stdio
- Stars: 4
- License: AGPL-3.0
- Latest version: 3.13.2

## Install

### Claude Code

```sh
claude mcp add --env 'CORTEX_API_TOKEN=<YOUR_CORTEX_API_TOKEN>' --env 'CORTEX_TOKEN=<YOUR_CORTEX_TOKEN>' cortex -- npx -y @dinglebear/cortex
```

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

```json
{
  "mcpServers": {
    "cortex": {
      "command": "npx",
      "args": [
        "-y",
        "@dinglebear/cortex"
      ],
      "env": {
        "CORTEX_API_TOKEN": "<YOUR_CORTEX_API_TOKEN>",
        "CORTEX_TOKEN": "<YOUR_CORTEX_TOKEN>"
      }
    }
  }
}
```

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

```json
{
  "servers": {
    "cortex": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@dinglebear/cortex"
      ],
      "env": {
        "CORTEX_API_TOKEN": "<YOUR_CORTEX_API_TOKEN>",
        "CORTEX_TOKEN": "<YOUR_CORTEX_TOKEN>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"cortex","type":"stdio","command":"npx","args":["-y","@dinglebear/cortex"],"env":{"CORTEX_API_TOKEN":"<YOUR_CORTEX_API_TOKEN>","CORTEX_TOKEN":"<YOUR_CORTEX_TOKEN>"}}'
```

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

```json
{
  "mcpServers": {
    "cortex": {
      "command": "npx",
      "args": [
        "-y",
        "@dinglebear/cortex"
      ],
      "env": {
        "CORTEX_API_TOKEN": "<YOUR_CORTEX_API_TOKEN>",
        "CORTEX_TOKEN": "<YOUR_CORTEX_TOKEN>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add cortex --env 'CORTEX_API_TOKEN=<YOUR_CORTEX_API_TOKEN>' --env 'CORTEX_TOKEN=<YOUR_CORTEX_TOKEN>' -- npx -y @dinglebear/cortex
```

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

```toml
[mcp_servers.cortex]
command = "npx"
args = ["-y", "@dinglebear/cortex"]

[mcp_servers.cortex.env]
CORTEX_API_TOKEN = "<YOUR_CORTEX_API_TOKEN>"
CORTEX_TOKEN = "<YOUR_CORTEX_TOKEN>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'CORTEX_API_TOKEN=<YOUR_CORTEX_API_TOKEN>' -e 'CORTEX_TOKEN=<YOUR_CORTEX_TOKEN>' cortex npx -- -y @dinglebear/cortex
```

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

```json
{
  "mcpServers": {
    "cortex": {
      "command": "npx",
      "args": [
        "-y",
        "@dinglebear/cortex"
      ],
      "env": {
        "CORTEX_API_TOKEN": "<YOUR_CORTEX_API_TOKEN>",
        "CORTEX_TOKEN": "<YOUR_CORTEX_TOKEN>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `CORTEX_API_TOKEN` | no | yes | Bearer token for Cortex REST API routes when running daemon/API mode. |
| `CORTEX_TOKEN` | no | yes | Optional bearer token for Cortex MCP HTTP mode; also used by some shared configs. |
| `CORTEX_DB_PATH` | no | no |  |
| `CORTEX_HOME` | no | no | Optional Cortex home directory containing configuration and local SQLite data. |
| `CORTEX_RMCP_RELEASE_BASE_URL` | no | no | Optional release download base URL override. |
| `CORTEX_RMCP_REPO` | no | no | Optional GitHub owner/repo override for release asset downloads. |
| `CORTEX_RMCP_VERSION` | no | no | Optional GitHub release tag override for the downloaded Cortex binary. |
| `RUST_LOG` | no | no | Tracing filter for Cortex logs. |

## FAQ

### What kind of data can Cortex ingest?

Cortex collects syslog (UDP/TCP), OTLP logs, metrics, and traces, Docker logs and events, managed file tails, host heartbeats, AI transcripts, shell history, and fleet inventory.

### Is Cortex suitable for large-scale enterprise use?

No, it is specifically designed for trusted homelabs or small private fleets rather than clustered log warehouses or general-purpose SIEMs.

### How can I connect an MCP client to Cortex?

You can use query-only stdio mode by pointing to the local database or use streamable HTTP mode by connecting to the persistent daemon with a bearer token.
