context-mcp-server 1.0.3 → 1.0.5

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.
@@ -28,22 +28,44 @@ Then:
28
28
 
29
29
  ---
30
30
 
31
- ## 2. During the Conversation
31
+ ## 2. When to Auto-Save Context
32
32
 
33
- | Situation | Action |
34
- |-----------|--------|
35
- | Decision made | `context.save` type: `"decision"` |
36
- | Bug found/fixed | `context.save` type: `"bug"` |
37
- | Architecture understood | `context.save` type: `"architecture"` |
38
- | User says "save/remember this" | `context.save` immediately |
39
- | Feature spans multiple conversations | `discussion.create` or `discussion.update` |
40
- | Need past info | `search` before asking user |
33
+ ### Always save no user prompt needed
41
34
 
42
- Always pass `project`. Auto-compact fires at >50 entries oldest summarized automatically.
35
+ **After graph build or rebuild** every time `codegraph_build` completes:
36
+ ```
37
+ context.save type: "architecture" title: "ContextGraph built — <project>"
38
+ content: "nodes: X | edges: Y | communities: Z"
39
+ ```
40
+
41
+ **User explicitly asks** — any phrase like "save this", "remember this", "note that" → save immediately.
42
+
43
+ **During plan / implementation / discussion / research** — save only when genuinely valuable:
44
+
45
+ | What happened | Type |
46
+ |--------------|------|
47
+ | Approach / library / pattern decided | `decision` |
48
+ | Bug found (root cause known) or fixed | `bug` |
49
+ | System structure understood | `architecture` |
50
+ | Gotcha, constraint, non-obvious behavior | `note` |
51
+ | Config / env var / secret key discovered | `config` |
52
+ | External API or service integration learned | `note` |
53
+ | Performance insight (why something is slow/fast) | `note` |
54
+ | How to run tests / test pattern discovered | `note` |
55
+ | Deploy / release step discovered | `note` |
56
+ | Milestone / feature / task completed | `note` |
57
+
58
+ Do NOT save: routine reads, search results, temporary debugging dead-ends.
59
+
60
+ Feature spans multiple sessions → `discussion.create` or `discussion.update`.
61
+ Need past info → `search` before asking user.
62
+ Always pass `project`. Auto-compact fires at >50 entries.
43
63
 
44
64
  ---
45
65
 
46
- ## 3. CodeGraph Pipeline
66
+ ## 3. ContextGraph Pipeline
67
+
68
+ > The knowledge graph is also called **ContextGraph**. The MCP tools use the `codegraph_*` prefix — both names refer to the same thing.
47
69
 
48
70
  ### Step 1 — Build (once per project, fast, local)
49
71
  ```
@@ -20,22 +20,40 @@ Then:
20
20
 
21
21
  ---
22
22
 
23
- ## 2. During the Conversation
23
+ ## 2. When to Auto-Save Context
24
24
 
25
- | Situation | Action |
26
- |-----------|--------|
27
- | Decision made | `context.save` type: `"decision"` |
28
- | Bug found/fixed | `context.save` type: `"bug"` |
29
- | Architecture understood | `context.save` type: `"architecture"` |
30
- | User says "save/remember this" | `context.save` immediately |
31
- | Feature spans sessions | `discussion.save` then `discussion.update` |
32
- | Need past info | `search` before asking user |
25
+ **After graph build or rebuild** — every time `codegraph_build` completes:
26
+ ```
27
+ context.save type: "architecture" title: "ContextGraph built — <project>"
28
+ content: "nodes: X | edges: Y | communities: Z"
29
+ ```
30
+
31
+ **User explicitly asks** "save this", "remember this", "note that" → save immediately.
33
32
 
34
- Always pass `project`. Auto-compact fires at >50 entries.
33
+ **During plan / implementation / discussion / research** — save only when genuinely valuable:
34
+
35
+ | What happened | Type |
36
+ |--------------|------|
37
+ | Approach / library / pattern decided | `decision` |
38
+ | Bug found (root cause known) or fixed | `bug` |
39
+ | System structure understood | `architecture` |
40
+ | Gotcha, constraint, non-obvious behavior | `note` |
41
+ | Config / env var / secret key discovered | `config` |
42
+ | External API or service integration learned | `note` |
43
+ | Performance insight (why something is slow/fast) | `note` |
44
+ | How to run tests / test pattern discovered | `note` |
45
+ | Deploy / release step discovered | `note` |
46
+ | Milestone / feature / task completed | `note` |
47
+
48
+ Do NOT save: routine reads, search results, temporary debugging dead-ends.
49
+ Feature spans sessions → `discussion.save` then `discussion.update`.
50
+ Need past info → `search` before asking. Always pass `project`.
35
51
 
36
52
  ---
37
53
 
38
- ## 3. CodeGraph Pipeline
54
+ ## 3. ContextGraph Pipeline
55
+
56
+ > The knowledge graph is also called **ContextGraph**. The MCP tools use the `codegraph_*` prefix — both names refer to the same thing.
39
57
 
40
58
  ### Step 1 — Build (once, fast, local)
41
59
  ```
@@ -0,0 +1,8 @@
1
+ Call the `context` MCP tool with `action: "resume"` and `project: "$ARGUMENTS"` (if no argument given, infer the project name from the current working directory name).
2
+
3
+ This loads:
4
+ - Recent decisions, bugs, and notes from past sessions
5
+ - Active discussions
6
+ - ContextGraph status (built or not)
7
+
8
+ If `codegraph.built` is false in the response, immediately call `codegraph_build` on the project path before proceeding.
@@ -0,0 +1,5 @@
1
+ Call `codegraph_build` with the path `$ARGUMENTS` (if no argument given, use the current working directory).
2
+
3
+ This builds the ContextGraph for the project — parses all source files into an AST knowledge graph using tree-sitter. Takes a few seconds. Once built, use `codegraph_query` to answer any structural question about the codebase instead of reading files directly.
4
+
5
+ After build completes, report: total nodes, edges, and communities found.
@@ -0,0 +1,9 @@
1
+ Call the `context` MCP tool with `action: "save"` to store a note for the current project.
2
+
3
+ Parse `$ARGUMENTS` to determine:
4
+ - `project`: infer from current working directory name if not specified
5
+ - `title`: first sentence or phrase from the argument
6
+ - `content`: full argument text
7
+ - `type`: auto-detect — if mentions a bug/fix → `"bug"`, decision/chose/decided → `"decision"`, structure/architecture → `"architecture"`, otherwise `"note"`
8
+
9
+ Confirm to the user what was saved (title, type, project).
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: context-mcp
3
+ description: >
4
+ Persistent memory + ContextGraph (codebase knowledge graph) for Claude.
5
+ Use at the START of every conversation to resume project context. Use
6
+ whenever the user mentions a project, asks to remember/save something,
7
+ references past work, or says "pick up where we left off". Also use
8
+ when the user asks about code structure, dependencies, or what exists
9
+ in a codebase — query the ContextGraph before reading any files.
10
+ ---
11
+
12
+ # Context-MCP
13
+
14
+ Persistent memory + codebase knowledge graph across every conversation.
15
+ `context.resume` starts every session. `codegraph_query` answers every structure question. Files only for bugs/logic.
16
+
17
+ ---
18
+
19
+ ## MANDATORY: Start of Every Conversation
20
+
21
+ Call `context` tool, `action: "resume"`, `project: "<project-name>"` **before any tool or response**.
22
+
23
+ Infer `project` from the working directory name if not stated.
24
+
25
+ Returns:
26
+ - `recentEntries` — decisions, bugs, notes from past sessions
27
+ - `activeDiscussions` — ongoing topics (auto-linked if exactly one active)
28
+ - `codegraph` — `{ built: true/false, nodes, edges, communities }`
29
+
30
+ Then:
31
+ - `codegraph.built: true` → use `codegraph_query` before reading any files
32
+ - `codegraph.built: false` → call `codegraph_build(path)` first, then proceed
33
+
34
+ ---
35
+
36
+ ## When to Auto-Save Context
37
+
38
+ ### Always save — no user prompt needed
39
+
40
+ **1. After graph build or rebuild**
41
+ Every time `codegraph_build` completes successfully, immediately call:
42
+ ```
43
+ context.save type: "architecture" title: "ContextGraph built — <project>"
44
+ content: "nodes: X | edges: Y | communities: Z | built: <timestamp>"
45
+ ```
46
+
47
+ **2. When user explicitly asks**
48
+ Any phrase like "save this", "remember this", "note that", "log this" → `context.save` immediately with whatever was just discussed.
49
+
50
+ **3. During plan / implementation / discussion / research — save when something valuable happens**
51
+ Only save if the moment is genuinely worth keeping across sessions:
52
+ - A decision was made and agreed on (approach, library, pattern, architecture)
53
+ - A bug was found with its root cause identified, or fixed
54
+ - An important discovery (gotcha, constraint, non-obvious behavior, env requirement)
55
+ - A significant milestone reached (feature complete, refactor done, plan finalized)
56
+ - Something that would save future-you from re-learning it
57
+
58
+ Do NOT save for: routine file reads, search results, explanations of existing code, temporary debugging steps that led nowhere.
59
+
60
+ | What happened | Type |
61
+ |--------------|------|
62
+ | Approach / library / pattern decided | `decision` |
63
+ | Bug found (root cause known) or fixed | `bug` |
64
+ | System structure understood | `architecture` |
65
+ | Gotcha, constraint, non-obvious behavior | `note` |
66
+ | Config / env var / secret key discovered | `config` |
67
+ | External API or service integration learned | `note` |
68
+ | Performance insight (why something is slow/fast) | `note` |
69
+ | How to run tests / test pattern discovered | `note` |
70
+ | Deploy / release step discovered | `note` |
71
+ | Milestone / feature / task completed | `note` |
72
+
73
+ Always pass `project`. Feature spans multiple sessions → `discussion.create` or `discussion.update`. Need past info → `search` before asking user. Auto-compact fires at >50 entries.
74
+
75
+ ---
76
+
77
+ ## ContextGraph Pipeline
78
+
79
+ > Also called **CodeGraph**. MCP tools use the `codegraph_*` prefix — both names mean the same thing.
80
+
81
+ ### Build (once per project, ~seconds, local)
82
+ ```
83
+ codegraph_build(path)
84
+ ```
85
+ Parses codebase into AST graph via tree-sitter. Extracts functions, classes, imports, call edges for 16+ languages. Build files get a single metadata node. Saved to `~/.context-mcp/graphs.json`.
86
+
87
+ ### Query (free, instant, forever)
88
+ ```
89
+ codegraph_query(path, question) → find functions, classes, files, dependencies, callers
90
+ codegraph_explain(path, node) → one node: type, file, depends_on, used_by
91
+ codegraph_path(path, from, to) → shortest path between two concepts
92
+ codegraph_nodes(path, type) → list all nodes of a type
93
+ codegraph_report(path) → god nodes, clusters, surprises
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Graph vs File
99
+
100
+ **Graph** — what exists: finding functions, classes, files, dependencies, callers, imports, paths between concepts.
101
+
102
+ **File** — bugs, logic inside a specific function, tracing unexpected behavior.
103
+
104
+ ---
105
+
106
+ ## Rules
107
+
108
+ 1. **`context.resume` first** — before any tool or response
109
+ 2. **Always pass `project`** — never save to global unless truly cross-project
110
+ 3. **`search` before asking** — if user references past work, find it first
111
+ 4. **`codegraph_query` before reading files** — graph is faster and cheaper
112
+ 5. **Read files for bugs/logic only** — graph is structure, not behavior