@contextos/mcp 0.2.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @contextos/mcp@0.1.0 build C:\Users\ixayl\Desktop\ContextOS\ContextOS\packages\mcp
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
  CLI Building entry: src/index.ts
@@ -8,5 +8,5 @@
8
8
  CLI Target: es2022
9
9
  CLI Cleaning output folder
10
10
  ESM Build start
11
- ESM dist\index.js 19.58 KB
12
- ESM ⚡️ Build success in 1395ms
11
+ ESM dist\index.js 19.69 KB
12
+ ESM ⚡️ Build success in 338ms
package/README.md CHANGED
@@ -1,63 +1,52 @@
1
- # ContextOS MCP Server
1
+ # @contextos/mcp
2
2
 
3
- Model Context Protocol (MCP) server that enables AI tools like **Claude Code**, **Cursor**, **Windsurf** to access optimized context from ContextOS.
3
+ **Model Context Protocol server for ContextOS**
4
4
 
5
- ## Features
5
+ [![npm version](https://img.shields.io/npm/v/@contextos/mcp?style=flat-square)](https://www.npmjs.com/package/@contextos/mcp)
6
6
 
7
- ### 🔧 Tools
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
- | Tool | Description |
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
- ### 📚 Resources
20
- AI can read these data sources:
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
- | Resource | Description |
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
- ### 💬 Prompts
30
- Pre-built prompt templates:
22
+ ### Recommended: Use Universal Setup
31
23
 
32
- | Prompt | Description |
33
- |--------|-------------|
34
- | `code_with_context` | Start coding with context |
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
- ## Installation
30
+ ### Manual Configuration
41
31
 
42
- ### For Claude Desktop
32
+ #### Claude Desktop / Claude Code CLI
43
33
 
44
- Add to your Claude Desktop config (`claude_desktop_config.json`):
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
- ### For Cursor
47
+ #### Cursor
59
48
 
60
- Add to Cursor settings:
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
- ### Global Installation
62
+ #### Windsurf
74
63
 
75
- ```bash
76
- npm install -g @contextos/mcp
77
- contextos-mcp
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
- ## Usage
79
+ ### Tools
83
80
 
84
- Once configured, the AI tool will automatically have access to ContextOS features.
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
- ### Example: Building Context
113
+ ```
114
+ You: Add rate limiting to the AuthController
87
115
 
88
- The AI can call:
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
- Use the contextos_build tool with goal "Add authentication to UserController"
121
+
122
+ **Example with Tools:**
123
+
91
124
  ```
125
+ You: What does PaymentService depend on?
92
126
 
93
- And receive optimized context automatically.
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
- ### Example: Reading Project Info
134
+ ## 🏗️ How It Works
96
135
 
97
- The AI can read:
98
136
  ```
99
- Read the contextos://project/info resource
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
- ## Development
167
+ ### Check if MCP server starts correctly
105
168
 
106
169
  ```bash
107
- # Install dependencies
108
- pnpm install
170
+ npx @contextos/mcp
171
+ ```
172
+
173
+ You should see: `ContextOS MCP Server started`
109
174
 
110
- # Build
111
- pnpm build
175
+ ### Enable debug logging
112
176
 
113
- # Run locally
114
- pnpm start
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
- while ((match = pattern.exec(content)) !== null) {
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@contextos/mcp",
3
- "version": "0.2.0",
4
- "description": "Model Context Protocol server for ContextOS - enables AI tools to access optimized context",
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
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@modelcontextprotocol/sdk": "^0.5.0",
12
- "@contextos/core": "0.2.0"
12
+ "@contextos/core": "0.4.4"
13
13
  },
14
14
  "devDependencies": {
15
15
  "tsup": "^8.0.0",
@@ -22,7 +22,11 @@
22
22
  "ai",
23
23
  "context",
24
24
  "cursor",
25
- "claude"
25
+ "claude",
26
+ "codex",
27
+ "gemini",
28
+ "windsurf",
29
+ "contextos"
26
30
  ],
27
31
  "author": "ContextOS Team",
28
32
  "license": "MIT",
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
- while ((match = pattern.exec(content)) !== null) {
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