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
package/CHANGELOG.md ADDED
@@ -0,0 +1,212 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [1.1.0] - 2026-05-07
11
+
12
+ ### Added
13
+
14
+ **New MCP tools**
15
+ - `find_references` — find all usage/call sites for a symbol across the repo (identifier-level, not import-level)
16
+ - `get_file_content` — retrieve raw cached file content with optional line-range slicing (`startLine`/`endLine`)
17
+ - `get_symbols` — batch-fetch multiple symbols by ID, returning source in a single round-trip
18
+ - `invalidate_cache` — force a full or per-file re-index by clearing content hashes; accepts optional `filePath` to scope invalidation
19
+
20
+ **Tool capability enhancements**
21
+ - `search_symbols`: new `debug` parameter — includes per-result relevance scoring breakdown (FTS5 rank, kind boost, exact-match bonus)
22
+ - `get_symbol_source`: new `context_lines` parameter (extra lines above/below) and `verify` flag (re-reads from disk to confirm source is current)
23
+ - `index_repo`: clone and index a remote Git repository by URL; supports private repos via `token`; clones stored at `~/.purecontext/clones/`
24
+ - AI summarization via Gemini Flash — configurable as an embedding/summarization provider alongside Anthropic and OpenAI
25
+
26
+ **Ecosystem & data tools**
27
+ - Context provider framework — plugin interface (`ContextProvider`) for domain-specific symbol enrichment; providers auto-detected from project config
28
+ - dbt integration — indexes models, sources, seeds, macros, and exposures; dbt Jinja pre-processor expands `{{ ref() }}` / `{{ source() }}` before SQL parsing; column definitions from `schema.yml` stored in `frameworkMeta.columns`
29
+ - OpenAPI/Swagger handler — parses `.yaml`/`.yml` files detected as OpenAPI specs; indexes endpoints and schemas as symbols
30
+ - SQL handler — indexes tables, views, functions, and stored procedures; works standalone and with dbt Jinja expansion
31
+ - `search_columns` tool — search dbt/SQL column definitions by name or description, with upstream/downstream lineage
32
+
33
+ **Language coverage expansion to 34 languages**
34
+
35
+ 16 new language handlers added (previously 18):
36
+
37
+ | Language | Extensions | Key symbol types |
38
+ |----------|-----------|-----------------|
39
+ | Bash | `.sh`, `.bash` | function |
40
+ | Perl | `.pl`, `.pm` | function, package |
41
+ | Terraform / HCL | `.tf`, `.hcl` | resource, module, variable, output |
42
+ | Nix | `.nix` | function, attribute |
43
+ | Protobuf | `.proto` | message, service, enum, rpc |
44
+ | GraphQL | `.graphql`, `.gql` | type, query, mutation, subscription, fragment |
45
+ | Groovy | `.groovy` | function, class, method |
46
+ | Erlang | `.erl`, `.hrl` | function, module |
47
+ | Gleam | `.gleam` | function, type |
48
+ | GDScript | `.gd` | function, class, signal |
49
+ | XML | `.xml` | element (pattern-configurable) |
50
+ | Objective-C | `.m`, `.h` | function, class, method |
51
+ | Fortran | `.f90`, `.f95`, `.for`, `.f` | function, subroutine, module |
52
+ | SQL | `.sql` | table, view, function, procedure |
53
+ | OpenAPI / YAML | `.yaml`, `.yml` | endpoint, schema |
54
+ | PHP (doc coverage) | existing | PHPDoc `/** */` extraction improved |
55
+
56
+ **Cross-repo intelligence**
57
+ - `search_cross_repo` tool — unified symbol search across all repos in a workspace; supports keyword, semantic, and hybrid modes; results include `repoId` and `repoPath`
58
+ - `find_similar` tool — find semantically similar code across repos using HNSW cosine similarity; configurable `minSimilarity` threshold (requires semantic search enabled)
59
+ - Cross-repo dependency tracking — `dep_edges` extended with `sourceRepoId`/`targetRepoId` columns; `get_blast_radius` and `find_importers` can now follow edges across repo boundaries
60
+ - MCP Resources — indexed symbol outlines exposed as MCP Resources (`purecontext://repo/<repoId>/outline`) for clients that support resource subscriptions
61
+
62
+ **Git & history integration**
63
+ - Git metadata indexing — during `index_folder`, PureContext walks `git log` and maps commits to symbols via byte-range overlap; stored in new `git_metadata` SQLite table; configurable via `git.enabled`, `git.maxCommits`, `git.branches`
64
+ - `get_symbol_history` tool — symbol-level commit history (hash, author, date, message, diff) without agents needing to run git commands
65
+ - `get_churn_metrics` tool — file or symbol churn scores (commits, lines changed, authors, churn score) with optional `since` date filter; surfaces high-risk files
66
+
67
+ **AI-powered architecture analysis**
68
+ - `get_quality_metrics` tool — per-file quality scores: cyclomatic complexity, coupling (fan-in/fan-out), cohesion, doc coverage, and a composite 0–100 score
69
+ - `detect_antipatterns` tool — detects god classes, circular dependencies, deep inheritance, feature envy, and other common anti-patterns; results include severity and symbol ID
70
+ - `get_architecture_doc` tool — auto-generates a Markdown or Mermaid architecture summary from the dependency graph and quality metrics
71
+ - `get_layer_violations` tool — detects import boundary violations given a layer definition (e.g., controllers must not import repositories directly)
72
+
73
+ **Enhanced Web UI**
74
+ - Architecture heatmap — colour-coded file tree where heat indicates churn score or quality score; helps identify hot spots at a glance
75
+ - Symbol timeline — visual history of commits touching a symbol, linked to `get_symbol_history` data
76
+ - Test coverage overlay — when a coverage JSON report is present, file tree nodes show line coverage percentages
77
+ - Multi-repo workspace view — repository picker with cross-repo search tab; switch between repos without reloading
78
+ - Advanced dependency graph — zoom/pan, node grouping by directory, edge filtering by kind, and path highlighting between two selected nodes
79
+
80
+ **Distribution & platform**
81
+ - Index export (`npx purecontext-mcp export`) — archives the SQLite database and HNSW index into a portable `.pctx.tar.gz` file
82
+ - Index import (`npx purecontext-mcp import`) — restores an exported archive; repo is immediately searchable, no re-indexing required
83
+ - Public registry — pre-built indexes for popular open-source projects hosted on CDN; pull with `npx purecontext-mcp pull <package>@<version>`; browse with `npx purecontext-mcp registry list`
84
+ - Webhook auto-reindex — HTTP endpoint (`POST /webhook/reindex`) accepts GitHub/GitLab push payloads and triggers incremental re-indexing automatically
85
+ - GitHub Actions composite action — `.github/actions/purecontext-cache/action.yml`; caches the index between CI runs using `actions/cache`, exports after indexing, imports on cache hit
86
+ - VS Code extension — `vscode-purecontext` extension wraps the MCP server with a sidebar panel for symbol search, file outline, and dependency graph directly in the editor
87
+
88
+ ### Changed
89
+
90
+ - `search_symbols` response now includes `repoId` in every result (was implicit from the request parameter) — enables direct use in cross-repo result lists
91
+ - `list_repos` now includes `gitEnabled` and `lastGitIndexed` fields when git metadata indexing is active
92
+ - Default `fileLimit` raised from 1000 to 5000 (language expansion makes larger repos viable)
93
+ - `_meta` envelope included in all tool responses (previously only retrieval tools); fields: `timing_ms`, `tokens_saved`, `total_tokens_saved`, `cost_avoided`
94
+
95
+ ---
96
+
97
+ ## [1.0.0] - 2026-04-26
98
+
99
+ This is the first stable release of PureContext MCP. The public tool API is now under
100
+ semver: breaking changes require a major version bump, new tools and fields increment
101
+ the minor version, and bug fixes increment the patch version.
102
+
103
+ ### Added
104
+
105
+ **Core symbol indexing (TypeScript and JavaScript)**
106
+ - Tree-sitter AST parsing via WASM bindings (`web-tree-sitter`) — no native compilation required for the parser itself
107
+ - Extracts functions, classes, methods, constants, types, interfaces, and enums with one-line signatures
108
+ - Deterministic symbol IDs (SHA-256 of `filePath:name:kind`) for stable cross-session references
109
+ - SQLite storage (`better-sqlite3`) with four tables: `symbols`, `files`, `dep_edges`, `repos`
110
+ - Incremental re-indexing via chokidar file watcher with debounce
111
+
112
+ **Language support (16 languages)**
113
+ - TypeScript and JavaScript (full symbol + import extraction)
114
+ - Python, Go, Rust, Java, C, C++, C#, Swift, Kotlin, Dart
115
+ - Elixir, Haskell, Scala, R
116
+ - PHP, Lua, Ruby
117
+
118
+ **Framework adapters (20+ frameworks)**
119
+ - Vue 3 (SFC `<script setup>`, composables, components)
120
+ - Nuxt 3 (pages, layouts, composables, server routes, plugins)
121
+ - React and Next.js (components, hooks, server/client components, API routes)
122
+ - Angular (components, services, pipes, guards, modules, directives)
123
+ - Express and Fastify (routes, middleware, plugins)
124
+ - Django, FastAPI, Flask (views, serializers, models, routers, dependencies)
125
+ - SQLAlchemy and Prisma (models, schemas, migrations)
126
+ - Axum and Actix-web (handlers, middleware, extractors)
127
+ - Echo, Fiber, Gin (handlers, middleware, groups)
128
+ - Spring and Hibernate (controllers, services, repositories, entities)
129
+
130
+ **MCP tool surface (12 tools)**
131
+ - `index_folder` — index a project directory
132
+ - `resolve_repo` — resolve a path to its repo ID
133
+ - `list_repos` — list all indexed repositories
134
+ - `search_symbols` — search by name fragment with kind and path filters
135
+ - `get_symbol_source` — retrieve raw source by byte offsets
136
+ - `get_file_outline` — all symbols in a file with signatures
137
+ - `get_repo_outline` — all files with top-level symbols
138
+ - `get_file_tree` — directory tree with file counts
139
+ - `get_context_bundle` — transitive forward-walk from a symbol
140
+ - `get_blast_radius` — reverse-walk to find all dependents
141
+ - `find_importers` — direct importers of a file
142
+ - `find_dead_code` — exported symbols that nothing imports
143
+
144
+ **Dependency graph**
145
+ - Import resolution with tsconfig path alias support
146
+ - Forward (context bundle) and reverse (blast radius) BFS traversal
147
+ - Dead code detection across the entire project graph
148
+
149
+ **FTS5 keyword search with relevance ranking**
150
+ - Full-text search over symbol names and signatures
151
+ - camelCase query preprocessor (`getUserById` → `get user by id`)
152
+ - Hyphen-aware tokenization
153
+ - Relevance ranker: exact name match → prefix match → content match
154
+
155
+ **Semantic search — HNSW vector index**
156
+ - Optional embedding-based symbol search via `hnswlib-wasm`
157
+ - Configurable embedding provider (Anthropic, OpenAI, or none)
158
+ - Index persists alongside the SQLite database
159
+
160
+ **Token savings tracker**
161
+ - Each tool response includes `_tokenEstimate` so agents can gauge context size
162
+ - Cumulative session savings reported by `list_repos`
163
+
164
+ **Multi-tenant rate limiting**
165
+ - Per-client request quotas configurable in `config.json`
166
+ - Token bucket algorithm with burst allowance
167
+
168
+ **Web UI**
169
+ - Vite + Vue 3 dashboard served from the MCP process
170
+ - Symbol search, file outline, dependency graph visualisation
171
+ - 28 Playwright end-to-end tests
172
+
173
+ **Worker thread pool for enterprise repos**
174
+ - Parallel tree-sitter parsing across a configurable thread pool
175
+ - Designed for 10k–50k file codebases
176
+ - Graceful degradation to single-threaded mode when the pool is unavailable
177
+
178
+ **npm release infrastructure**
179
+ - `prebuildify` prebuilt binaries for Node 18/20/22 × Windows/macOS/Linux
180
+ - GitHub Actions CI: 9-job matrix (3 OS × 3 Node versions) on every push and PR
181
+ - Release workflow: prebuild + publish triggered by `v*` tags
182
+ - `files` allowlist in `package.json` — published package < 20 MB
183
+ - `scripts/check-sqlite.js` postinstall canary with actionable error message
184
+ - `scripts/verify-package.sh` pre-release verification helper
185
+
186
+ **Public launch polish**
187
+ - `--health` flag — checks prerequisites (grammars, SQLite, index directory) and exits with JSON output; non-zero exit code on any failure
188
+ - Actionable error messages throughout: missing grammar files, SQLite open failures, and config validation all produce human-readable guidance instead of raw stack traces
189
+ - Opt-in telemetry — reports anonymised usage counts (tool invocations, file counts); disabled by default, enabled via `telemetry.enabled: true` in config
190
+
191
+ **Team and cloud features**
192
+ - HTTP/SSE transport — start the server with `--transport http` (or `--transport both` for stdio + HTTP simultaneously); port and bind address configurable via `--port`/`--host` or `config.json`
193
+ - API key management — `purecontext-mcp keys create/list/revoke` CLI; keys stored as bcrypt hashes, shown once on creation; format `pctx_<workspaceId>_<24-char-random>_<checksum>`
194
+ - Workspace support — logical namespaces that group repos and API keys; managed via the admin key (`PCTX_ADMIN_KEY` env var)
195
+ - Docker deployment — official `purecontext/purecontext-mcp` image; `docker-compose.yml` included in the repo; `/health` HTTP endpoint for container health checks
196
+
197
+ ### Changed
198
+
199
+ - Minimum Node.js version: **18.0.0** (uses native `fetch`, `worker_threads`, `structuredClone`)
200
+ - Default `fileLimit` raised from 500 to 1000
201
+
202
+ ### Fixed
203
+
204
+ - `web-tree-sitter` character-vs-byte offset bug in handler text extraction (all language handlers now use byte offsets throughout)
205
+ - Forward-slash normalisation for file paths stored in SQLite (Windows compatibility)
206
+ - FTS5 hyphen tokenization — hyphens in symbol names are now indexed correctly
207
+
208
+ ---
209
+
210
+ ## [0.1.0] - 2026-04-10
211
+
212
+ Initial internal release. Core TypeScript/JavaScript indexing, SQLite storage, and MCP stdio transport.
@@ -0,0 +1,69 @@
1
+ # Introduction
2
+
3
+
4
+ ## What is PureContext MCP?
5
+
6
+ PureContext MCP is a **token-efficient source code navigation server** for AI agents. Instead of reading entire files, AI agents can retrieve exactly the symbols they need — functions, classes, methods, routes, and more — saving 90–98% of context tokens.
7
+
8
+ It implements the **Model Context Protocol (MCP)** so it works natively with Claude Code and any other MCP-compatible AI client.
9
+
10
+ ## The token efficiency problem
11
+
12
+ When an AI agent wants to understand a `validateToken` function inside an 800-line file, the naive approach is to read the entire file. That costs roughly 2,000 tokens just to locate one 45-line function.
13
+
14
+ With PureContext, the agent asks for `validateToken` by name and gets back those 45 lines — roughly 150 tokens. The rest of the file is never loaded.
15
+
16
+ ```
17
+ Without PureContext: 800-line file → ~2,000 tokens
18
+ With PureContext: 45-line symbol → ~150 tokens
19
+ Savings: 93%
20
+ ```
21
+
22
+ This compounds quickly. A typical agent conversation that touches 20 symbols across 10 files saves hundreds of thousands of tokens per session.
23
+
24
+ ## How PureContext solves it
25
+
26
+ PureContext builds a **structured index** of your codebase using tree-sitter AST parsing:
27
+
28
+ 1. **Index** — Scan the project, parse each file with a tree-sitter grammar, extract every symbol (functions, classes, routes, components…) with its byte offsets, signature, and docstring.
29
+ 2. **Store** — Write structured symbol metadata to a SQLite database. Build a dependency graph from import/require statements.
30
+ 3. **Serve** — Expose MCP tools so AI agents can search by name, retrieve source, traverse dependencies, and explore the project structure — all without reading whole files.
31
+
32
+ ## Key concepts
33
+
34
+ | Term | Meaning |
35
+ |------|---------|
36
+ | **repo** | An indexed project directory. Identified by a deterministic `repoId`. |
37
+ | **symbol** | A named, addressable code entity: function, class, method, route, component, etc. |
38
+ | **kind** | The category of a symbol: `function`, `class`, `method`, `route`, `component`, `hook`, and more. |
39
+ | **signature** | A one-line human-readable declaration: `function validateToken(token: string): boolean` |
40
+ | **summary** | A one-line description, sourced from docstring → framework inference → AI → signature fallback. |
41
+ | **repoId** | 16-char hex, deterministic: `SHA-256(absolutePath).slice(0, 16)` |
42
+ | **symbolId** | 16-char hex, deterministic: `SHA-256(filePath:name:kind).slice(0, 16)` |
43
+ | **dep edge** | An import relationship: file A imports file B. Used to build the dependency graph. |
44
+
45
+ ## Key capabilities
46
+
47
+ - Index TypeScript, JavaScript, Python, Go, Rust, Java, C#, PHP, Ruby, Kotlin, C, C++, Lua, Dart, Swift, Elixir, Haskell, Scala, R, Bash, Terraform, Protobuf, GraphQL, and 10 more — **34 languages total**
48
+ - Framework-aware extraction: Vue, React, Nuxt, Next.js, Angular, NestJS, Express, Fastify, Django, Flask, FastAPI, Gin, Rails, Laravel, Spring Boot, and more
49
+ - Dependency graph: find what a symbol depends on (`get_context_bundle`) and what depends on it (`get_blast_radius`)
50
+ - Full-text search (FTS5) and semantic search (HNSW vector index) for finding code by name or meaning
51
+ - Web UI for visual codebase exploration — graph viewer, heatmap, symbol timeline
52
+ - Multi-tenant hosting for team deployments
53
+ - Git integration: symbol-level history, churn metrics, diff analysis
54
+ - Cross-repo search across multiple indexed projects
55
+
56
+ ## Who is this for?
57
+
58
+ - **Developers using Claude Code or other AI agent locally** — index your project once, then use PureContext tools in every conversation to navigate code without burning context tokens.
59
+ - **Teams with a shared codebase** — deploy PureContext as a shared server so everyone queries the same index. No per-developer re-indexing.
60
+ - **AI application developers** — use the MCP API directly to build agents that navigate source code efficiently.
61
+
62
+ ## What PureContext is not
63
+
64
+ PureContext is a navigation and indexing layer, not a general-purpose tool:
65
+
66
+ - Not a code editor or IDE
67
+ - Not a runtime debugger or test runner
68
+ - Not a full language server (no type-checking, no completions)
69
+ - Not a replacement for reading code — it makes targeted reading fast and cheap
@@ -0,0 +1,267 @@
1
+ # Installation
2
+
3
+
4
+ ## Prerequisites
5
+
6
+ | Requirement | Version | Notes |
7
+ |-------------|---------|-------|
8
+ | Node.js | >= 18.0.0 | 18, 20, and 22 are tested |
9
+ | npm | >= 9.0.0 | Ships with Node 18+ |
10
+ | Git | any | Required only for `index_repo` (remote repo cloning) |
11
+
12
+ ## Install via npm (recommended)
13
+
14
+ ```bash
15
+ npm install -g purecontext-mcp
16
+ ```
17
+
18
+ After this, `purecontext-mcp` is available as a global command.
19
+
20
+ If you prefer not to install globally, use `npx` to run without installing:
21
+
22
+ ```bash
23
+ npx purecontext-mcp
24
+ ```
25
+
26
+ `npx` downloads the package on first use and caches it. This is the recommended approach for most AI client integrations because it picks up new versions automatically without a manual upgrade step.
27
+
28
+ ## Prebuilt binaries
29
+
30
+ PureContext uses `better-sqlite3` for SQLite access. Pre-built native binaries are bundled for:
31
+
32
+ | Platform | Node 18 | Node 20 | Node 22 |
33
+ |----------|---------|---------|---------|
34
+ | Windows x64 | ✓ | ✓ | ✓ |
35
+ | macOS x64 | ✓ | ✓ | ✓ |
36
+ | macOS arm64 | ✓ | ✓ | ✓ |
37
+ | Linux x64 | ✓ | ✓ | ✓ |
38
+ | Linux arm64 | ✓ | ✓ | ✓ |
39
+
40
+ When a prebuilt binary matches your platform, `npm install` completes without any native compilation. No Python, no `node-gyp`, no build tools needed.
41
+
42
+ If your platform/Node combination is not in the table above, `npm install` will attempt a native compile. You will need:
43
+ - Python 3.x
44
+ - A C++ compiler (MSVC on Windows, clang/gcc on macOS/Linux)
45
+ - `node-gyp`: `npm install -g node-gyp`
46
+
47
+ ---
48
+
49
+ ## Connecting to your AI client
50
+
51
+ PureContext works with any MCP-compatible AI client. Choose the setup that matches your environment.
52
+
53
+ ### Claude Code (CLI)
54
+
55
+ ```bash
56
+ claude mcp add purecontext-mcp -- npx purecontext-mcp
57
+ ```
58
+
59
+ Verify:
60
+
61
+ ```bash
62
+ claude mcp list
63
+ # purecontext-mcp connected npx purecontext-mcp
64
+ ```
65
+
66
+ ### Claude Desktop
67
+
68
+ Edit `~/.claude/claude_desktop_config.json` (create it if it doesn't exist):
69
+
70
+ ```json
71
+ {
72
+ "mcpServers": {
73
+ "purecontext": {
74
+ "command": "npx",
75
+ "args": ["purecontext-mcp"]
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ If you installed globally (`npm install -g purecontext-mcp`), you can use the binary directly:
82
+
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "purecontext": {
87
+ "command": "purecontext-mcp"
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ Restart Claude Desktop after saving the file.
94
+
95
+ ### Cursor
96
+
97
+ Create or edit `.cursor/mcp.json` in your project directory for a project-scoped connection, or `~/.cursor/mcp.json` for a global one:
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "purecontext": {
103
+ "command": "npx",
104
+ "args": ["purecontext-mcp"]
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ Reload the Cursor window after saving (`Ctrl+Shift+P` → "Developer: Reload Window").
111
+
112
+ ### Windsurf
113
+
114
+ Open Windsurf Settings and navigate to the MCP section, or edit the MCP configuration file directly:
115
+
116
+ ```json
117
+ {
118
+ "mcpServers": {
119
+ "purecontext": {
120
+ "command": "npx",
121
+ "args": ["purecontext-mcp"]
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ ### VS Code (with MCP support)
128
+
129
+ Create `.vscode/mcp.json` in your project:
130
+
131
+ ```json
132
+ {
133
+ "servers": {
134
+ "purecontext": {
135
+ "type": "stdio",
136
+ "command": "npx",
137
+ "args": ["purecontext-mcp"]
138
+ }
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### Connecting to a shared team server (HTTP)
144
+
145
+ If your team runs a shared PureContext server, connect with an HTTP transport instead of launching a local process. The config format is the same across all clients — only the transport section changes:
146
+
147
+ **Claude Code CLI:**
148
+
149
+ ```bash
150
+ claude mcp add purecontext-shared \
151
+ --transport http \
152
+ --url https://purecontext.yourcompany.com/mcp/sse \
153
+ --header "Authorization: Bearer pctx_yourpersonalkey"
154
+ ```
155
+
156
+ **Claude Desktop / Cursor / Windsurf (config file):**
157
+
158
+ ```json
159
+ {
160
+ "mcpServers": {
161
+ "purecontext": {
162
+ "transport": "http",
163
+ "url": "https://purecontext.yourcompany.com/mcp/sse",
164
+ "headers": {
165
+ "Authorization": "Bearer pctx_yourpersonalkey"
166
+ }
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ Your API key is issued by your team's PureContext administrator. See [Team Setup](15-team-setup.md) for how to deploy and manage a shared server.
173
+
174
+ ---
175
+
176
+ ## Teaching your AI agent to use PureContext well
177
+
178
+ Installing PureContext gives your AI agent access to the tools. Adding the agent instructions tells it *how* to use them efficiently — which tool to pick for each situation, in what order to call them, and what patterns to avoid.
179
+
180
+ Two instruction files are provided at the repository root:
181
+
182
+ **`AGENT_INSTRUCTIONS_SHORT.md`** — A compact reference (~2 KB). Covers the mandatory first step, the complete tool selection table, the core rules, and the most common usage patterns. Use this for agents with limited system prompt space or when you want minimal overhead.
183
+
184
+ **`AGENT_INSTRUCTIONS.md`** — The full reference (~15 KB). Adds detailed parameter notes, every usage pattern, known limitations, decision trees, and anti-patterns. Use this when you want the agent to have complete context, especially for complex multi-step workflows.
185
+
186
+ ### Adding instructions to Claude Code
187
+
188
+ Add the short version to your project's `CLAUDE.md`:
189
+
190
+ ```bash
191
+ cat AGENT_INSTRUCTIONS_SHORT.md >> CLAUDE.md
192
+ ```
193
+
194
+ Or add the full version if the project is large and complex:
195
+
196
+ ```bash
197
+ cat AGENT_INSTRUCTIONS.md >> CLAUDE.md
198
+ ```
199
+
200
+ Claude Code reads `CLAUDE.md` at the start of every session. The instructions become part of every conversation in that project automatically — no need to repeat them.
201
+
202
+ ### Adding instructions to Cursor
203
+
204
+ Paste the contents of `AGENT_INSTRUCTIONS_SHORT.md` into your Cursor rules file (`.cursorrules` in the project root, or via Cursor Settings → Rules).
205
+
206
+ ### Adding instructions to Windsurf
207
+
208
+ Paste the contents into your Windsurf workspace memory or rules configuration.
209
+
210
+ ### Adding instructions to any other agent
211
+
212
+ The files are plain Markdown. Paste the contents into whatever system prompt, memory, or rules configuration your agent supports. The short version works well for constrained contexts. The full version is better when you can afford the space.
213
+
214
+ ### What the instructions do
215
+
216
+ Without them, an AI agent given access to PureContext may default to reading entire files (wasting tokens) rather than using `search_symbols`, or may not know to call `list_repos` first to get the `repoId` required by every tool. The instructions encode the correct workflow: check if indexed → search by name or meaning → retrieve source only for what you'll use.
217
+
218
+ ---
219
+
220
+ ## Verifying the installation
221
+
222
+ ```bash
223
+ purecontext-mcp --version
224
+ # 1.x.x
225
+
226
+ purecontext-mcp config --check
227
+ # ✓ Node.js 20.11.0
228
+ # ✓ SQLite (better-sqlite3 9.x)
229
+ # ✓ Grammar: tree-sitter-typescript.wasm
230
+ # ✓ Grammar: tree-sitter-javascript.wasm
231
+ # ... (all 34 grammars)
232
+ # ✓ Config: ~/.purecontext/config.json
233
+ ```
234
+
235
+ `config --check` validates the installation, verifies all grammar files are present, and reports the effective configuration.
236
+
237
+ ## Upgrading
238
+
239
+ ```bash
240
+ npm update -g purecontext-mcp
241
+ ```
242
+
243
+ Index files (SQLite databases) are forward-compatible within a major version. After upgrading from `1.x` to `1.y`, existing indexes continue to work. A major version upgrade (e.g., `1.x` → `2.0`) may require a re-index — the CLI will warn if it detects an incompatible index version.
244
+
245
+ ## Install from source
246
+
247
+ Use this when contributing, testing unreleased features, or running a local build.
248
+
249
+ ```bash
250
+ git clone <repository-url> purecontext-mcp
251
+ cd purecontext-mcp
252
+ npm install
253
+ npm run build
254
+ npm link # makes 'purecontext-mcp' available globally from this build
255
+ ```
256
+
257
+ ## Uninstalling
258
+
259
+ ```bash
260
+ npm uninstall -g purecontext-mcp
261
+ ```
262
+
263
+ This removes the binaries. Index files and configuration are not removed. To clean everything up:
264
+
265
+ ```bash
266
+ rm -rf ~/.purecontext # Removes indexes, config, savings stats
267
+ ```
@@ -0,0 +1,135 @@
1
+ # Quick Start
2
+
3
+
4
+ ## Step 1 — Connect to Claude Code
5
+
6
+ ```bash
7
+ # Recommended: use npx (no global install needed, always up-to-date)
8
+ claude mcp add purecontext-mcp -- npx purecontext-mcp
9
+
10
+ # Or, if installed globally:
11
+ claude mcp add purecontext-mcp purecontext-mcp
12
+ ```
13
+
14
+ Verify the connection:
15
+
16
+ ```bash
17
+ claude mcp list
18
+ # purecontext-mcp connected npx purecontext-mcp
19
+ ```
20
+
21
+ ## Step 2 — Index your project
22
+
23
+ In a Claude Code conversation, ask:
24
+
25
+ > "Use index_folder to index /path/to/my-project."
26
+
27
+ Or more naturally:
28
+
29
+ > "Index this project so I can search its symbols."
30
+
31
+ Claude will call `index_folder`. A typical response looks like:
32
+
33
+ ```json
34
+ {
35
+ "repoId": "a1b2c3d4e5f60001",
36
+ "filesIndexed": 342,
37
+ "symbolsExtracted": 4821,
38
+ "durationMs": 1240,
39
+ "languages": ["typescript", "javascript"],
40
+ "adapters": ["vue", "nuxt"]
41
+ }
42
+ ```
43
+
44
+ Re-indexing is incremental — only files whose content has changed are re-parsed. You can call `index_folder` again at any time; it is fast on subsequent runs.
45
+
46
+ ## Step 3 — Explore the project structure
47
+
48
+ ```
49
+ Get the repo outline for my project.
50
+ ```
51
+
52
+ Claude calls `get_repo_outline`, which returns all files and their top-level symbols — a token-efficient project map.
53
+
54
+ ## Step 4 — Search for symbols
55
+
56
+ ```
57
+ Search for functions named 'authenticate'.
58
+ ```
59
+
60
+ Claude calls `search_symbols`:
61
+
62
+ ```json
63
+ {
64
+ "symbols": [
65
+ {
66
+ "id": "8f3a2c1d0e4b5f9a",
67
+ "name": "authenticateUser",
68
+ "kind": "function",
69
+ "filePath": "src/auth/validator.ts",
70
+ "signature": "function authenticateUser(credentials: Credentials): Promise<User>",
71
+ "summary": "Validates user credentials and returns an authenticated User object."
72
+ }
73
+ ]
74
+ }
75
+ ```
76
+
77
+ Note: `search_symbols` returns signatures and summaries — **no source code**. This keeps the response tiny.
78
+
79
+ ## Step 5 — Retrieve source when you need it
80
+
81
+ ```
82
+ Get the source for the authenticateUser symbol.
83
+ ```
84
+
85
+ Claude calls `get_symbol_source` using the `id` from step 4 and gets back just those lines — not the whole file.
86
+
87
+ ## Example workflow
88
+
89
+ ```
90
+ User: "Find the authentication logic in this project."
91
+
92
+ Claude:
93
+ 1. search_symbols(query: "auth", kind: "function")
94
+ → Returns: authenticateUser, validateToken, hashPassword (3 matches, ~80 tokens)
95
+
96
+ 2. get_symbol_source(symbolId: "authenticateUser-id")
97
+ → Returns: 45 lines of source (~150 tokens)
98
+
99
+ Total: ~230 tokens
100
+ Without PureContext: read the 800-line auth file → ~2,000 tokens
101
+ Savings: 88%
102
+ ```
103
+
104
+ ## What to try next
105
+
106
+ | Task | Tool |
107
+ |------|------|
108
+ | See all symbols in a file | `get_file_outline` |
109
+ | Find what a function imports | `get_context_bundle` |
110
+ | Find what uses a function | `get_blast_radius` |
111
+ | Find unused exports | `find_dead_code` |
112
+ | Search by meaning, not name | `search_semantic` |
113
+ | Text search (like grep) | `search_text` |
114
+
115
+ ## Connecting to a team server
116
+
117
+ If your team runs a shared PureContext server:
118
+
119
+ ```bash
120
+ claude mcp add purecontext-remote \
121
+ --transport http \
122
+ --url https://purecontext.mycompany.com/mcp/sse \
123
+ --header "Authorization: Bearer pctx_yourpersonalkey"
124
+ ```
125
+
126
+ See [Team Setup](15-team-setup.md) for full instructions.
127
+
128
+ ## Generating a config file
129
+
130
+ ```bash
131
+ purecontext-mcp config --init
132
+ # Creates ~/.purecontext/config.json with defaults and comments
133
+ ```
134
+
135
+ See [Configuration](04-configuration.md) for all available options.