mcp-code-context 3.0.6 → 3.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.
- package/CHANGELOG.md +84 -1
- package/CHANGELOG_v3.2.0.md +196 -0
- package/CHANGELOG_v3.3.0.md +266 -0
- package/README.md +1 -1
- package/SECURITY.md +177 -0
- package/dist/src/core/engine.d.ts +2 -2
- package/dist/src/core/engine.js +14 -8
- package/dist/src/core/engine.js.map +1 -1
- package/dist/src/core/validator.d.ts +2 -2
- package/dist/src/core/validator.js +8 -7
- package/dist/src/core/validator.js.map +1 -1
- package/dist/src/index.d.ts +6 -6
- package/dist/src/index.js +499 -158
- package/dist/src/index.js.map +1 -1
- package/dist/src/operations/compress.d.ts +18 -0
- package/dist/src/operations/compress.js +89 -0
- package/dist/src/operations/compress.js.map +1 -0
- package/dist/src/operations/confirmationStore.d.ts +53 -0
- package/dist/src/operations/confirmationStore.js +91 -0
- package/dist/src/operations/confirmationStore.js.map +1 -0
- package/dist/src/operations/read.d.ts +50 -0
- package/dist/src/operations/read.js +228 -0
- package/dist/src/operations/read.js.map +1 -0
- package/dist/src/operations/write.d.ts +16 -4
- package/dist/src/operations/write.js +142 -48
- package/dist/src/operations/write.js.map +1 -1
- package/dist/src/parsers/base.d.ts +7 -2
- package/dist/src/parsers/base.js +18 -1
- package/dist/src/parsers/base.js.map +1 -1
- package/dist/src/parsers/dartTreeSitter.d.ts +3 -3
- package/dist/src/parsers/dartTreeSitter.js +6 -11
- package/dist/src/parsers/dartTreeSitter.js.map +1 -1
- package/dist/src/parsers/php.d.ts +2 -2
- package/dist/src/parsers/php.js +5 -10
- package/dist/src/parsers/php.js.map +1 -1
- package/dist/src/parsers/python.d.ts +2 -2
- package/dist/src/parsers/python.js +5 -10
- package/dist/src/parsers/python.js.map +1 -1
- package/dist/src/parsers/registry.d.ts +1 -1
- package/dist/src/parsers/registry.js +2 -2
- package/dist/src/parsers/registry.js.map +1 -1
- package/dist/src/parsers/typescript.d.ts +2 -2
- package/dist/src/parsers/typescript.js +8 -13
- package/dist/src/parsers/typescript.js.map +1 -1
- package/dist/src/utils/auditLogger.d.ts +90 -0
- package/dist/src/utils/auditLogger.js +271 -0
- package/dist/src/utils/auditLogger.js.map +1 -0
- package/dist/src/utils/backupManager.d.ts +33 -0
- package/dist/src/utils/backupManager.js +130 -0
- package/dist/src/utils/backupManager.js.map +1 -0
- package/dist/src/utils/constants.d.ts +12 -0
- package/dist/src/utils/constants.js +33 -0
- package/dist/src/utils/constants.js.map +1 -0
- package/dist/src/utils/diff.d.ts +13 -0
- package/dist/src/utils/diff.js +124 -0
- package/dist/src/utils/diff.js.map +1 -0
- package/dist/src/utils/fileLock.d.ts +63 -0
- package/dist/src/utils/fileLock.js +123 -0
- package/dist/src/utils/fileLock.js.map +1 -0
- package/dist/src/utils/rateLimiter.d.ts +61 -0
- package/dist/src/utils/rateLimiter.js +114 -0
- package/dist/src/utils/rateLimiter.js.map +1 -0
- package/dist/src/utils/safeRegex.d.ts +41 -0
- package/dist/src/utils/safeRegex.js +137 -0
- package/dist/src/utils/safeRegex.js.map +1 -0
- package/dist/src/utils/streaming.d.ts +43 -0
- package/dist/src/utils/streaming.js +175 -0
- package/dist/src/utils/streaming.js.map +1 -0
- package/dist/src/utils/telemetry.d.ts +91 -0
- package/dist/src/utils/telemetry.js +185 -0
- package/dist/src/utils/telemetry.js.map +1 -0
- package/llms.txt +46 -28
- package/package.json +5 -5
- package/mcp-code-context-3.0.2.tgz +0 -0
- package/tsconfig.tests.json +0 -27
package/llms.txt
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
# mcp-code-context v3.0
|
|
1
|
+
# mcp-code-context v3.4.0
|
|
2
2
|
|
|
3
|
-
> A Model Context Protocol (MCP) server with **Tree-sitter WASM parsers** for 100% AST accuracy. Zero native dependencies.
|
|
3
|
+
> A Model Context Protocol (MCP) server with **Tree-sitter WASM parsers** for 100% AST accuracy. Zero native dependencies. Production-ready with middleware pipeline.
|
|
4
4
|
|
|
5
|
-
## What's New in v3.0
|
|
5
|
+
## What's New in v3.4.0
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- ✅
|
|
9
|
-
- ✅
|
|
10
|
-
- ✅
|
|
7
|
+
🔒 **Production Hardening**:
|
|
8
|
+
- ✅ Two-phase write workflow (dry-run + confirmation token)
|
|
9
|
+
- ✅ Middleware pipeline: Rate limiting → File locking → Execution → Audit logging → Telemetry
|
|
10
|
+
- ✅ All 13 handlers require `projectRoot` with SecurityValidator
|
|
11
|
+
- ✅ Safe regex with timeout enforcement (ReDoS protection)
|
|
12
|
+
- ✅ LCS diff OOM guard (MAX_DIFF_LINES = 5000)
|
|
13
|
+
- ✅ Atomic writes (write-to-tmp + rename)
|
|
14
|
+
- ✅ Critical bug fix: `extractSymbol` API mismatch resolved
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
🔧 **NPM Package Optimization**:
|
|
15
|
-
- ✅ Package size reduced: 658.6 kB → 105.5 kB (-84%)
|
|
16
|
-
- ✅ File count reduced: 131 files → 36 files (-73%)
|
|
17
|
-
- ✅ Clean dist/ structure (no nested dist/src/)
|
|
18
|
-
- ✅ Excluded legacy v2 code from npm distribution
|
|
19
|
-
|
|
20
|
-
## What's New in v3.0.6
|
|
21
|
-
|
|
22
|
-
🚀 **Complete WASM Migration**: 100% portable architecture
|
|
23
|
-
- ✅ Migrated to web-tree-sitter@0.25.1 (WASM)
|
|
16
|
+
🚀 **Architecture**: 100% WASM portable
|
|
17
|
+
- ✅ web-tree-sitter@0.25.1 (WASM)
|
|
24
18
|
- ✅ Zero native dependencies (no Visual Studio, node-gyp, Python)
|
|
25
|
-
- ✅
|
|
26
|
-
- ✅ Dart
|
|
27
|
-
- ✅ TypeScript/JavaScript/Python/PHP all use WASM parsers
|
|
28
|
-
- ✅ ABI v15 support (latest language grammars)
|
|
19
|
+
- ✅ Windows/Mac/Linux without compilation
|
|
20
|
+
- ✅ TypeScript/JavaScript/Python/PHP/Dart all use WASM parsers
|
|
29
21
|
|
|
30
22
|
## What This Tool Does
|
|
31
23
|
|
|
@@ -42,6 +34,7 @@ This MCP server solves two problems:
|
|
|
42
34
|
|
|
43
35
|
**Input:**
|
|
44
36
|
- `directoryPath` (required): Absolute path to the repository root.
|
|
37
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
45
38
|
- `format` (optional): `"xml"` (default) or `"markdown"`.
|
|
46
39
|
|
|
47
40
|
**What it does:**
|
|
@@ -60,7 +53,9 @@ This MCP server solves two problems:
|
|
|
60
53
|
|
|
61
54
|
**Input:**
|
|
62
55
|
- `filePath` (required): Absolute path to the source file.
|
|
56
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
63
57
|
- `symbolName` (optional): Name of a function, class, interface, method, or type to extract.
|
|
58
|
+
- `className` (optional): Class name to scope the symbol search.
|
|
64
59
|
|
|
65
60
|
**What it does:**
|
|
66
61
|
- With `symbolName`: Parses the AST and returns only the full source code block for that symbol. Saves tokens when you only need one function from a large file.
|
|
@@ -73,7 +68,8 @@ This MCP server solves two problems:
|
|
|
73
68
|
|
|
74
69
|
**Input:**
|
|
75
70
|
- `filePath` (required): Absolute path to the file being modified.
|
|
76
|
-
- `
|
|
71
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
72
|
+
- `rootDir` (optional): Repository root. Defaults to projectRoot.
|
|
77
73
|
|
|
78
74
|
**What it does:**
|
|
79
75
|
- Scans all source files for `import`, `require()`, Python `from/import`, PHP `use`/`require_once`/`include`, and Dart `import` statements.
|
|
@@ -87,6 +83,7 @@ This MCP server solves two problems:
|
|
|
87
83
|
|
|
88
84
|
**Input:**
|
|
89
85
|
- `filePath` (required): Absolute path to the source file.
|
|
86
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
90
87
|
- `startLine` (optional): Starting line number (1-indexed).
|
|
91
88
|
- `endLine` (optional): Ending line number (1-indexed).
|
|
92
89
|
- `aroundPattern` (optional): Search pattern to find and return surrounding lines.
|
|
@@ -112,6 +109,7 @@ This MCP server solves two problems:
|
|
|
112
109
|
|
|
113
110
|
**Input:**
|
|
114
111
|
- `rootDir` (required): Absolute path to the repository root.
|
|
112
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
115
113
|
- `pattern` (required): Regular expression pattern to search for.
|
|
116
114
|
- `fileExtensions` (optional): Array of extensions to search (e.g., `[".ts", ".dart"]`). Defaults to common code extensions.
|
|
117
115
|
- `excludeDirs` (optional): Directories to exclude (default: `["node_modules", "dist", "build"]`).
|
|
@@ -144,13 +142,13 @@ This MCP server solves two problems:
|
|
|
144
142
|
- `steps` (optional): Number of versions to go back (1-5, default: 1).
|
|
145
143
|
**What it does:** Reverts the file to the state it was in before the last 1-5 modifications.
|
|
146
144
|
|
|
147
|
-
### Write Tools (
|
|
145
|
+
### Write Tools (v3.4.0 Two-Phase Workflow)
|
|
148
146
|
|
|
149
147
|
All write tools follow a **Two-Phase Workflow**:
|
|
150
148
|
1. **Phase 1 (Preview)**: Call without a token to get a unified `diff` and a `confirmationToken`.
|
|
151
149
|
2. **Phase 2 (Apply)**: Call with `confirmationToken` and `confirm: true` to apply the changes.
|
|
152
150
|
|
|
153
|
-
**Important Notes (
|
|
151
|
+
**Important Notes (v3.4.0):**
|
|
154
152
|
- ✅ **Windows CRLF Support**: Fully resolved. All operations work correctly on Windows files with CRLF line endings.
|
|
155
153
|
- ✅ **Parameter Brace Handling**: Methods with braces in parameters (e.g., `{int? cart}`) are now handled correctly.
|
|
156
154
|
|
|
@@ -159,6 +157,7 @@ All write tools follow a **Two-Phase Workflow**:
|
|
|
159
157
|
|
|
160
158
|
**Input:**
|
|
161
159
|
- `filePath` (required): Absolute path to the file to modify.
|
|
160
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
162
161
|
- `symbolName` (required): Name of the symbol to replace.
|
|
163
162
|
- `newContent` (required): Complete replacement code (signature + body).
|
|
164
163
|
- `confirmationToken` (optional): Token from Phase 1.
|
|
@@ -178,6 +177,7 @@ All write tools follow a **Two-Phase Workflow**:
|
|
|
178
177
|
|
|
179
178
|
**Input:**
|
|
180
179
|
- `filePath` (required): Absolute path to the file.
|
|
180
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
181
181
|
- `code` (required): The new code to insert.
|
|
182
182
|
- `anchorSymbol` (optional): Symbol name to position relative to. If omitted, inserts at end of file.
|
|
183
183
|
- `position` (optional): `"before"`, `"after"`, `"inside_start"`, `"inside_end"`. Defaults to `"after"`.
|
|
@@ -195,6 +195,7 @@ All write tools follow a **Two-Phase Workflow**:
|
|
|
195
195
|
|
|
196
196
|
**Input:**
|
|
197
197
|
- `filePath` (required): File where the symbol is defined.
|
|
198
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
198
199
|
- `oldName` (required): Current name.
|
|
199
200
|
- `newName` (required): New name.
|
|
200
201
|
- `rootDir` (optional): Repository root. Auto-detected if omitted.
|
|
@@ -214,6 +215,7 @@ All write tools follow a **Two-Phase Workflow**:
|
|
|
214
215
|
|
|
215
216
|
**Input:**
|
|
216
217
|
- `filePath` (required): Absolute path.
|
|
218
|
+
- `projectRoot` (required): Project root for security boundary.
|
|
217
219
|
- `symbolName` (required): Symbol to remove.
|
|
218
220
|
- `force` (optional): If true, skip dependency check. Defaults to false.
|
|
219
221
|
- `confirmationToken`, `confirm` (optional): Standard Phase 2 parameters.
|
|
@@ -234,13 +236,29 @@ All write tools follow a **Two-Phase Workflow**:
|
|
|
234
236
|
5. **Phase 2: Apply Edit** → Verify the diff, then call with the token and `confirm: true`.
|
|
235
237
|
6. **Recovery** → Use `rollback_file` if needed.
|
|
236
238
|
|
|
239
|
+
### Additional Tools (v3.4.0)
|
|
240
|
+
|
|
241
|
+
#### 11. `parse_file`
|
|
242
|
+
**Purpose:** Parse a file using Tree-sitter and extract all symbols.
|
|
243
|
+
**Input:** `filePath` (required), `projectRoot` (required).
|
|
244
|
+
**Returns:** JSON array of all symbols with type and name.
|
|
245
|
+
|
|
246
|
+
#### 12. `clean_backups`
|
|
247
|
+
**Purpose:** Remove all backup files for a project.
|
|
248
|
+
**Input:** `projectRoot` (required).
|
|
249
|
+
|
|
250
|
+
#### 13. `get_server_stats`
|
|
251
|
+
**Purpose:** Get server telemetry, audit statistics, and health metrics.
|
|
252
|
+
**Input:** None.
|
|
253
|
+
**Returns:** Pending confirmations count and operational metrics.
|
|
254
|
+
|
|
237
255
|
## Technical Details
|
|
238
256
|
|
|
239
257
|
- **Transport:** stdio (JSON-RPC over stdin/stdout)
|
|
240
258
|
- **Runtime:** Node.js >= 18
|
|
241
259
|
- **AST Engines:** web-tree-sitter@0.25.1 (WASM) for all languages
|
|
242
260
|
- **Language Grammars:** tree-sitter-wasms@0.1.13 (ABI v15)
|
|
243
|
-
- **Ignore Engine:** `ignore` npm package (full .gitignore spec support)
|
|
244
261
|
- **Supported languages:** TypeScript, JavaScript (all variants), PHP, Dart, Python
|
|
245
|
-
- **
|
|
262
|
+
- **Security:** projectRoot boundary, safe regex, rate limiting, file locking, audit logging, telemetry
|
|
263
|
+
- **Write safety:** Two-phase confirmation (dry-run + token), atomic writes, syntax validation
|
|
246
264
|
- **Portability:** 100% WASM - no native dependencies, works on all platforms
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-code-context",
|
|
3
|
-
"version": "3.0
|
|
4
|
-
"description": "Powerful MCP server with Tree-sitter WASM parsers for 100% AST accuracy. Zero native dependencies. Supports TypeScript, JavaScript, PHP, Dart, and Python.",
|
|
3
|
+
"version": "3.4.0",
|
|
4
|
+
"description": "Powerful MCP server with Tree-sitter WASM parsers for 100% AST accuracy. Zero native dependencies. Production-ready with streaming, telemetry, audit logging, rate limiting, file locking, and ReDoS protection. Supports TypeScript, JavaScript, PHP, Dart, and Python.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"build:tests": "tsc -p tsconfig.tests.json",
|
|
13
|
-
"start": "node dist/index.js",
|
|
14
|
-
"dev": "npm run build && node dist/index.js",
|
|
15
|
-
"test": "npm run build && npm run build:tests && node dist-tests/tests/test-wasm-parsers.js",
|
|
13
|
+
"start": "node dist/src/index.js",
|
|
14
|
+
"dev": "npm run build && node dist/src/index.js",
|
|
15
|
+
"test": "npm run build && npm run build:tests && node dist-tests/tests/test-security.js && node dist-tests/tests/test-file-lock.js && node dist-tests/tests/test-rate-limiter.js && node dist-tests/tests/test-v3.4.js && node dist-tests/tests/test-backup-manager.js && node dist-tests/tests/test-wasm-parsers.js",
|
|
16
16
|
"clean": "rimraf dist dist-tests",
|
|
17
17
|
"rebuild": "npm run clean && npm run build",
|
|
18
18
|
"prepublishOnly": "npm run rebuild"
|
|
Binary file
|
package/tsconfig.tests.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "Node16",
|
|
5
|
-
"moduleResolution": "Node16",
|
|
6
|
-
"outDir": "./dist-tests",
|
|
7
|
-
"rootDir": ".",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"baseUrl": ".",
|
|
16
|
-
"paths": {
|
|
17
|
-
"web-tree-sitter": ["node_modules/web-tree-sitter/web-tree-sitter.d.ts"]
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"include": [
|
|
21
|
-
"tests/test-wasm-parsers.ts",
|
|
22
|
-
"tests/manual/**/*"
|
|
23
|
-
],
|
|
24
|
-
"exclude": [
|
|
25
|
-
"node_modules"
|
|
26
|
-
]
|
|
27
|
-
}
|