@contextos/mcp 0.1.0 → 0.3.1
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/.turbo/turbo-build.log +3 -3
- package/README.md +137 -61
- package/dist/index.js +4 -1
- package/package.json +37 -33
- package/src/provider.ts +6 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @contextos/mcp@0.
|
|
2
|
+
> @contextos/mcp@0.3.0 build C:\Users\ixayl\Desktop\ContextOS\ContextOS\packages\mcp
|
|
3
3
|
> tsup src/index.ts --format esm --clean
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mCLI[39m Cleaning output folder
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist\index.js [22m[32m19.
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist\index.js [22m[32m19.69 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 338ms
|
package/README.md
CHANGED
|
@@ -1,63 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @contextos/mcp
|
|
2
2
|
|
|
3
|
-
Model Context Protocol
|
|
3
|
+
**Model Context Protocol server for ContextOS**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@contextos/mcp)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
AI can perform these actions:
|
|
7
|
+
Enables AI coding tools to access ContextOS's optimized context through the [Model Context Protocol](https://modelcontextprotocol.io/).
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|------|-------------|
|
|
12
|
-
| `contextos_build` | Build optimized context for a goal |
|
|
13
|
-
| `contextos_analyze` | Deep RLM-powered analysis |
|
|
14
|
-
| `contextos_find` | Find files by pattern |
|
|
15
|
-
| `contextos_deps` | Get file dependencies |
|
|
16
|
-
| `contextos_explain` | Get file explanation |
|
|
17
|
-
| `contextos_status` | Check ContextOS status |
|
|
9
|
+
## 🎯 Supported Tools
|
|
18
10
|
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
| Tool | Integration |
|
|
12
|
+
|------|-------------|
|
|
13
|
+
| Claude Desktop | ✅ Native MCP |
|
|
14
|
+
| Claude Code CLI | ✅ Native MCP |
|
|
15
|
+
| Cursor | ✅ Native MCP |
|
|
16
|
+
| Windsurf | ✅ Native MCP |
|
|
17
|
+
| Kilo Code | ✅ Native MCP |
|
|
18
|
+
| VS Code + Continue.dev | ✅ Native MCP |
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|----------|-------------|
|
|
24
|
-
| `contextos://context/current` | Last built context |
|
|
25
|
-
| `contextos://project/info` | Project configuration |
|
|
26
|
-
| `contextos://project/constraints` | Coding rules |
|
|
27
|
-
| `contextos://project/structure` | Directory tree |
|
|
20
|
+
## 🚀 Quick Setup
|
|
28
21
|
|
|
29
|
-
###
|
|
30
|
-
Pre-built prompt templates:
|
|
22
|
+
### Recommended: Use Universal Setup
|
|
31
23
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
| `review_code` | Review file with deps |
|
|
36
|
-
| `debug_issue` | Debug with context |
|
|
24
|
+
```bash
|
|
25
|
+
npx @contextos/setup
|
|
26
|
+
```
|
|
37
27
|
|
|
38
|
-
|
|
28
|
+
This automatically configures all your AI tools.
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
### Manual Configuration
|
|
41
31
|
|
|
42
|
-
|
|
32
|
+
#### Claude Desktop / Claude Code CLI
|
|
43
33
|
|
|
44
|
-
Add to
|
|
34
|
+
Add to `~/.config/claude/claude_desktop_config.json` (Linux/macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
45
35
|
|
|
46
36
|
```json
|
|
47
37
|
{
|
|
48
38
|
"mcpServers": {
|
|
49
39
|
"contextos": {
|
|
50
40
|
"command": "npx",
|
|
51
|
-
"args": ["@contextos/mcp"]
|
|
52
|
-
"cwd": "/path/to/your/project"
|
|
41
|
+
"args": ["-y", "@contextos/mcp"]
|
|
53
42
|
}
|
|
54
43
|
}
|
|
55
44
|
}
|
|
56
45
|
```
|
|
57
46
|
|
|
58
|
-
|
|
47
|
+
#### Cursor
|
|
59
48
|
|
|
60
|
-
Add to
|
|
49
|
+
Add to settings.json:
|
|
61
50
|
|
|
62
51
|
```json
|
|
63
52
|
{
|
|
@@ -70,52 +59,139 @@ Add to Cursor settings:
|
|
|
70
59
|
}
|
|
71
60
|
```
|
|
72
61
|
|
|
73
|
-
|
|
62
|
+
#### Windsurf
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
Add to settings.json:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcp.servers": {
|
|
69
|
+
"contextos": {
|
|
70
|
+
"command": "npx @contextos/mcp",
|
|
71
|
+
"cwd": "${workspaceFolder}"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
78
75
|
```
|
|
79
76
|
|
|
80
|
-
|
|
77
|
+
## 🔧 MCP Capabilities
|
|
81
78
|
|
|
82
|
-
|
|
79
|
+
### Tools
|
|
83
80
|
|
|
84
|
-
|
|
81
|
+
| Tool | Description |
|
|
82
|
+
|------|-------------|
|
|
83
|
+
| `contextos_build` | Build optimized context for a goal |
|
|
84
|
+
| `contextos_analyze` | Deep analysis using RLM engine |
|
|
85
|
+
| `contextos_find` | Find files matching a pattern |
|
|
86
|
+
| `contextos_deps` | Get file dependencies |
|
|
87
|
+
| `contextos_explain` | Explain a file's purpose |
|
|
88
|
+
| `contextos_status` | Get ContextOS status |
|
|
89
|
+
|
|
90
|
+
### Resources
|
|
91
|
+
|
|
92
|
+
| Resource | Description |
|
|
93
|
+
|----------|-------------|
|
|
94
|
+
| `contextos://context/current` | Current built context |
|
|
95
|
+
| `contextos://project/info` | Project information |
|
|
96
|
+
| `contextos://project/constraints` | Coding constraints |
|
|
97
|
+
| `contextos://project/structure` | File tree structure |
|
|
98
|
+
|
|
99
|
+
### Prompts
|
|
100
|
+
|
|
101
|
+
| Prompt | Description |
|
|
102
|
+
|--------|-------------|
|
|
103
|
+
| `code_with_context` | Start coding with full context |
|
|
104
|
+
| `review_code` | Review code with dependencies |
|
|
105
|
+
| `debug_issue` | Debug with relevant context |
|
|
106
|
+
|
|
107
|
+
## 📋 Usage Examples
|
|
108
|
+
|
|
109
|
+
Once configured, your AI assistant can use ContextOS automatically:
|
|
110
|
+
|
|
111
|
+
**Example Chat:**
|
|
85
112
|
|
|
86
|
-
|
|
113
|
+
```
|
|
114
|
+
You: Add rate limiting to the AuthController
|
|
87
115
|
|
|
88
|
-
|
|
116
|
+
AI: [Calls contextos_build("Add rate limiting to AuthController")]
|
|
117
|
+
AI: Based on the context, I can see AuthController.ts imports RateLimitMiddleware...
|
|
118
|
+
Here's the implementation:
|
|
119
|
+
...
|
|
89
120
|
```
|
|
90
|
-
|
|
121
|
+
|
|
122
|
+
**Example with Tools:**
|
|
123
|
+
|
|
91
124
|
```
|
|
125
|
+
You: What does PaymentService depend on?
|
|
92
126
|
|
|
93
|
-
|
|
127
|
+
AI: [Calls contextos_deps("src/payment/PaymentService.ts")]
|
|
128
|
+
AI: PaymentService depends on:
|
|
129
|
+
- src/payment/StripeClient.ts
|
|
130
|
+
- src/user/UserRepository.ts
|
|
131
|
+
- src/common/Logger.ts
|
|
132
|
+
```
|
|
94
133
|
|
|
95
|
-
|
|
134
|
+
## 🏗️ How It Works
|
|
96
135
|
|
|
97
|
-
The AI can read:
|
|
98
136
|
```
|
|
99
|
-
|
|
137
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
138
|
+
│ AI Tool (Cursor, Claude, etc.) │
|
|
139
|
+
└─────────────────────────────────────────────────────────────┘
|
|
140
|
+
│
|
|
141
|
+
│ MCP Protocol
|
|
142
|
+
▼
|
|
143
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
144
|
+
│ @contextos/mcp │
|
|
145
|
+
│ │
|
|
146
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
147
|
+
│ │ Tools │ │ Resources │ │ Prompts │ │
|
|
148
|
+
│ │ (Actions) │ │ (Data) │ │ (Templates) │ │
|
|
149
|
+
│ └──────────────┘ └──────────────┘ └──────────────┘ │
|
|
150
|
+
│ │ │
|
|
151
|
+
│ ▼ │
|
|
152
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
153
|
+
│ │ @contextos/core │ │
|
|
154
|
+
│ │ RLM Engine | Hybrid Ranker | Parser | Graph | etc. │ │
|
|
155
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
156
|
+
└─────────────────────────────────────────────────────────────┘
|
|
157
|
+
│
|
|
158
|
+
▼
|
|
159
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
160
|
+
│ Your Codebase │
|
|
161
|
+
│ .contextos/ | src/ | package.json | ... │
|
|
162
|
+
└─────────────────────────────────────────────────────────────┘
|
|
100
163
|
```
|
|
101
164
|
|
|
102
|
-
|
|
165
|
+
## 🔍 Debugging
|
|
103
166
|
|
|
104
|
-
|
|
167
|
+
### Check if MCP server starts correctly
|
|
105
168
|
|
|
106
169
|
```bash
|
|
107
|
-
|
|
108
|
-
|
|
170
|
+
npx @contextos/mcp
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
You should see: `ContextOS MCP Server started`
|
|
109
174
|
|
|
110
|
-
|
|
111
|
-
pnpm build
|
|
175
|
+
### Enable debug logging
|
|
112
176
|
|
|
113
|
-
|
|
114
|
-
|
|
177
|
+
```bash
|
|
178
|
+
DEBUG=contextos:* npx @contextos/mcp
|
|
115
179
|
```
|
|
116
180
|
|
|
117
|
-
|
|
181
|
+
### Check tool logs
|
|
182
|
+
|
|
183
|
+
Most MCP-compatible tools have a developer console or log file where you can see MCP communication.
|
|
184
|
+
|
|
185
|
+
## 📦 Requirements
|
|
186
|
+
|
|
187
|
+
- Node.js 18+
|
|
188
|
+
- A ContextOS-initialized project (`npx @contextos/cli init`)
|
|
189
|
+
- An MCP-compatible AI tool
|
|
190
|
+
|
|
191
|
+
## 🤝 Contributing
|
|
192
|
+
|
|
193
|
+
Found an issue or want to add support for a new tool? Open an issue or PR!
|
|
118
194
|
|
|
119
|
-
## License
|
|
195
|
+
## 📄 License
|
|
120
196
|
|
|
121
|
-
MIT
|
|
197
|
+
MIT © ContextOS Team
|
package/dist/index.js
CHANGED
|
@@ -355,12 +355,15 @@ ${content.slice(0, 3e3)}
|
|
|
355
355
|
/^import\s+([\w.]+)/gm,
|
|
356
356
|
/^from\s+([\w.]+)\s+import/gm
|
|
357
357
|
];
|
|
358
|
+
const MAX_ITERATIONS = 1e3;
|
|
358
359
|
for (const pattern of patterns) {
|
|
359
360
|
let match;
|
|
360
|
-
|
|
361
|
+
let iterations = 0;
|
|
362
|
+
while ((match = pattern.exec(content)) !== null && iterations < MAX_ITERATIONS) {
|
|
361
363
|
if (match[1] && !imports.includes(match[1])) {
|
|
362
364
|
imports.push(match[1]);
|
|
363
365
|
}
|
|
366
|
+
iterations++;
|
|
364
367
|
}
|
|
365
368
|
}
|
|
366
369
|
return `# Dependencies of ${file}
|
package/package.json
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@contextos/mcp",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Model Context Protocol server for ContextOS - enables all AI tools (Claude, Cursor, Codex, Gemini, Windsurf) to access optimized context",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"contextos-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@modelcontextprotocol/sdk": "^0.5.0",
|
|
12
|
+
"@contextos/core": "0.4.4"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"tsup": "^8.0.0",
|
|
16
|
+
"tsx": "^4.7.0",
|
|
17
|
+
"typescript": "^5.4.0"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"mcp",
|
|
21
|
+
"model-context-protocol",
|
|
22
|
+
"ai",
|
|
23
|
+
"context",
|
|
24
|
+
"cursor",
|
|
25
|
+
"claude",
|
|
26
|
+
"codex",
|
|
27
|
+
"gemini",
|
|
28
|
+
"windsurf",
|
|
29
|
+
"contextos"
|
|
30
|
+
],
|
|
31
|
+
"author": "ContextOS Team",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup src/index.ts --format esm --clean",
|
|
35
|
+
"dev": "tsx watch src/index.ts",
|
|
36
|
+
"start": "node dist/index.js"
|
|
37
|
+
}
|
|
34
38
|
}
|
package/src/provider.ts
CHANGED
|
@@ -406,12 +406,17 @@ ${result.context}
|
|
|
406
406
|
/^from\s+([\w.]+)\s+import/gm,
|
|
407
407
|
];
|
|
408
408
|
|
|
409
|
+
// Fix R3: Add maximum iterations to prevent ReDoS
|
|
410
|
+
const MAX_ITERATIONS = 1000;
|
|
411
|
+
|
|
409
412
|
for (const pattern of patterns) {
|
|
410
413
|
let match;
|
|
411
|
-
|
|
414
|
+
let iterations = 0;
|
|
415
|
+
while ((match = pattern.exec(content)) !== null && iterations < MAX_ITERATIONS) {
|
|
412
416
|
if (match[1] && !imports.includes(match[1])) {
|
|
413
417
|
imports.push(match[1]);
|
|
414
418
|
}
|
|
419
|
+
iterations++;
|
|
415
420
|
}
|
|
416
421
|
}
|
|
417
422
|
|