purecontext-mcp 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/AGENT_INSTRUCTIONS.md +509 -0
  2. package/AGENT_INSTRUCTIONS_SHORT.md +97 -0
  3. package/CHANGELOG.md +212 -0
  4. package/docs/01-introduction.md +69 -0
  5. package/docs/02-installation.md +267 -0
  6. package/docs/03-quick-start.md +135 -0
  7. package/docs/04-configuration.md +214 -0
  8. package/docs/05-cli-reference.md +130 -0
  9. package/docs/06-tools-reference.md +499 -0
  10. package/docs/07-language-support.md +88 -0
  11. package/docs/08-framework-adapters.md +324 -0
  12. package/docs/09-dependency-graph.md +182 -0
  13. package/docs/10-semantic-search.md +153 -0
  14. package/docs/11-search-quality.md +110 -0
  15. package/docs/12-ai-summarization.md +106 -0
  16. package/docs/13-token-savings.md +110 -0
  17. package/docs/14-transport-modes.md +167 -0
  18. package/docs/15-team-setup.md +251 -0
  19. package/docs/16-docker.md +186 -0
  20. package/docs/17-web-ui.md +157 -0
  21. package/docs/18-git-history.md +157 -0
  22. package/docs/19-cross-repo.md +177 -0
  23. package/docs/20-architecture-analysis.md +228 -0
  24. package/docs/21-ecosystem-tools.md +189 -0
  25. package/docs/22-distribution.md +240 -0
  26. package/docs/23-performance.md +121 -0
  27. package/docs/24-security.md +144 -0
  28. package/docs/25-architecture-overview.md +240 -0
  29. package/docs/26-troubleshooting.md +234 -0
  30. package/docs/27-api-stability.md +114 -0
  31. package/docs/README.md +71 -0
  32. package/guide/README.md +57 -0
  33. package/guide/ai-summaries.md +127 -0
  34. package/guide/code-health.md +190 -0
  35. package/guide/code-history.md +149 -0
  36. package/guide/finding-code.md +157 -0
  37. package/guide/navigating-new-code.md +121 -0
  38. package/guide/safe-changes.md +156 -0
  39. package/guide/team-setup.md +191 -0
  40. package/guide/web-ui.md +154 -0
  41. package/guide/why-purecontext.md +73 -0
  42. package/guide/workflow-onboarding.md +114 -0
  43. package/guide/workflow-pr-review.md +199 -0
  44. package/guide/workflow-refactoring.md +172 -0
  45. package/package.json +9 -2
@@ -0,0 +1,251 @@
1
+ # Team Setup & Multi-Tenant
2
+
3
+
4
+ Run PureContext as a shared server so your whole team queries the same index — no per-developer re-indexing.
5
+
6
+ ---
7
+
8
+ ## Overview
9
+
10
+ ```
11
+ Local mode: Server mode (shared):
12
+ Claude Code (each dev) Claude Code (each dev)
13
+ ↓ stdio ↓ HTTP + API key
14
+ PureContext (local) PureContext (shared server)
15
+ ↓ ↓
16
+ Local SQLite index Shared SQLite index(es)
17
+ ```
18
+
19
+ **Why a shared server?** Each developer re-indexes the same codebase independently in local mode. A shared server indexes once and serves all team members — consistent results and no redundant work.
20
+
21
+ ---
22
+
23
+ ## Step 1 — Deploy the server
24
+
25
+ ### Docker (recommended)
26
+
27
+ ```bash
28
+ mkdir -p ./purecontext-data
29
+
30
+ docker run -d \
31
+ --name purecontext \
32
+ -p 3000:3000 \
33
+ -v "$(pwd)/purecontext-data:/data" \
34
+ -e PCTX_ADMIN_KEY="$(openssl rand -hex 32)" \
35
+ --restart unless-stopped \
36
+ purecontext/purecontext-mcp:latest
37
+ ```
38
+
39
+ Note your `PCTX_ADMIN_KEY` — you need it to manage workspaces and keys.
40
+
41
+ ### Docker Compose
42
+
43
+ ```yaml
44
+ version: '3.8'
45
+ services:
46
+ purecontext:
47
+ image: purecontext/purecontext-mcp:latest
48
+ ports:
49
+ - "3000:3000"
50
+ volumes:
51
+ - ./data:/data
52
+ environment:
53
+ PCTX_ADMIN_KEY: "change-me-before-deploying"
54
+ restart: unless-stopped
55
+ ```
56
+
57
+ ```bash
58
+ docker compose up -d
59
+ ```
60
+
61
+ ### npm (no Docker)
62
+
63
+ ```bash
64
+ npm install -g purecontext-mcp
65
+ PCTX_ADMIN_KEY=your-secret purecontext-mcp --server --host 0.0.0.0 --port 3000
66
+ ```
67
+
68
+ ### Verify the server is running
69
+
70
+ ```bash
71
+ curl http://localhost:3000/health
72
+ # {"status":"ok","version":"1.x.x","repoCount":0}
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Step 2 — Create a workspace
78
+
79
+ A workspace is the unit of isolation — one team = one workspace. All repos and API keys belong to a workspace.
80
+
81
+ ```bash
82
+ export ADMIN_KEY="your-pctx-admin-key"
83
+ export SERVER="http://localhost:3000"
84
+
85
+ curl -s -X POST "$SERVER/admin/workspaces" \
86
+ -H "Authorization: Bearer $ADMIN_KEY" \
87
+ -H "Content-Type: application/json" \
88
+ -d '{"name": "my-team", "plan": "team"}' | jq .
89
+ ```
90
+
91
+ Response:
92
+
93
+ ```json
94
+ {"id": "ws_abc123", "name": "my-team", "plan": "team", "created_at": 1714000000}
95
+ ```
96
+
97
+ Save the `id` — you'll use it when creating API keys.
98
+
99
+ ---
100
+
101
+ ## Step 3 — Create API keys
102
+
103
+ Each developer gets their own API key. Keys are shown once on creation and never again.
104
+
105
+ ```bash
106
+ curl -s -X POST "$SERVER/admin/keys" \
107
+ -H "Authorization: Bearer $ADMIN_KEY" \
108
+ -H "Content-Type: application/json" \
109
+ -d '{
110
+ "label": "alice-macbook",
111
+ "permissions": ["read", "write"],
112
+ "workspace_id": "ws_abc123"
113
+ }' | jq .
114
+ ```
115
+
116
+ **Response (key shown only once):**
117
+
118
+ ```json
119
+ {
120
+ "key": "pctx_00000000_..._1234",
121
+ "label": "alice-macbook",
122
+ "permissions": ["read", "write"],
123
+ "key_hash_prefix": "deadbeef"
124
+ }
125
+ ```
126
+
127
+ ### Permission levels
128
+
129
+ | Permission | Allowed operations |
130
+ |------------|-------------------|
131
+ | `read` | Search symbols, get outlines, get source |
132
+ | `write` | + `index_folder`, `index_repo` |
133
+ | `admin` | + Manage keys and workspaces |
134
+
135
+ For AI agents that only query (not index), use `read` permission. For CI pipelines that re-index on push, use `write`.
136
+
137
+ ---
138
+
139
+ ## Step 4 — Index the shared codebase
140
+
141
+ Connect Claude Code (step 5) and ask it to index, or call the API directly:
142
+
143
+ ```bash
144
+ curl -s -X POST "$SERVER/mcp/sse" \
145
+ -H "Authorization: Bearer pctx_yourwritekey" \
146
+ -H "Content-Type: application/json" \
147
+ -d '{
148
+ "jsonrpc": "2.0",
149
+ "method": "tools/call",
150
+ "params": {"name": "index_folder", "arguments": {"path": "/path/to/repo"}},
151
+ "id": 1
152
+ }'
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Step 5 — Connect each developer
158
+
159
+ Each developer runs this once:
160
+
161
+ ```bash
162
+ claude mcp add purecontext-remote \
163
+ --transport http \
164
+ --url https://purecontext.mycompany.com/mcp/sse \
165
+ --header "Authorization: Bearer pctx_yourpersonalkey"
166
+ ```
167
+
168
+ After adding, verify in Claude Code:
169
+
170
+ ```
171
+ /mcp
172
+ # Should show purecontext-remote as connected
173
+
174
+ List my indexed repositories using list_repos
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Step 6 — Manage keys over time
180
+
181
+ ```bash
182
+ # List all keys (shows label, prefix, permissions — never the raw key)
183
+ curl -s "$SERVER/admin/keys" -H "Authorization: Bearer $ADMIN_KEY" | jq .
184
+
185
+ # Revoke a key (e.g., when someone leaves the team)
186
+ curl -s -X DELETE "$SERVER/admin/keys/deadbeef" \
187
+ -H "Authorization: Bearer $ADMIN_KEY"
188
+
189
+ # Check key usage stats
190
+ curl -s "$SERVER/admin/keys/deadbeef/usage" \
191
+ -H "Authorization: Bearer $ADMIN_KEY" | jq .
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Rate limiting
197
+
198
+ HTTP mode uses a token-bucket algorithm to prevent any single client from overwhelming the server:
199
+
200
+ - Each key gets a bucket with capacity `rateLimit.maxTokens` (default: 100)
201
+ - Tokens refill at `rateLimit.refillRate` per second (default: 10)
202
+ - Expensive tools (e.g., `index_folder`) cost more tokens
203
+
204
+ When rate limited, responses return `429 Too Many Requests` with a `Retry-After` header.
205
+
206
+ Configure per-tool costs in `config.json`:
207
+
208
+ ```json
209
+ {
210
+ "rateLimit": {
211
+ "enabled": true,
212
+ "maxTokens": 200,
213
+ "refillRate": 20,
214
+ "perToolLimits": {
215
+ "index_folder": 10,
216
+ "search_symbols": 1
217
+ }
218
+ }
219
+ }
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Admin API reference
225
+
226
+ All endpoints require `Authorization: Bearer <PCTX_ADMIN_KEY>`.
227
+
228
+ | Endpoint | Method | Description |
229
+ |----------|--------|-------------|
230
+ | `/admin/workspaces` | `POST` | Create workspace |
231
+ | `/admin/workspaces` | `GET` | List workspaces |
232
+ | `/admin/workspaces/:id` | `DELETE` | Delete workspace and all data |
233
+ | `/admin/keys` | `POST` | Create API key |
234
+ | `/admin/keys` | `GET` | List keys |
235
+ | `/admin/keys/:prefix` | `DELETE` | Revoke key |
236
+ | `/admin/keys/:prefix/usage` | `GET` | Key usage stats |
237
+ | `/admin/stats` | `GET` | Server-wide statistics |
238
+
239
+ ---
240
+
241
+ ## Production checklist
242
+
243
+ - [ ] `PCTX_ADMIN_KEY` is a long random secret (≥ 32 hex chars), set via env var only — never in a committed config file
244
+ - [ ] Server is behind a reverse proxy (nginx, Caddy) with TLS
245
+ - [ ] Port 3000 is not directly exposed to the internet (terminate TLS at the proxy)
246
+ - [ ] `/data` volume is on a backed-up disk
247
+ - [ ] `restart: unless-stopped` is set in docker-compose
248
+ - [ ] Developers have `read` permission only unless they need to re-index
249
+ - [ ] Admin key is rotated if ever exposed
250
+
251
+ See [Docker Deployment](16-docker.md) for full reverse proxy examples.
@@ -0,0 +1,186 @@
1
+ # Docker Deployment
2
+
3
+
4
+ ---
5
+
6
+ ## Quick start
7
+
8
+ ```bash
9
+ docker run -d \
10
+ --name purecontext \
11
+ -p 3000:3000 \
12
+ -v /path/to/data:/data \
13
+ -e PCTX_ADMIN_KEY="$(openssl rand -hex 32)" \
14
+ --restart unless-stopped \
15
+ purecontext/purecontext-mcp:latest
16
+ ```
17
+
18
+ Verify:
19
+
20
+ ```bash
21
+ curl http://localhost:3000/health
22
+ # {"status":"ok","version":"1.x.x","repoCount":0}
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Docker Compose (recommended)
28
+
29
+ The `docker-compose.yml` in the project root is ready to use:
30
+
31
+ ```yaml
32
+ version: '3.8'
33
+ services:
34
+ purecontext:
35
+ image: purecontext/purecontext-mcp:latest
36
+ ports:
37
+ - "3000:3000"
38
+ volumes:
39
+ - ./data:/data
40
+ environment:
41
+ PCTX_ADMIN_KEY: "${PCTX_ADMIN_KEY}"
42
+ PCTX_PORT: "3000"
43
+ PCTX_HOST: "0.0.0.0"
44
+ restart: unless-stopped
45
+ healthcheck:
46
+ test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
47
+ interval: 30s
48
+ timeout: 10s
49
+ retries: 3
50
+ ```
51
+
52
+ ```bash
53
+ export PCTX_ADMIN_KEY="$(openssl rand -hex 32)"
54
+ docker compose up -d
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Environment variables
60
+
61
+ | Variable | Default | Description |
62
+ |----------|---------|-------------|
63
+ | `PCTX_ADMIN_KEY` | *(required)* | Admin key for `/admin/*` endpoints. Set via environment, never in config files. |
64
+ | `PCTX_DATA_DIR` | `/data` | Data directory inside container — mount a volume here. |
65
+ | `PCTX_PORT` | `3000` | HTTP port. |
66
+ | `PCTX_HOST` | `0.0.0.0` | Bind address. |
67
+ | `PCTX_LOG_LEVEL` | `info` | Log verbosity: `debug`, `info`, `warn`, `error`. |
68
+ | `ANTHROPIC_API_KEY` | — | For AI summarization (Anthropic provider). |
69
+ | `OPENAI_API_KEY` | — | For AI summarization or semantic search (OpenAI). |
70
+ | `GEMINI_API_KEY` | — | For AI summarization (Google Gemini). |
71
+
72
+ ---
73
+
74
+ ## Volume mounts
75
+
76
+ | Container path | Purpose |
77
+ |---------------|---------|
78
+ | `/data` | SQLite index databases, auth database, config. **Must be a persistent volume.** |
79
+
80
+ Without a volume mount, all indexes and API keys are lost when the container restarts.
81
+
82
+ Optional: mount local repo directories for faster indexing (avoids git clone):
83
+
84
+ ```yaml
85
+ volumes:
86
+ - ./data:/data
87
+ - /home/user/projects:/projects:ro # read-only, for indexing
88
+ ```
89
+
90
+ Then call `index_folder` with `/projects/my-repo` as the path.
91
+
92
+ ---
93
+
94
+ ## Updating
95
+
96
+ ```bash
97
+ docker compose pull
98
+ docker compose up -d --force-recreate
99
+ ```
100
+
101
+ The `/data` volume is unaffected. Index files are forward-compatible within a major version.
102
+
103
+ ---
104
+
105
+ ## Health check
106
+
107
+ The Docker image includes a built-in health check:
108
+
109
+ ```dockerfile
110
+ HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
111
+ CMD curl -f http://localhost:3000/health || exit 1
112
+ ```
113
+
114
+ Check status:
115
+
116
+ ```bash
117
+ docker inspect --format='{{.State.Health.Status}}' purecontext
118
+ # healthy
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Resource requirements
124
+
125
+ | Repo size | RAM (at rest) | RAM (during index) | CPU |
126
+ |-----------|---------------|--------------------|-----|
127
+ | < 1k files | ~100 MB | ~200 MB | any |
128
+ | 1k–10k files | ~200 MB | ~500 MB | 2+ cores recommended |
129
+ | 10k–50k files | ~500 MB | ~1 GB | 4+ cores recommended |
130
+
131
+ SQLite uses WAL mode — reads don't block writes, no special IO requirements.
132
+
133
+ ---
134
+
135
+ ## Reverse proxy (TLS termination)
136
+
137
+ ### nginx
138
+
139
+ ```nginx
140
+ server {
141
+ listen 443 ssl;
142
+ server_name purecontext.mycompany.com;
143
+
144
+ ssl_certificate /etc/letsencrypt/live/purecontext.mycompany.com/fullchain.pem;
145
+ ssl_certificate_key /etc/letsencrypt/live/purecontext.mycompany.com/privkey.pem;
146
+
147
+ location / {
148
+ proxy_pass http://localhost:3000;
149
+ proxy_http_version 1.1;
150
+ proxy_set_header Upgrade $http_upgrade;
151
+ proxy_set_header Connection keep-alive;
152
+ proxy_set_header Host $host;
153
+ proxy_set_header X-Real-IP $remote_addr;
154
+ # Required for SSE: disable buffering
155
+ proxy_buffering off;
156
+ proxy_cache off;
157
+ proxy_read_timeout 3600s;
158
+ }
159
+ }
160
+ ```
161
+
162
+ ### Caddy
163
+
164
+ ```
165
+ purecontext.mycompany.com {
166
+ reverse_proxy localhost:3000 {
167
+ flush_interval -1 # disable buffering for SSE
168
+ }
169
+ }
170
+ ```
171
+
172
+ Caddy handles TLS automatically via Let's Encrypt.
173
+
174
+ ---
175
+
176
+ ## Server logs
177
+
178
+ ```bash
179
+ # Stream logs
180
+ docker logs -f purecontext
181
+
182
+ # Last 100 lines
183
+ docker logs --tail 100 purecontext
184
+ ```
185
+
186
+ Log format: structured JSON lines when `PCTX_LOG_LEVEL=info` or higher. Each line includes timestamp, level, tool name (for MCP calls), repoId, and duration.
@@ -0,0 +1,157 @@
1
+ # Web UI
2
+
3
+
4
+ The Web UI provides a visual interface for exploring indexed codebases. It is served by the same process as the MCP server when HTTP transport is active.
5
+
6
+ ---
7
+
8
+ ## Accessing the Web UI
9
+
10
+ The Web UI is available at `http://localhost:3000` (or your server URL) when running in HTTP mode:
11
+
12
+ ```bash
13
+ purecontext-mcp --transport http --port 3000
14
+ ```
15
+
16
+ Then open `http://localhost:3000` in a browser.
17
+
18
+ ### Building the UI
19
+
20
+ The UI is pre-built in the npm package. For development or rebuilding from source:
21
+
22
+ ```bash
23
+ npm run build:ui # build only the UI
24
+ npm run build # build everything
25
+ npm run dev # watch mode: TypeScript + Vite dev server with hot reload
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Repository browser
31
+
32
+ - List all indexed repositories with symbol counts, file counts, and language breakdown
33
+ - Collapsible file tree with file type icons
34
+ - Click any file to open its symbol outline
35
+
36
+ ---
37
+
38
+ ## Symbol search
39
+
40
+ - Real-time search with 300ms debounce — results appear as you type
41
+ - Filter by: symbol kind, language, file path pattern
42
+ - Keyboard navigation: arrow keys to move through results, Enter to open
43
+ - Query term highlighting in results
44
+ - Switches between keyword and semantic mode (if semantic search is enabled)
45
+
46
+ ---
47
+
48
+ ## Symbol viewer
49
+
50
+ - Syntax-highlighted source code (powered by Shiki — VS Code-quality highlighting)
51
+ - Line numbers with anchors (shareable URLs)
52
+ - Light/dark theme toggle (preference persisted in localStorage)
53
+ - **Related symbols panel**: importers, dependencies, same-file symbols
54
+
55
+ ---
56
+
57
+ ## Dependency graph viewer
58
+
59
+ An interactive force-directed graph of file and symbol dependencies.
60
+
61
+ ### Controls
62
+
63
+ | Action | Control |
64
+ |--------|---------|
65
+ | Pan | Click and drag |
66
+ | Zoom | Scroll wheel |
67
+ | Fit to view | Double-click background |
68
+ | Select node | Click |
69
+ | Expand node | Click `+` |
70
+ | Forward walk | Enable "Dependencies" mode |
71
+ | Reverse walk | Enable "Importers" mode |
72
+
73
+ ### Layout options
74
+
75
+ - **Force-directed** (default) — physics simulation, nodes cluster by connectivity
76
+ - **Hierarchical** — root at top, dependencies flow downward
77
+ - **Radial** — selected node at center, connected nodes radiate outward
78
+
79
+ ### Depth slider
80
+
81
+ Adjust traversal depth (1–5 hops). Higher depth reveals transitive dependencies but may produce large graphs.
82
+
83
+ ### Blast radius view
84
+
85
+ Switch to "Blast radius" mode to see everything that depends on the selected node — color gradient from red (direct impact) to yellow (indirect).
86
+
87
+ ---
88
+
89
+ ## Architecture heatmap
90
+
91
+ An overlay on the file tree that color-codes files by a selected metric:
92
+
93
+ | Metric | Color scale | Use case |
94
+ |--------|-------------|----------|
95
+ | Churn | blue (stable) → red (high churn) | Identify high-risk files before a refactor |
96
+ | Complexity | green → orange → red | Find over-complex files that need attention |
97
+ | Quality score | green (high) → red (low) | Prioritize technical debt |
98
+ | Test coverage | green (covered) → red (uncovered) | Requires external coverage report |
99
+
100
+ Click any cell in the heatmap to open the file's symbol outline.
101
+
102
+ ---
103
+
104
+ ## Symbol timeline
105
+
106
+ Per-symbol git history visualized as a timeline. Shows:
107
+ - When the symbol was created (first commit where it appears)
108
+ - Each commit that modified the symbol (with author, date, message)
109
+ - When the symbol was deleted (if applicable)
110
+
111
+ Requires git history integration enabled (see [Git & History Integration](18-git-history.md)).
112
+
113
+ ---
114
+
115
+ ## Test coverage overlay
116
+
117
+ Overlays test coverage data on the file tree. Requires an lcov-format coverage report:
118
+
119
+ 1. Run your test suite with coverage output (`npx vitest --coverage`, `pytest --cov`, etc.)
120
+ 2. Export as lcov: `coverage.info` / `lcov.info`
121
+ 3. In PureContext Web UI: Settings → Coverage → Upload lcov file
122
+
123
+ Files are color-coded by coverage percentage. Click a file to see line-level coverage in the source viewer.
124
+
125
+ ---
126
+
127
+ ## Multi-repo workspace
128
+
129
+ When multiple repos are indexed, the sidebar shows a repo switcher. Cross-repo search results appear in a unified list with the source repo identified for each result.
130
+
131
+ ---
132
+
133
+ ## Advanced graph controls
134
+
135
+ Additional controls available in the graph viewer:
136
+
137
+ | Feature | Description |
138
+ |---------|-------------|
139
+ | Language filter | Show only nodes of a specific language |
140
+ | Kind filter | Show only files/symbols of a specific kind |
141
+ | Cycle detection | Highlight circular dependency cycles in red |
142
+ | Export | Save graph as SVG or PNG |
143
+ | Minimap | Overview panel for large graphs |
144
+
145
+ ---
146
+
147
+ ## Keyboard shortcuts
148
+
149
+ | Shortcut | Action |
150
+ |----------|--------|
151
+ | `/` | Focus search bar |
152
+ | `↑` / `↓` | Navigate search results |
153
+ | `Enter` | Open selected symbol |
154
+ | `Esc` | Close panels / clear search |
155
+ | `G` | Open graph view for current symbol |
156
+ | `B` | Show blast radius for current symbol |
157
+ | `H` | Toggle heatmap overlay |