|
| 1 | +# Using Cortex with Claude Desktop |
| 2 | + |
| 3 | +This example shows how to integrate Cortex with [Claude Desktop](https://claude.ai/download) using the Model Context Protocol (MCP). |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Claude Desktop supports MCP servers, allowing Claude to use Cortex's memory capabilities directly in your conversations. This gives Claude: |
| 8 | + |
| 9 | +- **Persistent conversation memory** across chat sessions |
| 10 | +- **Knowledge retrieval** from your documents |
| 11 | +- **Workflow context** that persists between tasks |
| 12 | +- **Entity memory** for tracking people, projects, and concepts |
| 13 | + |
| 14 | +## Setup |
| 15 | + |
| 16 | +### 1. Install Cortex |
| 17 | + |
| 18 | +```bash |
| 19 | +# macOS (Apple Silicon) |
| 20 | +curl -LO https://github.com/petal-labs/cortex/releases/latest/download/cortex_0.1.0_darwin_arm64.tar.gz |
| 21 | +tar -xzf cortex_0.1.0_darwin_arm64.tar.gz |
| 22 | +sudo mv cortex_0.1.0_darwin_arm64/cortex /usr/local/bin/ |
| 23 | + |
| 24 | +# macOS (Intel) |
| 25 | +curl -LO https://github.com/petal-labs/cortex/releases/latest/download/cortex_0.1.0_darwin_amd64.tar.gz |
| 26 | +tar -xzf cortex_0.1.0_darwin_amd64.tar.gz |
| 27 | +sudo mv cortex_0.1.0_darwin_amd64/cortex /usr/local/bin/ |
| 28 | +``` |
| 29 | + |
| 30 | +### 2. Configure Claude Desktop |
| 31 | + |
| 32 | +Edit your Claude Desktop configuration file: |
| 33 | + |
| 34 | +**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` |
| 35 | + |
| 36 | +**Windows**: `%APPDATA%\Claude\claude_desktop_config.json` |
| 37 | + |
| 38 | +Add the Cortex MCP server: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "mcpServers": { |
| 43 | + "cortex": { |
| 44 | + "command": "cortex", |
| 45 | + "args": ["serve", "--namespace", "claude-desktop"] |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +### 3. Restart Claude Desktop |
| 52 | + |
| 53 | +Quit and reopen Claude Desktop. You should see Cortex tools available in the tools menu. |
| 54 | + |
| 55 | +## Configuration Options |
| 56 | + |
| 57 | +### Basic Configuration |
| 58 | + |
| 59 | +```json |
| 60 | +{ |
| 61 | + "mcpServers": { |
| 62 | + "cortex": { |
| 63 | + "command": "cortex", |
| 64 | + "args": ["serve"] |
| 65 | + } |
| 66 | + } |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +### With Custom Data Directory |
| 71 | + |
| 72 | +```json |
| 73 | +{ |
| 74 | + "mcpServers": { |
| 75 | + "cortex": { |
| 76 | + "command": "cortex", |
| 77 | + "args": ["serve", "--namespace", "claude"], |
| 78 | + "env": { |
| 79 | + "CORTEX_DATA_DIR": "/path/to/your/cortex/data" |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +### With Iris Embedding Service |
| 87 | + |
| 88 | +If you're running an [Iris](https://github.com/petal-labs/iris) embedding service: |
| 89 | + |
| 90 | +```json |
| 91 | +{ |
| 92 | + "mcpServers": { |
| 93 | + "cortex": { |
| 94 | + "command": "cortex", |
| 95 | + "args": ["serve", "--namespace", "claude"], |
| 96 | + "env": { |
| 97 | + "IRIS_ENDPOINT": "http://localhost:8000" |
| 98 | + } |
| 99 | + } |
| 100 | + } |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +## Available Tools |
| 105 | + |
| 106 | +Once configured, Claude will have access to these tools: |
| 107 | + |
| 108 | +### Conversation Memory |
| 109 | +- `conversation_append` - Save messages to memory |
| 110 | +- `conversation_history` - Retrieve past conversations |
| 111 | +- `conversation_search` - Search conversation history |
| 112 | +- `conversation_summarize` - Summarize long conversations |
| 113 | + |
| 114 | +### Knowledge Store |
| 115 | +- `knowledge_ingest` - Add documents to knowledge base |
| 116 | +- `knowledge_search` - Search your documents |
| 117 | +- `knowledge_collections` - Manage document collections |
| 118 | + |
| 119 | +### Workflow Context |
| 120 | +- `context_get` / `context_set` - Store and retrieve key-value data |
| 121 | +- `context_list` - List stored context |
| 122 | +- `context_merge` - Merge context with strategies |
| 123 | + |
| 124 | +### Entity Memory |
| 125 | +- `entity_query` - Look up entities by name |
| 126 | +- `entity_search` - Semantic search across entities |
| 127 | +- `entity_relationships` - Get entity connections |
| 128 | + |
| 129 | +## Example Prompts |
| 130 | + |
| 131 | +Once Cortex is connected, try these prompts: |
| 132 | + |
| 133 | +**Build a knowledge base:** |
| 134 | +> "Ingest this document into my 'research' collection and remember the key points." |
| 135 | +
|
| 136 | +**Search your knowledge:** |
| 137 | +> "Search my knowledge base for information about machine learning optimization." |
| 138 | +
|
| 139 | +**Track project context:** |
| 140 | +> "Remember that I'm working on the authentication feature for Project X." |
| 141 | +
|
| 142 | +**Recall past conversations:** |
| 143 | +> "What did we discuss last week about the database schema?" |
| 144 | +
|
| 145 | +## Pre-loading Knowledge |
| 146 | + |
| 147 | +You can pre-load documents before starting Claude Desktop: |
| 148 | + |
| 149 | +```bash |
| 150 | +# Ingest your project documentation |
| 151 | +cortex knowledge ingest-dir \ |
| 152 | + --collection "project-docs" \ |
| 153 | + --dir ~/projects/myapp/docs \ |
| 154 | + --pattern "*.md" \ |
| 155 | + --namespace claude-desktop |
| 156 | + |
| 157 | +# Add important reference materials |
| 158 | +cortex knowledge ingest \ |
| 159 | + --collection "references" \ |
| 160 | + --title "API Guidelines" \ |
| 161 | + --file ~/docs/api-guidelines.md \ |
| 162 | + --namespace claude-desktop |
| 163 | +``` |
| 164 | + |
| 165 | +## Troubleshooting |
| 166 | + |
| 167 | +### Cortex tools not appearing |
| 168 | + |
| 169 | +1. Check that Cortex is in your PATH: `which cortex` |
| 170 | +2. Verify the config file syntax is valid JSON |
| 171 | +3. Check Claude Desktop logs for errors |
| 172 | +4. Restart Claude Desktop completely |
| 173 | + |
| 174 | +### Connection errors |
| 175 | + |
| 176 | +1. Ensure no other process is using Cortex |
| 177 | +2. Check file permissions on the data directory |
| 178 | +3. Try running `cortex serve` manually to see errors |
| 179 | + |
| 180 | +### Data not persisting |
| 181 | + |
| 182 | +1. Verify the namespace matches between CLI and config |
| 183 | +2. Check that the data directory is writable |
| 184 | +3. Ensure you're not running multiple instances with different data dirs |
0 commit comments