@danielblomma/cortex-mcp 0.4.0

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 (41) hide show
  1. package/README.md +203 -0
  2. package/bin/cortex.mjs +621 -0
  3. package/docs/MCP_MARKETPLACE.md +160 -0
  4. package/package.json +42 -0
  5. package/scaffold/.context/config.yaml +21 -0
  6. package/scaffold/.context/ontology.cypher +63 -0
  7. package/scaffold/.context/rules.yaml +25 -0
  8. package/scaffold/.githooks/_cortex-update-runner.sh +58 -0
  9. package/scaffold/.githooks/post-checkout +22 -0
  10. package/scaffold/.githooks/post-merge +14 -0
  11. package/scaffold/docs/architecture.md +22 -0
  12. package/scaffold/mcp/package-lock.json +2623 -0
  13. package/scaffold/mcp/package.json +29 -0
  14. package/scaffold/mcp/src/embed.ts +416 -0
  15. package/scaffold/mcp/src/embeddings.ts +192 -0
  16. package/scaffold/mcp/src/graph.ts +666 -0
  17. package/scaffold/mcp/src/loadGraph.ts +597 -0
  18. package/scaffold/mcp/src/paths.ts +33 -0
  19. package/scaffold/mcp/src/search.ts +412 -0
  20. package/scaffold/mcp/src/server.ts +98 -0
  21. package/scaffold/mcp/src/types.ts +109 -0
  22. package/scaffold/mcp/tests/server.test.mjs +60 -0
  23. package/scaffold/mcp/tsconfig.json +13 -0
  24. package/scaffold/scripts/bootstrap.sh +57 -0
  25. package/scaffold/scripts/capture-note.sh +55 -0
  26. package/scaffold/scripts/context.sh +109 -0
  27. package/scaffold/scripts/embed.sh +15 -0
  28. package/scaffold/scripts/ingest.mjs +1118 -0
  29. package/scaffold/scripts/ingest.sh +20 -0
  30. package/scaffold/scripts/install-git-hooks.sh +21 -0
  31. package/scaffold/scripts/load-kuzu.sh +6 -0
  32. package/scaffold/scripts/load-ryu.sh +18 -0
  33. package/scaffold/scripts/parsers/javascript.mjs +390 -0
  34. package/scaffold/scripts/parsers/package-lock.json +51 -0
  35. package/scaffold/scripts/parsers/package.json +17 -0
  36. package/scaffold/scripts/plan-state-engine.cjs +310 -0
  37. package/scaffold/scripts/plan-state.sh +71 -0
  38. package/scaffold/scripts/refresh.sh +9 -0
  39. package/scaffold/scripts/status.sh +282 -0
  40. package/scaffold/scripts/update-context.sh +18 -0
  41. package/scaffold/scripts/watch.sh +374 -0
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # Cortex MCP
2
+
3
+ `@danielblomma/cortex-mcp` is a local, repo-scoped context platform for coding assistants.
4
+ It indexes your codebase into structured entities (files, rules, ADRs) and exposes that context over MCP (JSON-RPC over stdio).
5
+
6
+ ![Cortex install and bootstrap demo](https://raw.githubusercontent.com/DanielBlomma/cortex/main/docs/install-demo.gif)
7
+
8
+ ## Why Use Cortex
9
+
10
+ - Semantic search across code and documentation.
11
+ - Graph relationships between entities and architectural constraints.
12
+ - Local-first: your code and context stay on your machine.
13
+ - Incremental updates keep context fresh as the repo changes.
14
+ - Works with Claude Code/Desktop and Codex MCP clients.
15
+
16
+ ## Core Features
17
+
18
+ - Semantic search (files, rules, ADRs).
19
+ - Graph relationships between entities and constraints.
20
+ - Architectural rules and ADR context for implementation decisions.
21
+
22
+ ## Advanced Features (Experimental)
23
+
24
+ Cortex can extract function-level chunks and build call graphs in experimental builds:
25
+
26
+ - `context.find_callers` - what calls this function?
27
+ - `context.trace_calls` - what does this function call?
28
+ - `context.impact_analysis` - what is impacted if this function changes?
29
+ - Requires JavaScript/TypeScript codebase and semantic chunking/call graph indexing enabled.
30
+
31
+ These APIs are experimental and may not be exposed in every installation.
32
+
33
+ ## Requirements
34
+
35
+ - Node.js 18+
36
+ - Git repository
37
+ - Optional for auto-connection: `claude` and/or `codex` CLI in `PATH`
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ npm i -g @danielblomma/cortex-mcp
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ From the repository you want to index:
48
+
49
+ ```bash
50
+ cortex init --bootstrap
51
+ ```
52
+
53
+ This will:
54
+
55
+ - scaffold `.context/`, `scripts/`, `mcp/`, `.githooks/`, and docs files
56
+ - build and prepare the local MCP server
57
+ - try to auto-register MCP connections for Claude/Codex (if installed)
58
+ - start background sync unless disabled
59
+
60
+ Disable watcher setup:
61
+
62
+ ```bash
63
+ cortex init --bootstrap --no-watch
64
+ ```
65
+
66
+ ## Verify MCP Connection
67
+
68
+ Claude:
69
+
70
+ ```bash
71
+ claude mcp list
72
+ ```
73
+
74
+ Codex:
75
+
76
+ ```bash
77
+ codex mcp list
78
+ ```
79
+
80
+ ## Manual MCP Configuration
81
+
82
+ If auto-registration is unavailable, configure MCP manually.
83
+
84
+ Claude Desktop (`~/Library/Application Support/Claude/claude_desktop_config.json`):
85
+
86
+ ```json
87
+ {
88
+ "mcpServers": {
89
+ "cortex": {
90
+ "command": "cortex",
91
+ "args": ["mcp"],
92
+ "env": {
93
+ "CORTEX_PROJECT_ROOT": "/absolute/path/to/your-project"
94
+ }
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ Codex (`~/.config/codex/mcp-config.json`):
101
+
102
+ ```json
103
+ {
104
+ "mcpServers": {
105
+ "cortex-myproject": {
106
+ "command": "cortex",
107
+ "args": ["mcp"],
108
+ "cwd": "/absolute/path/to/your-project"
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ ## MCP Tools
115
+
116
+ ### `context.search`
117
+
118
+ Ranked context search across indexed entities.
119
+
120
+ Input:
121
+
122
+ - `query` (string, required)
123
+ - `top_k` (int, 1-20, default `5`)
124
+ - `include_deprecated` (bool, default `false`)
125
+ - `include_content` (bool, default `false`)
126
+
127
+ ### `context.get_related`
128
+
129
+ Fetch entity relationships from the graph.
130
+
131
+ Input:
132
+
133
+ - `entity_id` (string, required)
134
+ - `depth` (int, 1-3, default `1`)
135
+ - `include_edges` (bool, default `true`)
136
+
137
+ ### `context.get_rules`
138
+
139
+ List indexed rules and optionally include inactive rules.
140
+
141
+ Input:
142
+
143
+ - `scope` (string, optional)
144
+ - `include_inactive` (bool, default `false`)
145
+
146
+ ### `context.reload`
147
+
148
+ Reload the RyuGraph connection after updates/maintenance.
149
+
150
+ Input:
151
+
152
+ - `force` (bool, default `true`)
153
+
154
+ ## Example Prompts
155
+
156
+ - "Find files that handle authentication."
157
+ - "Show related files for this ADR."
158
+ - "What active architectural rules apply to this API?"
159
+
160
+ ## Common Commands
161
+
162
+ ```text
163
+ cortex init [path] [--force] [--bootstrap] [--connect] [--no-connect] [--watch] [--no-watch]
164
+ cortex connect [path] [--skip-build]
165
+ cortex mcp
166
+ cortex bootstrap
167
+ cortex update
168
+ cortex status
169
+ cortex watch [start|stop|status|run|once] [--interval <sec>] [--debounce <sec>] [--mode <auto|event|poll>]
170
+ cortex note <title> [text]
171
+ cortex plan
172
+ cortex todo [text|list|done <id>|reopen <id>|remove <id>]
173
+ cortex help
174
+ ```
175
+
176
+ ## Limitations
177
+
178
+ - Requires repo initialization (`cortex init --bootstrap`).
179
+ - Each repository has its own local Cortex context instance.
180
+ - No cloud sync by design (privacy-first local storage).
181
+
182
+ ## Security and Privacy
183
+
184
+ - Cortex stores context data locally under `.context/`.
185
+ - No source code upload is required for core functionality.
186
+
187
+ ## Troubleshooting
188
+
189
+ - `mcp/dist/server.js` missing:
190
+ Run `cortex bootstrap` (or re-run `cortex init --bootstrap`).
191
+ - `claude` or `codex` not found during init:
192
+ Auto-registration is skipped; use manual config above.
193
+ - MCP tools return stale context:
194
+ Run `cortex update`, then reconnect MCP or call `context.reload` from your MCP client.
195
+
196
+ ## Support
197
+
198
+ - Issues: https://github.com/DanielBlomma/cortex/issues
199
+ - Marketplace prep notes: [docs/MCP_MARKETPLACE.md](docs/MCP_MARKETPLACE.md)
200
+
201
+ ## License
202
+
203
+ MIT