|
| 1 | +# MCP Configuration Guide |
| 2 | + |
| 3 | +This guide covers all configuration options for the CTX MCP server integration with Claude Desktop and other MCP |
| 4 | +clients. |
| 5 | + |
| 6 | +## Table of Contents |
| 7 | + |
| 8 | +- [Configuration Modes](#configuration-modes) |
| 9 | +- [Platform-Specific Configurations](#platform-specific-configurations) |
| 10 | + - [Linux Configuration](#linux-configuration) |
| 11 | + - [macOS Configuration](#macos-configuration) |
| 12 | + - [Windows Configuration](#windows-configuration) |
| 13 | + - [Windows with WSL Configuration](#windows-with-wsl-configuration) |
| 14 | +- [Environment Variables](#environment-variables) |
| 15 | + - [Setting Environment Variables](#setting-environment-variables) |
| 16 | + - [Environment Variables with WSL](#environment-variables-with-wsl) |
| 17 | +- [Configuration Generator](#configuration-generator) |
| 18 | +- [Troubleshooting](#troubleshooting) |
| 19 | + |
| 20 | +## Configuration Modes |
| 21 | + |
| 22 | +The CTX MCP server supports two primary configuration modes: |
| 23 | + |
| 24 | +### Global Registry Mode (Recommended) |
| 25 | + |
| 26 | +Use this mode when working with multiple projects: |
| 27 | + |
| 28 | +```json |
| 29 | +{ |
| 30 | + "mcpServers": { |
| 31 | + "ctx": { |
| 32 | + "command": "ctx", |
| 33 | + "args": [ |
| 34 | + "server" |
| 35 | + ] |
| 36 | + } |
| 37 | + } |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +**Features:** |
| 42 | + |
| 43 | +- Enables dynamic switching between registered projects |
| 44 | +- Requires projects to be registered with `ctx project:add` |
| 45 | +- No need to specify project path in configuration |
| 46 | +- Ideal for developers working on multiple projects |
| 47 | + |
| 48 | +> Learn more about project management and dynamic switching in the [Projects Guide](projects.md). |
| 49 | +
|
| 50 | +**Setup:** |
| 51 | + |
| 52 | +```bash |
| 53 | +# Register your projects |
| 54 | +ctx project:add /path/to/project1 --name "Project One" |
| 55 | +ctx project:add /path/to/project2 --name "Project Two" |
| 56 | + |
| 57 | +# Use the configuration above in Claude Desktop |
| 58 | +``` |
| 59 | + |
| 60 | +### Project-Specific Mode |
| 61 | + |
| 62 | +Use this mode for single-project workflows: |
| 63 | + |
| 64 | +```json |
| 65 | +{ |
| 66 | + "mcpServers": { |
| 67 | + "ctx": { |
| 68 | + "command": "ctx", |
| 69 | + "args": [ |
| 70 | + "server", |
| 71 | + "-c", |
| 72 | + "/path/to/project" |
| 73 | + ] |
| 74 | + } |
| 75 | + } |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +**Features:** |
| 80 | + |
| 81 | +- Ties configuration to a specific project path |
| 82 | +- No project registration needed |
| 83 | +- Good for focused single-project work |
| 84 | +- Simpler setup for dedicated environments |
| 85 | + |
| 86 | +## Platform-Specific Configurations |
| 87 | + |
| 88 | +### Linux Configuration |
| 89 | + |
| 90 | +```json |
| 91 | +{ |
| 92 | + "mcpServers": { |
| 93 | + "ctx": { |
| 94 | + "command": "/usr/local/bin/ctx", |
| 95 | + "args": [ |
| 96 | + "server", |
| 97 | + "-c", |
| 98 | + "/home/username/projects/myproject" |
| 99 | + ] |
| 100 | + } |
| 101 | + } |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +### macOS Configuration |
| 106 | + |
| 107 | +**Standard installation:** |
| 108 | + |
| 109 | +```json |
| 110 | +{ |
| 111 | + "mcpServers": { |
| 112 | + "ctx": { |
| 113 | + "command": "ctx", |
| 114 | + "args": [ |
| 115 | + "server", |
| 116 | + "-c", |
| 117 | + "/Users/username/projects/myproject" |
| 118 | + ] |
| 119 | + } |
| 120 | + } |
| 121 | +} |
| 122 | +``` |
| 123 | + |
| 124 | +### Windows Configuration |
| 125 | + |
| 126 | +**Standard installation:** |
| 127 | + |
| 128 | +```json |
| 129 | +{ |
| 130 | + "mcpServers": { |
| 131 | + "ctx": { |
| 132 | + "command": "C:\\Program Files\\ctx\\ctx.exe", |
| 133 | + "args": [ |
| 134 | + "server", |
| 135 | + "-c", |
| 136 | + "C:\\Users\\Username\\Projects\\MyProject" |
| 137 | + ] |
| 138 | + } |
| 139 | + } |
| 140 | +} |
| 141 | +``` |
| 142 | + |
| 143 | +> **Note**: You can add the path to `ctx.exe` to your environment variables to avoid specifying the full path. |
| 144 | +
|
| 145 | +**Windows path formatting:** |
| 146 | + |
| 147 | +- Use double backslashes: `C:\\Path\\To\\Project` |
| 148 | +- Or use forward slashes: `C:/Path/To/Project` |
| 149 | +- Avoid spaces in paths when possible |
| 150 | + |
| 151 | +### Windows with WSL Configuration |
| 152 | + |
| 153 | +**WSL with bash:** |
| 154 | + |
| 155 | +```json |
| 156 | +{ |
| 157 | + "mcpServers": { |
| 158 | + "ctx": { |
| 159 | + "command": "bash.exe", |
| 160 | + "args": [ |
| 161 | + "-c", |
| 162 | + "ctx server -c /home/username/projects/myproject" |
| 163 | + ] |
| 164 | + } |
| 165 | + } |
| 166 | +} |
| 167 | +``` |
| 168 | + |
| 169 | +## Environment Variables |
| 170 | + |
| 171 | +Environment variables can be used to customize the MCP server behavior, enable features, or provide authentication |
| 172 | +credentials. |
| 173 | + |
| 174 | +### Setting Environment Variables |
| 175 | + |
| 176 | +You can pass environment variables to the MCP server using the `env` property in your configuration: |
| 177 | + |
| 178 | +```json |
| 179 | +{ |
| 180 | + "mcpServers": { |
| 181 | + "ctx": { |
| 182 | + "command": "ctx", |
| 183 | + "args": [ |
| 184 | + "server", |
| 185 | + "-c", |
| 186 | + "/path/to/project" |
| 187 | + ], |
| 188 | + "env": { |
| 189 | + "GITHUB_PAT": "ghp_your_personal_access_token" |
| 190 | + } |
| 191 | + } |
| 192 | + } |
| 193 | +} |
| 194 | +``` |
| 195 | + |
| 196 | +### Environment Variables with WSL |
| 197 | + |
| 198 | +**Important**: When using `wsl.exe` as the command, the `env` property in the configuration will **not** properly pass |
| 199 | +environment variables to the WSL environment. |
| 200 | + |
| 201 | +Instead, you must set environment variables directly in the bash command: |
| 202 | + |
| 203 | +```json |
| 204 | +{ |
| 205 | + "mcpServers": { |
| 206 | + "ctx": { |
| 207 | + "command": "bash.exe", |
| 208 | + "args": [ |
| 209 | + "-c", |
| 210 | + "export GITHUB_PAT=ghp_your_token && export MCP_FILE_OPERATIONS=true && ctx server -c /path/to/project" |
| 211 | + ] |
| 212 | + } |
| 213 | + } |
| 214 | +} |
| 215 | +``` |
| 216 | + |
| 217 | +### Using .env Files |
| 218 | + |
| 219 | +You can use a `.env` file for environment configuration: |
| 220 | + |
| 221 | +```json |
| 222 | +{ |
| 223 | + "mcpServers": { |
| 224 | + "ctx": { |
| 225 | + "command": "ctx", |
| 226 | + "args": [ |
| 227 | + "server", |
| 228 | + "-c", |
| 229 | + "/path/to/project", |
| 230 | + "-e", |
| 231 | + ".env.local" |
| 232 | + ] |
| 233 | + } |
| 234 | + } |
| 235 | +} |
| 236 | +``` |
| 237 | + |
| 238 | +The `.env` file should be located in your project directory: |
| 239 | + |
| 240 | +```bash |
| 241 | +# .env.local |
| 242 | +GITHUB_PAT=ghp_your_personal_access_token |
| 243 | +MCP_FILE_OPERATIONS=true |
| 244 | +MCP_DOCUMENT_NAME_FORMAT={description} ({tags}) - {path} |
| 245 | +``` |
| 246 | + |
| 247 | +## Configuration Generator |
| 248 | + |
| 249 | +The command provides an interactive way to generate configurations: |
| 250 | + |
| 251 | +```bash |
| 252 | +ctx mcp:config |
| 253 | +``` |
| 254 | + |
| 255 | +### Command Options |
| 256 | + |
| 257 | +```bash |
| 258 | +ctx mcp:config -h |
| 259 | +``` |
| 260 | + |
| 261 | +### What the Generator Does |
| 262 | + |
| 263 | +The generator will: |
| 264 | + |
| 265 | +- 🔍 Auto-detect your operating system |
| 266 | +- 🎯 Generate the correct configuration format |
| 267 | +- 📋 Provide copy-paste ready JSON |
| 268 | +- 🧭 Include setup instructions |
| 269 | +- 💡 Suggest environment variables |
| 270 | +- ⚠️ Warn about common issues |
| 271 | + |
| 272 | +## Troubleshooting |
| 273 | + |
| 274 | +### Common Issues |
| 275 | + |
| 276 | +**Server doesn't start:** |
| 277 | + |
| 278 | +1. Verify CTX is installed: `ctx --version` |
| 279 | +2. Check project path contains `context.json` or `context.yaml` |
| 280 | +3. Review Claude Desktop logs (Settings → Developer → View Logs) |
| 281 | + |
| 282 | +**Command not found:** |
| 283 | + |
| 284 | +- Linux/macOS: Add CTX to PATH or use full path |
| 285 | +- Windows: Add `ctx.exe` directory to PATH environment variable |
| 286 | +- WSL: Ensure CTX is installed in WSL environment |
| 287 | + |
| 288 | +**Environment variables not working:** |
| 289 | + |
| 290 | +- Check syntax in `env` property |
| 291 | +- For WSL: Use export statements in bash command |
| 292 | +- For .env files: Verify file exists and path is correct |
| 293 | + |
| 294 | +**Project not loading:** |
| 295 | + |
| 296 | +- Verify configuration file exists in project root |
| 297 | +- Check file permissions |
| 298 | +- Ensure path in `-c` flag is absolute, not relative |
| 299 | + |
| 300 | +**WSL-specific issues:** |
| 301 | + |
| 302 | +- Path conversion: Use Linux paths, not Windows paths |
| 303 | +- Distribution: Specify WSL distribution if you have multiple |
| 304 | +- Environment: Variables must be set in bash command, not `env` property |
| 305 | + |
| 306 | +### Debug Mode |
| 307 | + |
| 308 | +Enable debug logging to troubleshoot issues: |
| 309 | + |
| 310 | +```json |
| 311 | +{ |
| 312 | + "mcpServers": { |
| 313 | + "ctx": { |
| 314 | + "command": "ctx", |
| 315 | + "args": [ |
| 316 | + "server", |
| 317 | + "-c", |
| 318 | + "/path/to/project", |
| 319 | + "-vvv" |
| 320 | + ] |
| 321 | + } |
| 322 | + } |
| 323 | +} |
| 324 | +``` |
0 commit comments