opencontext-mcp 1.1.0 → 1.2.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.
- package/README.md +94 -156
- package/dist/config.js +33 -2
- package/dist/config.js.map +1 -1
- package/dist/context-store.d.ts +13 -0
- package/dist/context-store.js +114 -14
- package/dist/context-store.js.map +1 -1
- package/dist/server.js +24 -0
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,50 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://opencntx.dev">
|
|
3
|
+
<img src="https://github.com/slxca/opencontext/blob/master/apps/web/public/opencontext.png?raw=true" alt="OpenContext logo" width="500">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
[](https://www.typescriptlang.org/)
|
|
5
|
-
[](https://nodejs.org/)
|
|
6
|
-
[](https://opencntx.dev/)
|
|
7
|
-
[](LICENSE)
|
|
7
|
+
<p align="center"><b>Persistent, project-local memory for AI coding agents.</b></p>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://opencntx.dev"><img alt="Website" src="https://img.shields.io/badge/website-opencntx.dev-191919?style=flat-square" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/opencontext-mcp"><img alt="npm version" src="https://img.shields.io/npm/v/opencontext-mcp?style=flat-square" /></a>
|
|
12
|
+
<a href="https://github.com/slxca/opencontext/actions"><img alt="CI status" src="https://img.shields.io/github/actions/workflow/status/slxca/opencontext/ci.yml?style=flat-square&branch=master" /></a>
|
|
13
|
+
</p>
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
---
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
Most coding agents lose critical decisions between sessions: architecture invariants, API contracts, rejected patterns, and setup quirks. OpenContext solves context loss through a lightweight Model Context Protocol (MCP) server that lets agents read and mutate durable markdown files inside `.opencontext/`.
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
No vector databases, no cloud subscriptions, and no hidden state. Memory is plain markdown tracked directly in Git.
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
- `read_context`: read one saved topic or list all available topics
|
|
19
|
-
- **Auto-Index**: automatic `index.md` generation with topic metadata
|
|
20
|
-
- **Write Guard**: input validation, size limits, and prompt injection protection
|
|
21
|
-
- **Config System**: customizable via `.opencontext.jsonc` or `.opencontext.json`
|
|
22
|
-
- Project-specific storage based on the client's current working directory
|
|
23
|
-
- No database, account, cloud sync, or hidden state
|
|
24
|
-
- Works with MCP-compatible clients over stdio
|
|
25
|
-
- Built with strict TypeScript and the official `@modelcontextprotocol/sdk`
|
|
21
|
+
---
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
### Quickstart
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
Run directly without installation via `npx`:
|
|
30
26
|
|
|
31
27
|
```bash
|
|
32
28
|
npx -y opencontext-mcp
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
For local development in this repository:
|
|
36
29
|
|
|
37
|
-
```bash
|
|
38
|
-
pnpm install
|
|
39
|
-
pnpm build
|
|
40
|
-
pnpm start
|
|
41
30
|
```
|
|
42
31
|
|
|
43
|
-
|
|
32
|
+
### Client Setup
|
|
44
33
|
|
|
45
|
-
|
|
34
|
+
#### OpenCode
|
|
46
35
|
|
|
47
|
-
Add OpenContext
|
|
36
|
+
Add OpenContext to your project MCP configuration (`opencode.json`):
|
|
48
37
|
|
|
49
38
|
```json
|
|
50
39
|
{
|
|
@@ -56,11 +45,12 @@ Add OpenContext MCP to your OpenCode MCP configuration:
|
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
47
|
}
|
|
48
|
+
|
|
59
49
|
```
|
|
60
50
|
|
|
61
|
-
|
|
51
|
+
#### Cursor / Claude Desktop / Windsurf
|
|
62
52
|
|
|
63
|
-
|
|
53
|
+
Add OpenContext to your MCP settings file (`claude_desktop_config.json` or Cursor MCP settings):
|
|
64
54
|
|
|
65
55
|
```json
|
|
66
56
|
{
|
|
@@ -71,168 +61,116 @@ Cursor and Claude Desktop use the same MCP server configuration:
|
|
|
71
61
|
}
|
|
72
62
|
}
|
|
73
63
|
}
|
|
74
|
-
```
|
|
75
64
|
|
|
76
|
-
|
|
65
|
+
```
|
|
77
66
|
|
|
78
|
-
|
|
67
|
+
---
|
|
79
68
|
|
|
80
|
-
|
|
69
|
+
### Core Tools
|
|
81
70
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
| Tool | Parameters | Description |
|
|
72
|
+
| --- | --- | --- |
|
|
73
|
+
| `read_context` | `topic?` *(optional string)* | Reads a specific context topic, or returns the lightweight topic index (~100 tokens) if omitted. |
|
|
74
|
+
| `save_context` | `topic` *(string)*, `content` *(string)* | Writes or mutates markdown memory inside `.opencontext/<topic>.md` with built-in write guards and symlink protections. |
|
|
75
|
+
| `delete_context` | `topic` *(string)* | Removes an obsolete topic file and automatically rebuilds the topic index. |
|
|
86
76
|
|
|
87
|
-
|
|
88
|
-
"readOnly": false,
|
|
77
|
+
---
|
|
89
78
|
|
|
90
|
-
|
|
91
|
-
"disabled": false,
|
|
79
|
+
### ADR Lifecycle & Frontmatter
|
|
92
80
|
|
|
93
|
-
|
|
94
|
-
"autoIndex": true,
|
|
81
|
+
Topics support optional YAML frontmatter to track lifecycle status — useful when architectural decisions evolve and old context should be visible but clearly flagged as outdated.
|
|
95
82
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
83
|
+
````markdown
|
|
84
|
+
---
|
|
85
|
+
description: OAuth2 + PKCE authentication flow
|
|
86
|
+
status: active
|
|
87
|
+
supersedes: auth_v1
|
|
88
|
+
---
|
|
102
89
|
|
|
103
|
-
|
|
104
|
-
"history": {
|
|
105
|
-
"enabled": false,
|
|
106
|
-
"maxBackupsPerTopic": 5,
|
|
107
|
-
"retentionDays": 7
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
```
|
|
90
|
+
# Authentication v2
|
|
111
91
|
|
|
112
|
-
|
|
92
|
+
Migrated from JWT to OAuth2 with PKCE.
|
|
93
|
+
````
|
|
113
94
|
|
|
114
|
-
|
|
95
|
+
**Supported frontmatter keys:**
|
|
115
96
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
97
|
+
| Key | Values | Description |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| `description` | string | Short summary used in the auto-generated index. |
|
|
100
|
+
| `status` | `active` \| `deprecated` \| `superseded` | Lifecycle status. Defaults to `active` when omitted. |
|
|
101
|
+
| `supersedes` | string | Topic name this topic replaces *(set on the newer topic)*. |
|
|
102
|
+
| `superseded_by` | string | Topic name that replaced this one *(set on the older topic)*. |
|
|
122
103
|
|
|
123
|
-
|
|
104
|
+
Non-active topics automatically receive `[DEPRECATED]` or `[SUPERSEDED]` badges in the auto-generated `index.md`, along with cross-references showing which topic replaced or was replaced.
|
|
124
105
|
|
|
125
|
-
|
|
106
|
+
---
|
|
126
107
|
|
|
127
|
-
|
|
108
|
+
### Agent Workflows
|
|
128
109
|
|
|
129
|
-
|
|
110
|
+
Instruct your agents to automatically leverage project context. Add this snippet to your `.cursorrules`, `CLAUDE.md`, or system prompt:
|
|
130
111
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
| `topic` | string | yes | Lowercase snake_case or kebab-case topic name |
|
|
134
|
-
| `content` | string | yes | Markdown content to save |
|
|
112
|
+
```markdown
|
|
113
|
+
Before making structural code changes, run `read_context` to inspect existing project topics and architectural decisions.
|
|
135
114
|
|
|
136
|
-
|
|
115
|
+
Whenever a new architectural convention, database schema, or API rule is established or refactored, call `save_context` with a concise, topic-scoped markdown summary. Use YAML frontmatter (status, supersedes) when updating conventions to track lifecycle changes.
|
|
137
116
|
|
|
138
|
-
|
|
139
|
-
Save our API conventions under topic api-contracts.
|
|
117
|
+
When a topic becomes obsolete, call `delete_context` to remove it. For deprecated topics that should remain visible, set status: deprecated or status: superseded in the frontmatter instead of deleting.
|
|
140
118
|
```
|
|
141
119
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
Reads one saved topic, or lists all topics when no topic is provided.
|
|
120
|
+
---
|
|
145
121
|
|
|
146
|
-
|
|
122
|
+
### Configuration
|
|
147
123
|
|
|
148
|
-
|
|
149
|
-
| ------- | ------ | -------- | ------------- |
|
|
150
|
-
| `topic` | string | no | Topic to read |
|
|
151
|
-
|
|
152
|
-
Example use:
|
|
153
|
-
|
|
154
|
-
```text
|
|
155
|
-
Read the architecture context before changing the routing layer.
|
|
156
|
-
```
|
|
124
|
+
Customize storage paths and security boundaries with an optional `.opencontext.jsonc` file in your repository root:
|
|
157
125
|
|
|
158
|
-
|
|
126
|
+
```jsonc
|
|
127
|
+
{
|
|
128
|
+
// Storage location (default: ".opencontext")
|
|
129
|
+
"path": ".opencontext",
|
|
159
130
|
|
|
160
|
-
|
|
131
|
+
// Prevent agents from writing or updating files
|
|
132
|
+
"readOnly": false,
|
|
161
133
|
|
|
162
|
-
|
|
163
|
-
|
|
134
|
+
// Auto-generate index.md with topic descriptions
|
|
135
|
+
"autoIndex": true,
|
|
164
136
|
|
|
165
|
-
|
|
137
|
+
// Write guard & prompt injection defenses
|
|
138
|
+
"guard": {
|
|
139
|
+
"enabled": true,
|
|
140
|
+
"maxFileSizeKb": 50,
|
|
141
|
+
"strictPatternCheck": true
|
|
142
|
+
}
|
|
143
|
+
}
|
|
166
144
|
|
|
167
|
-
Prefer small, focused context topics in snake_case or kebab-case. Keep the content concise, factual, and written in markdown.
|
|
168
145
|
```
|
|
169
146
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
1. Ask an architect or planning agent to analyze the project and save durable decisions with `save_context`.
|
|
173
|
-
2. Ask build agents to call `read_context` before coding.
|
|
174
|
-
3. Let agents update context when they discover something that should survive the current chat.
|
|
175
|
-
4. Review `.opencontext/` files like normal project documentation.
|
|
147
|
+
---
|
|
176
148
|
|
|
177
|
-
|
|
149
|
+
### Local Development
|
|
178
150
|
|
|
179
|
-
|
|
151
|
+
```bash
|
|
152
|
+
# Clone and install dependencies
|
|
153
|
+
git clone [https://github.com/slxca/opencontext.git](https://github.com/slxca/opencontext.git)
|
|
154
|
+
cd opencontext
|
|
155
|
+
pnpm install
|
|
180
156
|
|
|
181
|
-
|
|
157
|
+
# Build & run tests
|
|
158
|
+
pnpm build
|
|
159
|
+
pnpm test
|
|
182
160
|
|
|
183
|
-
```bash
|
|
184
|
-
git add .opencontext
|
|
185
161
|
```
|
|
186
162
|
|
|
187
|
-
|
|
163
|
+
---
|
|
188
164
|
|
|
189
|
-
|
|
190
|
-
.opencontext/
|
|
191
|
-
```
|
|
165
|
+
### Documentation
|
|
192
166
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
## Project Structure
|
|
196
|
-
|
|
197
|
-
```text
|
|
198
|
-
opencontext/
|
|
199
|
-
├── packages/
|
|
200
|
-
│ └── opencontext/ # MCP server package
|
|
201
|
-
│ ├── src/
|
|
202
|
-
│ │ ├── index.ts # CLI entrypoint (stdio transport)
|
|
203
|
-
│ │ ├── server.ts # McpServer factory and tool registration
|
|
204
|
-
│ │ ├── config.ts # Config loading (.opencontext.jsonc)
|
|
205
|
-
│ │ ├── context-store.ts # Filesystem operations for .opencontext/
|
|
206
|
-
│ │ ├── validation.ts # Topic validation and write guard
|
|
207
|
-
│ │ └── types.ts # Shared constants and error helpers
|
|
208
|
-
│ └── test/
|
|
209
|
-
│ ├── context-store.test.ts
|
|
210
|
-
│ ├── validation.test.ts
|
|
211
|
-
│ ├── guard.test.ts
|
|
212
|
-
│ └── auto-index.test.ts
|
|
213
|
-
├── apps/
|
|
214
|
-
│ └── web/ # Website (Next.js)
|
|
215
|
-
│ └── src/
|
|
216
|
-
│ ├── app/
|
|
217
|
-
│ │ ├── page.tsx # Landing page
|
|
218
|
-
│ │ ├── docs/ # Documentation
|
|
219
|
-
│ │ ├── imprint/
|
|
220
|
-
│ │ └── privacy-policy/
|
|
221
|
-
│ └── components/
|
|
222
|
-
├── CONTRIBUTING.md
|
|
223
|
-
├── SECURITY.md
|
|
224
|
-
└── README.md
|
|
225
|
-
```
|
|
167
|
+
For advanced setup guides, guard parameters, and agent prompt templates, visit **[opencntx.dev/docs](https://www.google.com/search?q=https://opencntx.dev/docs)**.
|
|
226
168
|
|
|
227
|
-
|
|
169
|
+
### Contributing
|
|
228
170
|
|
|
229
|
-
|
|
230
|
-
pnpm install
|
|
231
|
-
pnpm build # compile all packages
|
|
232
|
-
pnpm typecheck # type-check without emitting
|
|
233
|
-
pnpm test # run vitest suite
|
|
234
|
-
```
|
|
171
|
+
Contributions are welcome. Please ensure all unit tests and typechecks pass before submitting a pull request:
|
|
235
172
|
|
|
236
|
-
|
|
173
|
+
```bash
|
|
174
|
+
pnpm typecheck && pnpm test
|
|
237
175
|
|
|
238
|
-
|
|
176
|
+
```
|
package/dist/config.js
CHANGED
|
@@ -20,6 +20,7 @@ const CONFIG_CANDIDATES = [".opencontext.jsonc", ".opencontext.json"];
|
|
|
20
20
|
/**
|
|
21
21
|
* Strips JSONC content into parseable JSON by removing comments and trailing commas.
|
|
22
22
|
* Handles single-line (//), multi-line (/* * /), and trailing commas.
|
|
23
|
+
* Trailing comma removal is token-aware to avoid modifying string literals.
|
|
23
24
|
*/
|
|
24
25
|
function stripJsonComments(raw) {
|
|
25
26
|
let result = "";
|
|
@@ -63,11 +64,41 @@ function stripJsonComments(raw) {
|
|
|
63
64
|
i += 2; // skip */
|
|
64
65
|
continue;
|
|
65
66
|
}
|
|
67
|
+
// Trailing comma: skip comma if followed by optional whitespace/comments then } or ]
|
|
68
|
+
if (ch === ",") {
|
|
69
|
+
let j = i + 1;
|
|
70
|
+
// Skip whitespace and comments to find the next meaningful token
|
|
71
|
+
while (j < len) {
|
|
72
|
+
if (raw[j] === " " || raw[j] === "\t" || raw[j] === "\n" || raw[j] === "\r") {
|
|
73
|
+
j++;
|
|
74
|
+
}
|
|
75
|
+
else if (raw[j] === "/" && j + 1 < len && raw[j + 1] === "/") {
|
|
76
|
+
while (j < len && raw[j] !== "\n")
|
|
77
|
+
j++;
|
|
78
|
+
}
|
|
79
|
+
else if (raw[j] === "/" && j + 1 < len && raw[j + 1] === "*") {
|
|
80
|
+
j += 2;
|
|
81
|
+
while (j < len - 1 && !(raw[j] === "*" && raw[j + 1] === "/"))
|
|
82
|
+
j++;
|
|
83
|
+
j += 2;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (j < len && (raw[j] === "}" || raw[j] === "]")) {
|
|
90
|
+
i = j; // skip comma and whitespace/comments, continue from closing bracket
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
// Not a trailing comma — keep it
|
|
94
|
+
result += ch;
|
|
95
|
+
i++;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
66
98
|
result += ch;
|
|
67
99
|
i++;
|
|
68
100
|
}
|
|
69
|
-
|
|
70
|
-
return result.replace(/,(\s*[}\]])/g, "$1");
|
|
101
|
+
return result;
|
|
71
102
|
}
|
|
72
103
|
function deepMerge(target, source) {
|
|
73
104
|
const result = { ...target };
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAsBlC,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE,cAAc;IACpB,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,IAAI;IACf,OAA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AE,QAAQ,CAAC,CAAC;QAC1C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC7C,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB,CAAC;YACxD,OAAO,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACvD,SAAS,CAAC,yCAAyC;YACrD,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,gCAAgC,QAAQ,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACvF,OAAO,cAAc,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
package/dist/context-store.d.ts
CHANGED
|
@@ -28,12 +28,25 @@ export declare class ContextStore {
|
|
|
28
28
|
* @throws UserInputError if topic doesn't exist or is invalid
|
|
29
29
|
*/
|
|
30
30
|
readContext(topicInput?: string): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Deletes a context topic file from the context directory.
|
|
33
|
+
* @param topicInput - Topic name to delete
|
|
34
|
+
* @returns Success message with confirmation
|
|
35
|
+
* @throws UserInputError if topic doesn't exist or is invalid
|
|
36
|
+
*/
|
|
37
|
+
deleteContext(topicInput: string): Promise<string>;
|
|
31
38
|
/**
|
|
32
39
|
* Lists all available context topics.
|
|
33
40
|
* Scans the context directory for .md files and returns sorted topic names.
|
|
34
41
|
* @returns Sorted array of topic names
|
|
35
42
|
*/
|
|
36
43
|
listTopics(): Promise<string[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Parses YAML frontmatter from markdown content.
|
|
46
|
+
* Returns extracted fields or empty object if no frontmatter found.
|
|
47
|
+
* Uses simple line-by-line parsing — no external YAML dependency.
|
|
48
|
+
*/
|
|
49
|
+
private parseFrontmatter;
|
|
37
50
|
/**
|
|
38
51
|
* Extracts a short description from markdown content.
|
|
39
52
|
* Strategy: frontmatter description → first heading → first paragraph → fallback.
|
package/dist/context-store.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { mkdir, readdir, readFile, writeFile, stat } from "node:fs/promises";
|
|
1
|
+
import { mkdir, readdir, readFile, writeFile, stat, lstat, unlink } from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import { INDEX_FILENAME, UserInputError, isNodeError } from "./types.js";
|
|
3
|
+
import { INDEX_FILENAME, UserInputError, isNodeError, STATUS_BADGES } from "./types.js";
|
|
4
4
|
import { validateTopic, validateWritePayload, sanitizeTopicPath } from "./validation.js";
|
|
5
5
|
import { DEFAULT_CONFIG } from "./config.js";
|
|
6
6
|
/**
|
|
@@ -43,6 +43,21 @@ export class ContextStore {
|
|
|
43
43
|
}
|
|
44
44
|
const topic = validateTopic(topicInput);
|
|
45
45
|
const filePath = sanitizeTopicPath(this.contextDir, topic);
|
|
46
|
+
// Reject writes to existing symlinks — prevents symlink traversal attacks
|
|
47
|
+
try {
|
|
48
|
+
const fileStat = await lstat(filePath);
|
|
49
|
+
if (fileStat.isSymbolicLink()) {
|
|
50
|
+
throw new UserInputError(`Refusing to overwrite symlink at ${this.config.path}/${topic}.md. Delete the symlink first.`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
55
|
+
// File does not exist yet — normal case, continue
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
46
61
|
await mkdir(this.contextDir, { recursive: true });
|
|
47
62
|
await writeFile(filePath, content, "utf8");
|
|
48
63
|
return `Saved context topic "${topic}" to ${this.config.path}/${topic}.md.`;
|
|
@@ -71,8 +86,34 @@ export class ContextStore {
|
|
|
71
86
|
if (topics.length === 0) {
|
|
72
87
|
return `No OpenContext topics found in ${this.config.path}/. Use save_context to create one.`;
|
|
73
88
|
}
|
|
89
|
+
if (!this.config.autoIndex) {
|
|
90
|
+
return topics.map((t) => `- ${t}`).join("\n");
|
|
91
|
+
}
|
|
74
92
|
return this.rebuildContextIndex();
|
|
75
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Deletes a context topic file from the context directory.
|
|
96
|
+
* @param topicInput - Topic name to delete
|
|
97
|
+
* @returns Success message with confirmation
|
|
98
|
+
* @throws UserInputError if topic doesn't exist or is invalid
|
|
99
|
+
*/
|
|
100
|
+
async deleteContext(topicInput) {
|
|
101
|
+
const topic = validateTopic(topicInput);
|
|
102
|
+
const filePath = sanitizeTopicPath(this.contextDir, topic);
|
|
103
|
+
try {
|
|
104
|
+
await unlink(filePath);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
108
|
+
throw new UserInputError(`No context found for topic "${topic}" at ${this.config.path}/${topic}.md.`);
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
if (this.config.autoIndex) {
|
|
113
|
+
await this.rebuildContextIndex();
|
|
114
|
+
}
|
|
115
|
+
return `Deleted context topic "${topic}" from ${this.config.path}/${topic}.md.`;
|
|
116
|
+
}
|
|
76
117
|
/**
|
|
77
118
|
* Lists all available context topics.
|
|
78
119
|
* Scans the context directory for .md files and returns sorted topic names.
|
|
@@ -93,6 +134,52 @@ export class ContextStore {
|
|
|
93
134
|
throw error;
|
|
94
135
|
}
|
|
95
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Parses YAML frontmatter from markdown content.
|
|
139
|
+
* Returns extracted fields or empty object if no frontmatter found.
|
|
140
|
+
* Uses simple line-by-line parsing — no external YAML dependency.
|
|
141
|
+
*/
|
|
142
|
+
parseFrontmatter(content) {
|
|
143
|
+
const trimmed = content.trim();
|
|
144
|
+
if (!trimmed.startsWith("---")) {
|
|
145
|
+
return {};
|
|
146
|
+
}
|
|
147
|
+
const endIdx = trimmed.indexOf("---", 3);
|
|
148
|
+
if (endIdx === -1) {
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
const block = trimmed.slice(3, endIdx);
|
|
152
|
+
const result = {};
|
|
153
|
+
for (const line of block.split("\n")) {
|
|
154
|
+
const trimmedLine = line.trim();
|
|
155
|
+
if (!trimmedLine || trimmedLine.startsWith("#"))
|
|
156
|
+
continue;
|
|
157
|
+
const colonIdx = trimmedLine.indexOf(":");
|
|
158
|
+
if (colonIdx === -1)
|
|
159
|
+
continue;
|
|
160
|
+
const key = trimmedLine.slice(0, colonIdx).trim();
|
|
161
|
+
let value = trimmedLine.slice(colonIdx + 1).trim();
|
|
162
|
+
// Strip surrounding quotes
|
|
163
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
164
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
165
|
+
value = value.slice(1, -1);
|
|
166
|
+
}
|
|
167
|
+
if (key === "description") {
|
|
168
|
+
result.description = value;
|
|
169
|
+
}
|
|
170
|
+
else if (key === "status" &&
|
|
171
|
+
(value === "active" || value === "deprecated" || value === "superseded")) {
|
|
172
|
+
result.status = value;
|
|
173
|
+
}
|
|
174
|
+
else if (key === "supersedes") {
|
|
175
|
+
result.supersedes = value;
|
|
176
|
+
}
|
|
177
|
+
else if (key === "superseded_by") {
|
|
178
|
+
result.superseded_by = value;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
96
183
|
/**
|
|
97
184
|
* Extracts a short description from markdown content.
|
|
98
185
|
* Strategy: frontmatter description → first heading → first paragraph → fallback.
|
|
@@ -104,16 +191,10 @@ export class ContextStore {
|
|
|
104
191
|
if (!trimmed) {
|
|
105
192
|
return "No summary available.";
|
|
106
193
|
}
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const frontmatter = trimmed.slice(3, endIdx);
|
|
112
|
-
const descMatch = frontmatter.match(/description:\s*["']?(.+?)["']?\s*$/m);
|
|
113
|
-
if (descMatch?.[1]) {
|
|
114
|
-
return descMatch[1].slice(0, 120);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
194
|
+
// Use structured frontmatter parser
|
|
195
|
+
const fm = this.parseFrontmatter(content);
|
|
196
|
+
if (fm.description) {
|
|
197
|
+
return fm.description.slice(0, 120);
|
|
117
198
|
}
|
|
118
199
|
const lines = trimmed.split("\n");
|
|
119
200
|
// Strategy B: First heading
|
|
@@ -166,7 +247,17 @@ export class ContextStore {
|
|
|
166
247
|
const description = this.extractDescription(content);
|
|
167
248
|
const date = fileStat.mtime.toISOString().slice(0, 10);
|
|
168
249
|
const sizeBytes = Buffer.byteLength(content, "utf8");
|
|
169
|
-
|
|
250
|
+
const fm = this.parseFrontmatter(content);
|
|
251
|
+
topicEntries.push({
|
|
252
|
+
topic,
|
|
253
|
+
filename: entry.name,
|
|
254
|
+
description,
|
|
255
|
+
date,
|
|
256
|
+
sizeBytes,
|
|
257
|
+
status: fm.status,
|
|
258
|
+
supersedes: fm.supersedes,
|
|
259
|
+
superseded_by: fm.superseded_by,
|
|
260
|
+
});
|
|
170
261
|
}
|
|
171
262
|
const lines = [
|
|
172
263
|
"# Project Context Index",
|
|
@@ -179,7 +270,16 @@ export class ContextStore {
|
|
|
179
270
|
const sizeStr = t.sizeBytes >= 1024
|
|
180
271
|
? `${(t.sizeBytes / 1024).toFixed(1)} KB`
|
|
181
272
|
: `${t.sizeBytes} B`;
|
|
182
|
-
|
|
273
|
+
const badge = t.status && t.status !== "active"
|
|
274
|
+
? ` ${STATUS_BADGES.get(t.status) ?? `[${t.status.toUpperCase()}]`}`
|
|
275
|
+
: "";
|
|
276
|
+
const supersedesNote = t.supersedes
|
|
277
|
+
? ` (supersedes: \`${t.supersedes}\`)`
|
|
278
|
+
: "";
|
|
279
|
+
const supersededByNote = t.superseded_by
|
|
280
|
+
? ` (superseded by: \`${t.superseded_by}\`)`
|
|
281
|
+
: "";
|
|
282
|
+
lines.push(`- **${t.topic}**${badge} (\`${t.filename}\`) - Updated: ${t.date} (${sizeStr})${supersedesNote}${supersededByNote}`);
|
|
183
283
|
lines.push(` > ${t.description}`);
|
|
184
284
|
}
|
|
185
285
|
lines.push("");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-store.js","sourceRoot":"","sources":["../src/context-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"context-store.js","sourceRoot":"","sources":["../src/context-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAA2C,MAAM,YAAY,CAAC;AACjI,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAuB,cAAc,EAAE,MAAM,aAAa,CAAC;AAElE;;;GAGG;AACH,MAAM,OAAO,YAAY;IAIJ;IACA;IAJF,UAAU,CAAS;IAEpC,YACmB,WAAmB,OAAO,CAAC,GAAG,EAAE,EAChC,SAAyB,cAAc;QADvC,aAAQ,GAAR,QAAQ,CAAwB;QAChC,WAAM,GAAN,MAAM,CAAiC;QAExD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,0DA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sB,CAAC,CAAC,aAAa,KAAK;gBAC5C,CAAC,CAAC,EAAE,CAAC;YACP,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,OAAO,CAAC,CAAC,QAAQ,kBAAkB,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,cAAc,GAAG,gBAAgB,EAAE,CAAC,CAAC;YACjI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QACrC,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;QAC3F,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEf,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAC7D,MAAM,SAAS,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAEjD,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
package/dist/server.js
CHANGED
|
@@ -63,6 +63,30 @@ export async function createOpenContextServer(basePath, config) {
|
|
|
63
63
|
return textResult(`OpenContext error: ${getErrorMessage(error)}`, true);
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
+
server.registerTool("delete_context", {
|
|
67
|
+
title: "Delete Context",
|
|
68
|
+
description: "Delete a saved OpenContext topic. The topic file will be removed from disk.",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
topic: z
|
|
71
|
+
.string()
|
|
72
|
+
.min(1)
|
|
73
|
+
.describe("Topic name in snake_case or kebab-case to delete."),
|
|
74
|
+
},
|
|
75
|
+
}, async ({ topic }) => {
|
|
76
|
+
if (resolvedConfig.disabled) {
|
|
77
|
+
return textResult("OpenContext is currently paused. Tool access is disabled via configuration.");
|
|
78
|
+
}
|
|
79
|
+
if (resolvedConfig.readOnly) {
|
|
80
|
+
return textResult("OpenContext is in read-only mode. Write operations are disabled via configuration.", true);
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const result = await store.deleteContext(topic);
|
|
84
|
+
return textResult(result);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return textResult(`OpenContext error: ${getErrorMessage(error)}`, true);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
66
90
|
return server;
|
|
67
91
|
}
|
|
68
92
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAAiB,EACjB,MAAuB;IAEvB,MAAM,cAAc,GAAG,MAAM,IAAI,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,cAAc;KACxB,CAAC,CAAC;IAEH,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,4EAA4E,cAAc,C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M,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,UAAU,CAAC,sBAAsB,eAAe,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,6EAA6E;QAC/E,WAAW,EAAE;YACX,KAAK,EAAE,CAAC;iBACL,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CACP,mDAAmD,CACpD;SACJ;KACF,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAClB,IAAI,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,UAAU,CAAC,6EAA6E,CAAC,CAAC;QACnG,CAAC;QACD,IAAI,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,UAAU,CAAC,oFAAoF,EAAE,IAAI,CAAC,CAAC;QAChH,CAAC;QACD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAChD,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,UAAU,CAAC,sBAAsB,eAAe,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
/** MCP server identifier used in protocol handshakes. */
|
|
2
2
|
export declare const SERVER_NAME = "opencontext-mcp";
|
|
3
3
|
/** Current server version for compatibility checks. */
|
|
4
|
-
export declare const SERVER_VERSION = "1.
|
|
4
|
+
export declare const SERVER_VERSION = "1.2.0";
|
|
5
5
|
/** Filename for the auto-generated context index. */
|
|
6
6
|
export declare const INDEX_FILENAME = "index.md";
|
|
7
7
|
/** Topic names reserved by the system — cannot be written by external agents. */
|
|
8
8
|
export declare const RESERVED_TOPICS: ReadonlySet<string>;
|
|
9
|
+
/** Allowed values for the topic status field in YAML frontmatter. */
|
|
10
|
+
export type TopicStatus = "active" | "deprecated" | "superseded";
|
|
11
|
+
/** Parsed YAML frontmatter from a topic file. All fields optional. */
|
|
12
|
+
export interface TopicFrontmatter {
|
|
13
|
+
description?: string;
|
|
14
|
+
status?: TopicStatus;
|
|
15
|
+
/** The topic this one replaces (used by the newer topic). */
|
|
16
|
+
supersedes?: string;
|
|
17
|
+
/** The topic that replaced this one (used by the older topic). */
|
|
18
|
+
superseded_by?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Badge prefix used in index.md for non-active topics. */
|
|
21
|
+
export declare const STATUS_BADGES: ReadonlyMap<TopicStatus, string>;
|
|
9
22
|
/**
|
|
10
23
|
* Regex pattern for validating topic names.
|
|
11
24
|
* Allows lowercase alphanumeric with single hyphens or underscores as separators.
|
package/dist/types.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/** MCP server identifier used in protocol handshakes. */
|
|
2
2
|
export const SERVER_NAME = "opencontext-mcp";
|
|
3
3
|
/** Current server version for compatibility checks. */
|
|
4
|
-
export const SERVER_VERSION = "1.
|
|
4
|
+
export const SERVER_VERSION = "1.2.0";
|
|
5
5
|
/** Filename for the auto-generated context index. */
|
|
6
6
|
export const INDEX_FILENAME = "index.md";
|
|
7
7
|
/** Topic names reserved by the system — cannot be written by external agents. */
|
|
8
8
|
export const RESERVED_TOPICS = new Set(["index"]);
|
|
9
|
+
/** Badge prefix used in index.md for non-active topics. */
|
|
10
|
+
export const STATUS_BADGES = new Map([
|
|
11
|
+
["deprecated", "[DEPRECATED]"],
|
|
12
|
+
["superseded", "[SUPERSEDED]"],
|
|
13
|
+
]);
|
|
9
14
|
/**
|
|
10
15
|
* Regex pattern for validating topic names.
|
|
11
16
|
* Allows lowercase alphanumeric with single hyphens or underscores as separators.
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE7C,uDAAuD;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,qDAAqD;AACrD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE7C,uDAAuD;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,qDAAqD;AACrD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAevE,2DAA2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAqC,IAAI,GAAG,CAAC;IACrE,CAAC,YAAY,EAAE,cAAc,CAAC;IAC9B,CAAC,YAAY,EAAE,cAAc,CAAC;CAC/B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,+BAA+B,CAAC;AAE7D;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED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