@j0hanz/filesystem-context-mcp 1.0.4 → 1.0.6
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 +27 -26
- package/dist/instructions.md +245 -0
- package/dist/prompts/analyze-codebase.d.ts +3 -0
- package/dist/prompts/analyze-codebase.d.ts.map +1 -0
- package/dist/prompts/analyze-codebase.js +58 -0
- package/dist/prompts/analyze-codebase.js.map +1 -0
- package/dist/prompts/filesystem-query.d.ts +3 -0
- package/dist/prompts/filesystem-query.d.ts.map +1 -0
- package/dist/prompts/filesystem-query.js +113 -0
- package/dist/prompts/filesystem-query.js.map +1 -0
- package/dist/prompts/find-duplicates.d.ts +3 -0
- package/dist/prompts/find-duplicates.d.ts.map +1 -0
- package/dist/prompts/find-duplicates.js +68 -0
- package/dist/prompts/find-duplicates.js.map +1 -0
- package/dist/prompts/index.d.ts +3 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +13 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/project-overview.d.ts +3 -0
- package/dist/prompts/project-overview.d.ts.map +1 -0
- package/dist/prompts/project-overview.js +51 -0
- package/dist/prompts/project-overview.js.map +1 -0
- package/dist/prompts/search-and-replace.d.ts +3 -0
- package/dist/prompts/search-and-replace.d.ts.map +1 -0
- package/dist/prompts/search-and-replace.js +83 -0
- package/dist/prompts/search-and-replace.js.map +1 -0
- package/dist/schemas/outputs.d.ts +4 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +15 -0
- package/dist/server.js.map +1 -1
- package/dist/tools/analyze-directory.d.ts.map +1 -1
- package/dist/tools/analyze-directory.js +1 -0
- package/dist/tools/analyze-directory.js.map +1 -1
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +1 -0
- package/dist/tools/directory-tree.js.map +1 -1
- package/dist/tools/get-file-info.d.ts.map +1 -1
- package/dist/tools/get-file-info.js +1 -0
- package/dist/tools/get-file-info.js.map +1 -1
- package/dist/tools/list-allowed-dirs.d.ts.map +1 -1
- package/dist/tools/list-allowed-dirs.js +1 -0
- package/dist/tools/list-allowed-dirs.js.map +1 -1
- package/dist/tools/list-directory.d.ts.map +1 -1
- package/dist/tools/list-directory.js +1 -0
- package/dist/tools/list-directory.js.map +1 -1
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +1 -0
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/read-media-file.d.ts.map +1 -1
- package/dist/tools/read-media-file.js +1 -0
- package/dist/tools/read-media-file.js.map +1 -1
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +1 -0
- package/dist/tools/read-multiple-files.js.map +1 -1
- package/dist/tools/search-content.d.ts.map +1 -1
- package/dist/tools/search-content.js +1 -0
- package/dist/tools/search-content.js.map +1 -1
- package/dist/tools/search-files.d.ts.map +1 -1
- package/dist/tools/search-files.js +1 -0
- package/dist/tools/search-files.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ A secure, read-only MCP server for filesystem scanning, searching, and analysis
|
|
|
5
5
|
[](https://www.npmjs.com/package/@j0hanz/filesystem-context-mcp)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://nodejs.org)
|
|
8
|
-
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
9
|
[](https://modelcontextprotocol.io)
|
|
10
10
|
|
|
11
11
|
## One-Click Install
|
|
@@ -196,7 +196,7 @@ Search for files using glob patterns.
|
|
|
196
196
|
| `path` | string | ✅ | - | Base directory to search from |
|
|
197
197
|
| `pattern` | string | ✅ | - | Glob pattern (e.g., `**/*.ts`, `src/**/*.js`) |
|
|
198
198
|
| `excludePatterns` | string[] | ❌ | `[]` | Patterns to exclude |
|
|
199
|
-
| `maxResults` | number | ❌ | - | Maximum matches to return (
|
|
199
|
+
| `maxResults` | number | ❌ | - | Maximum matches to return (max 10,000) |
|
|
200
200
|
| `sortBy` | string | ❌ | `path` | Sort by: `name`, `size`, `modified`, `path` |
|
|
201
201
|
| `maxDepth` | number | ❌ | - | Maximum directory depth to search (1-100) |
|
|
202
202
|
|
|
@@ -218,15 +218,15 @@ Search for files using glob patterns.
|
|
|
218
218
|
|
|
219
219
|
Read the contents of a text file.
|
|
220
220
|
|
|
221
|
-
| Parameter | Type | Required | Default | Description
|
|
222
|
-
| ----------- | ------ | -------- | ------- |
|
|
223
|
-
| `path` | string | ✅ | - | File path to read
|
|
224
|
-
| `encoding` | string | ❌ | `utf-8` | File encoding (`utf-8`, `ascii`, `base64`, etc.)
|
|
225
|
-
| `maxSize` | number | ❌ | 10MB | Maximum file size in bytes
|
|
226
|
-
| `lineStart` | number | ❌ | - | Start line (1-indexed) for reading a range
|
|
227
|
-
| `lineEnd` | number | ❌ | - | End line (inclusive) for reading a range
|
|
228
|
-
| `head` | number | ❌ | - | Read only first N lines
|
|
229
|
-
| `tail` | number | ❌ | - | Read only last N lines
|
|
221
|
+
| Parameter | Type | Required | Default | Description |
|
|
222
|
+
| ----------- | ------ | -------- | ------- | ---------------------------------------------------------- |
|
|
223
|
+
| `path` | string | ✅ | - | File path to read |
|
|
224
|
+
| `encoding` | string | ❌ | `utf-8` | File encoding (`utf-8`, `ascii`, `base64`, etc.) |
|
|
225
|
+
| `maxSize` | number | ❌ | 10MB | Maximum file size in bytes |
|
|
226
|
+
| `lineStart` | number | ❌ | - | Start line (1-indexed, min 1) for reading a range |
|
|
227
|
+
| `lineEnd` | number | ❌ | - | End line (1-indexed, inclusive, min 1) for reading a range |
|
|
228
|
+
| `head` | number | ❌ | - | Read only first N lines |
|
|
229
|
+
| `tail` | number | ❌ | - | Read only last N lines |
|
|
230
230
|
|
|
231
231
|
> **Note:** Cannot specify both `head` and `tail` simultaneously. Use `lineStart`/`lineEnd` for range reading.
|
|
232
232
|
|
|
@@ -301,13 +301,13 @@ Search for text content within files using regular expressions.
|
|
|
301
301
|
|
|
302
302
|
Analyze a directory structure and return statistics.
|
|
303
303
|
|
|
304
|
-
| Parameter | Type | Required | Default | Description
|
|
305
|
-
| ----------------- | -------- | -------- | ------- |
|
|
306
|
-
| `path` | string | ✅ | - | Directory to analyze
|
|
307
|
-
| `maxDepth` | number | ❌ | `10` | Maximum depth to analyze (0-100)
|
|
308
|
-
| `topN` | number | ❌ | `10` | Number of top items to return (
|
|
309
|
-
| `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude
|
|
310
|
-
| `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories
|
|
304
|
+
| Parameter | Type | Required | Default | Description |
|
|
305
|
+
| ----------------- | -------- | -------- | ------- | ---------------------------------------- |
|
|
306
|
+
| `path` | string | ✅ | - | Directory to analyze |
|
|
307
|
+
| `maxDepth` | number | ❌ | `10` | Maximum depth to analyze (0-100) |
|
|
308
|
+
| `topN` | number | ❌ | `10` | Number of top items to return (max 1000) |
|
|
309
|
+
| `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
|
|
310
|
+
| `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
|
|
311
311
|
|
|
312
312
|
**Returns:** Statistics including total files/directories, total size, file type distribution, largest files, and recently modified files.
|
|
313
313
|
|
|
@@ -317,14 +317,14 @@ Analyze a directory structure and return statistics.
|
|
|
317
317
|
|
|
318
318
|
Get a JSON tree structure of a directory, optimized for AI parsing.
|
|
319
319
|
|
|
320
|
-
| Parameter | Type | Required | Default | Description
|
|
321
|
-
| ----------------- | -------- | -------- | ------- |
|
|
322
|
-
| `path` | string | ✅ | - | Directory path to build tree from
|
|
323
|
-
| `maxDepth` | number | ❌ | `5` | Maximum depth to traverse (0-50)
|
|
324
|
-
| `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude
|
|
325
|
-
| `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories
|
|
326
|
-
| `includeSize` | boolean | ❌ | `false` | Include file sizes in the tree
|
|
327
|
-
| `maxFiles` | number | ❌ | - | Maximum total files to include (
|
|
320
|
+
| Parameter | Type | Required | Default | Description |
|
|
321
|
+
| ----------------- | -------- | -------- | ------- | -------------------------------------------- |
|
|
322
|
+
| `path` | string | ✅ | - | Directory path to build tree from |
|
|
323
|
+
| `maxDepth` | number | ❌ | `5` | Maximum depth to traverse (0-50) |
|
|
324
|
+
| `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
|
|
325
|
+
| `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
|
|
326
|
+
| `includeSize` | boolean | ❌ | `false` | Include file sizes in the tree |
|
|
327
|
+
| `maxFiles` | number | ❌ | - | Maximum total files to include (max 100,000) |
|
|
328
328
|
|
|
329
329
|
**Returns:** Hierarchical tree structure with file/directory nodes.
|
|
330
330
|
|
|
@@ -500,6 +500,7 @@ This server implements multiple layers of security:
|
|
|
500
500
|
src/
|
|
501
501
|
├── index.ts # Entry point, CLI argument parsing
|
|
502
502
|
├── server.ts # MCP server setup, roots protocol handling
|
|
503
|
+
├── instructions.md # AI instructions for tool usage (bundled with dist)
|
|
503
504
|
├── config/
|
|
504
505
|
│ └── types.ts # Shared TypeScript types
|
|
505
506
|
├── lib/
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Filesystem Context MCP Server
|
|
2
|
+
|
|
3
|
+
> **Read-only** filesystem tools for exploring directories, searching files, and analyzing codebases. All operations are safe and idempotent.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Tool Selection Guide
|
|
8
|
+
|
|
9
|
+
### Which Tool Should I Use?
|
|
10
|
+
|
|
11
|
+
| Goal | Tool | Key Parameters |
|
|
12
|
+
| --------------------------------- | -------------------------- | ------------------------------------------------- |
|
|
13
|
+
| See what directories I can access | `list_allowed_directories` | _(none)_ |
|
|
14
|
+
| Visualize project structure | `directory_tree` | `maxDepth`, `excludePatterns`, `includeSize` |
|
|
15
|
+
| List directory contents | `list_directory` | `recursive`, `sortBy`, `maxEntries` |
|
|
16
|
+
| Get directory statistics | `analyze_directory` | `topN`, `excludePatterns` |
|
|
17
|
+
| Find files by name/pattern | `search_files` | `pattern` (glob), `excludePatterns`, `maxResults` |
|
|
18
|
+
| Search inside file contents | `search_content` | `pattern` (regex), `filePattern`, `contextLines` |
|
|
19
|
+
| Read a single file | `read_file` | `head`, `tail`, `lineStart`/`lineEnd` |
|
|
20
|
+
| Read multiple files | `read_multiple_files` | `paths[]`, `head`, `tail` |
|
|
21
|
+
| Get file metadata | `get_file_info` | _(path only)_ |
|
|
22
|
+
| Read images/binary files | `read_media_file` | `maxSize` |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Quick Start Workflow
|
|
27
|
+
|
|
28
|
+
**Always start here:**
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
1. list_allowed_directories → Know your boundaries
|
|
32
|
+
2. directory_tree(path, maxDepth=3) → See project structure
|
|
33
|
+
3. analyze_directory(path) → Get statistics
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Tool Reference
|
|
39
|
+
|
|
40
|
+
### `list_allowed_directories`
|
|
41
|
+
|
|
42
|
+
Returns all directories this server can access. **Call first** to understand scope.
|
|
43
|
+
|
|
44
|
+
### `directory_tree`
|
|
45
|
+
|
|
46
|
+
Returns a JSON tree structure—ideal for AI parsing.
|
|
47
|
+
|
|
48
|
+
| Parameter | Type | Default | Description |
|
|
49
|
+
| ----------------- | -------- | ------- | --------------------------- |
|
|
50
|
+
| `path` | string | — | Directory to visualize |
|
|
51
|
+
| `maxDepth` | number | 5 | How deep to traverse (0-50) |
|
|
52
|
+
| `excludePatterns` | string[] | [] | Glob patterns to skip |
|
|
53
|
+
| `includeHidden` | boolean | false | Include dotfiles |
|
|
54
|
+
| `includeSize` | boolean | false | Show file sizes |
|
|
55
|
+
| `maxFiles` | number | — | Limit total files returned |
|
|
56
|
+
|
|
57
|
+
**Example:** `directory_tree(path, maxDepth=3, excludePatterns=["node_modules", "dist"])`
|
|
58
|
+
|
|
59
|
+
### `list_directory`
|
|
60
|
+
|
|
61
|
+
Flat listing with metadata. Use for detailed file information.
|
|
62
|
+
|
|
63
|
+
| Parameter | Type | Default | Description |
|
|
64
|
+
| --------------- | ------- | ------- | ---------------------------------- |
|
|
65
|
+
| `path` | string | — | Directory to list |
|
|
66
|
+
| `recursive` | boolean | false | Include subdirectories |
|
|
67
|
+
| `sortBy` | enum | "name" | `name`, `size`, `modified`, `type` |
|
|
68
|
+
| `maxDepth` | number | 10 | Depth limit when recursive |
|
|
69
|
+
| `maxEntries` | number | — | Limit results (up to 100,000) |
|
|
70
|
+
| `includeHidden` | boolean | false | Include dotfiles |
|
|
71
|
+
|
|
72
|
+
### `analyze_directory`
|
|
73
|
+
|
|
74
|
+
Statistics: file counts, sizes, types, largest files, recent changes.
|
|
75
|
+
|
|
76
|
+
| Parameter | Type | Default | Description |
|
|
77
|
+
| ----------------- | -------- | ------- | ------------------------------ |
|
|
78
|
+
| `path` | string | — | Directory to analyze |
|
|
79
|
+
| `maxDepth` | number | 10 | How deep to analyze |
|
|
80
|
+
| `topN` | number | 10 | Number of largest/recent files |
|
|
81
|
+
| `excludePatterns` | string[] | [] | Patterns to skip |
|
|
82
|
+
| `includeHidden` | boolean | false | Include dotfiles |
|
|
83
|
+
|
|
84
|
+
### `search_files`
|
|
85
|
+
|
|
86
|
+
Find files by glob pattern. Returns paths, sizes, and modification dates.
|
|
87
|
+
|
|
88
|
+
| Parameter | Type | Default | Description |
|
|
89
|
+
| ----------------- | -------- | ------- | -------------------------------------- |
|
|
90
|
+
| `path` | string | — | Base directory |
|
|
91
|
+
| `pattern` | string | — | **Glob**: `**/*.ts`, `src/**/test*.js` |
|
|
92
|
+
| `excludePatterns` | string[] | [] | Patterns to skip |
|
|
93
|
+
| `maxResults` | number | — | Limit results (up to 10,000) |
|
|
94
|
+
| `maxDepth` | number | — | Depth limit |
|
|
95
|
+
| `sortBy` | enum | "path" | `name`, `size`, `modified`, `path` |
|
|
96
|
+
|
|
97
|
+
**Common patterns:**
|
|
98
|
+
|
|
99
|
+
- `**/*.ts` — All TypeScript files
|
|
100
|
+
- `src/**/*.{js,jsx}` — JS/JSX in src
|
|
101
|
+
- `**/test/**` — All test directories
|
|
102
|
+
- `**/*.test.ts` — Test files by convention
|
|
103
|
+
|
|
104
|
+
### `search_content`
|
|
105
|
+
|
|
106
|
+
Grep-like search inside files. Returns matching lines with context.
|
|
107
|
+
|
|
108
|
+
| Parameter | Type | Default | Description |
|
|
109
|
+
| ----------------- | -------- | ------- | --------------------------------------- |
|
|
110
|
+
| `path` | string | — | Base directory |
|
|
111
|
+
| `pattern` | string | — | **Regex**: `TODO\|FIXME`, `function\s+` |
|
|
112
|
+
| `filePattern` | string | `**/*` | Glob to filter files |
|
|
113
|
+
| `excludePatterns` | string[] | [] | Patterns to skip |
|
|
114
|
+
| `caseSensitive` | boolean | false | Case-sensitive matching |
|
|
115
|
+
| `wholeWord` | boolean | false | Match whole words only |
|
|
116
|
+
| `isLiteral` | boolean | false | Treat pattern as literal (not regex) |
|
|
117
|
+
| `contextLines` | number | 0 | Lines before/after match (0-10) |
|
|
118
|
+
| `maxResults` | number | 100 | Limit matches |
|
|
119
|
+
| `maxFilesScanned` | number | — | Limit files to scan |
|
|
120
|
+
| `maxFileSize` | number | 1MB | Skip files larger than this |
|
|
121
|
+
| `timeoutMs` | number | — | Operation timeout |
|
|
122
|
+
| `skipBinary` | boolean | true | Skip binary files |
|
|
123
|
+
|
|
124
|
+
**Example:** `search_content(path, pattern="export (function|class)", filePattern="**/*.ts", contextLines=2)`
|
|
125
|
+
|
|
126
|
+
### `read_file`
|
|
127
|
+
|
|
128
|
+
Read a single file with optional line selection.
|
|
129
|
+
|
|
130
|
+
| Parameter | Type | Default | Description |
|
|
131
|
+
| ----------- | ------ | ------- | ------------------------------------------- |
|
|
132
|
+
| `path` | string | — | File to read |
|
|
133
|
+
| `encoding` | enum | "utf-8" | `utf-8`, `ascii`, `base64`, `hex`, `latin1` |
|
|
134
|
+
| `maxSize` | number | 10MB | Maximum file size |
|
|
135
|
+
| `head` | number | — | Read first N lines only |
|
|
136
|
+
| `tail` | number | — | Read last N lines only |
|
|
137
|
+
| `lineStart` | number | — | Start line (1-indexed) |
|
|
138
|
+
| `lineEnd` | number | — | End line (inclusive) |
|
|
139
|
+
|
|
140
|
+
**⚠️ Cannot combine:** `head`/`tail` with `lineStart`/`lineEnd`
|
|
141
|
+
|
|
142
|
+
### `read_multiple_files`
|
|
143
|
+
|
|
144
|
+
**Preferred for 2+ files** — runs in parallel, individual failures don't block others.
|
|
145
|
+
|
|
146
|
+
| Parameter | Type | Default | Description |
|
|
147
|
+
| ---------- | -------- | ------- | ----------------------- |
|
|
148
|
+
| `paths` | string[] | — | Files to read (max 100) |
|
|
149
|
+
| `encoding` | enum | "utf-8" | Encoding for all files |
|
|
150
|
+
| `maxSize` | number | 10MB | Max size per file |
|
|
151
|
+
| `head` | number | — | First N lines from each |
|
|
152
|
+
| `tail` | number | — | Last N lines from each |
|
|
153
|
+
|
|
154
|
+
### `get_file_info`
|
|
155
|
+
|
|
156
|
+
Metadata only: size, timestamps, permissions, MIME type.
|
|
157
|
+
|
|
158
|
+
| Parameter | Type | Description |
|
|
159
|
+
| --------- | ------ | ----------------- |
|
|
160
|
+
| `path` | string | File or directory |
|
|
161
|
+
|
|
162
|
+
### `read_media_file`
|
|
163
|
+
|
|
164
|
+
Returns binary files as base64 with MIME type. Includes image dimensions.
|
|
165
|
+
|
|
166
|
+
| Parameter | Type | Default | Description |
|
|
167
|
+
| --------- | ------ | ------- | ------------------ |
|
|
168
|
+
| `path` | string | — | Path to media file |
|
|
169
|
+
| `maxSize` | number | 50MB | Maximum file size |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Efficiency Best Practices
|
|
174
|
+
|
|
175
|
+
### ✅ Do
|
|
176
|
+
|
|
177
|
+
- **Batch reads**: Use `read_multiple_files` for 2+ files
|
|
178
|
+
- **Limit scope**: Always set `maxResults`, `maxDepth`, `maxEntries`
|
|
179
|
+
- **Exclude noise**: Use `excludePatterns=["node_modules", ".git", "dist"]`
|
|
180
|
+
- **Preview large files**: Use `head=50` or `tail=50` before full read
|
|
181
|
+
- **Search then read**: `search_files` → `read_multiple_files`
|
|
182
|
+
|
|
183
|
+
### ❌ Don't
|
|
184
|
+
|
|
185
|
+
- Call `read_file` in a loop — use `read_multiple_files`
|
|
186
|
+
- Use `recursive=true` without `maxDepth` on large directories
|
|
187
|
+
- Search with `maxResults` unset on large codebases
|
|
188
|
+
- Read entire large files when you only need a section
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Common Workflows
|
|
193
|
+
|
|
194
|
+
### Project Discovery
|
|
195
|
+
|
|
196
|
+
```text
|
|
197
|
+
list_allowed_directories
|
|
198
|
+
directory_tree(path, maxDepth=3, excludePatterns=["node_modules",".git"])
|
|
199
|
+
analyze_directory(path, excludePatterns=["node_modules"])
|
|
200
|
+
read_multiple_files([package.json, README.md, tsconfig.json])
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Find and Read Code
|
|
204
|
+
|
|
205
|
+
```text
|
|
206
|
+
search_files(path, pattern="**/*.service.ts")
|
|
207
|
+
read_multiple_files([...results])
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Search Code Patterns
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
search_content(path, pattern="async function", filePattern="**/*.ts", contextLines=2)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Investigate Large Files
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
analyze_directory(path) → See largestFiles
|
|
220
|
+
get_file_info(largefile) → Check exact size
|
|
221
|
+
read_file(largefile, head=100) → Preview beginning
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Error Recovery
|
|
227
|
+
|
|
228
|
+
| Error Code | Meaning | Solution |
|
|
229
|
+
| ------------------- | ----------------------------- | ------------------------------------------- |
|
|
230
|
+
| `E_ACCESS_DENIED` | Path outside allowed dirs | Run `list_allowed_directories` |
|
|
231
|
+
| `E_NOT_FOUND` | Path doesn't exist | Use `list_directory` to explore |
|
|
232
|
+
| `E_NOT_FILE` | Expected file, got directory | Use `list_directory` or `directory_tree` |
|
|
233
|
+
| `E_NOT_DIRECTORY` | Expected directory, got file | Use `read_file` or `get_file_info` |
|
|
234
|
+
| `E_TOO_LARGE` | File exceeds size limit | Use `head`/`tail` or increase `maxSize` |
|
|
235
|
+
| `E_BINARY_FILE` | Binary file in text operation | Use `read_media_file` instead |
|
|
236
|
+
| `E_TIMEOUT` | Operation too slow | Reduce `maxResults`, `maxDepth`, `maxFiles` |
|
|
237
|
+
| `E_INVALID_PATTERN` | Bad glob/regex syntax | Check pattern syntax |
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Security Notes
|
|
242
|
+
|
|
243
|
+
- **Read-only**: No writes, deletes, or modifications possible
|
|
244
|
+
- **Path validation**: Symlinks cannot escape allowed directories
|
|
245
|
+
- **Binary detection**: Prevents accidental large base64 in text output
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-codebase.d.ts","sourceRoot":"","sources":["../../src/prompts/analyze-codebase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAkErE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { completable } from '@modelcontextprotocol/sdk/server/completable.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getAllowedDirectories } from '../lib/path-validation.js';
|
|
4
|
+
export function registerAnalyzeCodebasePrompt(server) {
|
|
5
|
+
server.registerPrompt('analyze-codebase', {
|
|
6
|
+
description: 'Deep analysis of code patterns, architecture, and implementation details in a codebase',
|
|
7
|
+
argsSchema: {
|
|
8
|
+
path: completable(z.string().min(1).describe('Root path of the codebase to analyze'), (value) => {
|
|
9
|
+
const dirs = getAllowedDirectories();
|
|
10
|
+
return dirs.filter((d) => d.toLowerCase().includes(value.toLowerCase()) ||
|
|
11
|
+
value.toLowerCase().includes(d.toLowerCase().slice(0, 10)));
|
|
12
|
+
}),
|
|
13
|
+
focus: z
|
|
14
|
+
.enum(['architecture', 'patterns', 'quality', 'security', 'all'])
|
|
15
|
+
.optional()
|
|
16
|
+
.default('all')
|
|
17
|
+
.describe('Analysis focus area (default: all)'),
|
|
18
|
+
filePattern: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.default('**/*.{ts,js,py,java,go,rs}')
|
|
22
|
+
.describe('Glob pattern for files to analyze (default: common source files)'),
|
|
23
|
+
},
|
|
24
|
+
}, ({ path, focus, filePattern }) => ({
|
|
25
|
+
messages: [
|
|
26
|
+
{
|
|
27
|
+
role: 'user',
|
|
28
|
+
content: {
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: `Perform a deep analysis of the codebase at "${path}" with focus on: ${focus}.
|
|
31
|
+
|
|
32
|
+
Use the available filesystem tools systematically:
|
|
33
|
+
|
|
34
|
+
1. **Discovery Phase**
|
|
35
|
+
- Use \`directory_tree\` to understand the overall structure
|
|
36
|
+
- Use \`search_files\` with pattern "${filePattern}" to find source files
|
|
37
|
+
- Use \`analyze_directory\` to get file statistics and identify largest/most recent files
|
|
38
|
+
|
|
39
|
+
2. **Code Inspection Phase**
|
|
40
|
+
- Use \`search_content\` to find key patterns:
|
|
41
|
+
${focus === 'architecture' || focus === 'all' ? '- Search for class/interface definitions, exports, imports' : ''}
|
|
42
|
+
${focus === 'patterns' || focus === 'all' ? '- Search for common design patterns (Factory, Singleton, Observer, etc.)' : ''}
|
|
43
|
+
${focus === 'quality' || focus === 'all' ? '- Search for TODO, FIXME, HACK comments' : ''}
|
|
44
|
+
${focus === 'security' || focus === 'all' ? '- Search for potential security concerns (eval, exec, password, secret, token)' : ''}
|
|
45
|
+
- Use \`read_multiple_files\` to examine key files identified in discovery
|
|
46
|
+
|
|
47
|
+
3. **Analysis Deliverables**
|
|
48
|
+
${focus === 'architecture' || focus === 'all' ? '- **Architecture**: Module organization, dependency flow, layering patterns' : ''}
|
|
49
|
+
${focus === 'patterns' || focus === 'all' ? '- **Design Patterns**: Identified patterns, their usage, and effectiveness' : ''}
|
|
50
|
+
${focus === 'quality' || focus === 'all' ? '- **Code Quality**: Technical debt indicators, documentation coverage, consistency' : ''}
|
|
51
|
+
${focus === 'security' || focus === 'all' ? '- **Security**: Potential vulnerabilities, hardcoded secrets, input validation' : ''}
|
|
52
|
+
- **Recommendations**: Prioritized list of improvements with rationale`,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=analyze-codebase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-codebase.js","sourceRoot":"","sources":["../../src/prompts/analyze-codebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAG9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,UAAU,6BAA6B,CAAC,MAAiB;IAC7D,MAAM,CAAC,cAAc,CACnB,kBAAkB,EAClB;QACE,WAAW,EACT,wFAAwF;QAC1F,UAAU,EAAE;YACV,IAAI,EAAE,WAAW,CACf,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC,EAClE,CAAC,KAAK,EAAE,EAAE;gBACR,MAAM,IAAI,GAAG,qBAAqB,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC,MAAM,CAChB,CAAC,CAAC,EAAE,EAA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,cAAc,IAAI,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,6EAA6E,CAAC,CAAC,CAAC,EAAE;KAChI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,4EAA4E,CAAC,CAAC,CAAC,EAAE;KAC3H,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,oFAAoF,CAAC,CAAC,CAAC,EAAE;KAClI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,gFAAgF,CAAC,CAAC,CAAC,EAAE;0EAC1D;iBAC/D;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem-query.d.ts","sourceRoot":"","sources":["../../src/prompts/filesystem-query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAkIrE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { completable } from '@modelcontextprotocol/sdk/server/completable.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getAllowedDirectories } from '../lib/path-validation.js';
|
|
4
|
+
export function registerFilesystemQueryPrompt(server) {
|
|
5
|
+
server.registerPrompt('filesystem-query', {
|
|
6
|
+
description: 'A guided prompt for performing common filesystem exploration and analysis tasks. Provides structured guidance based on the selected operation type.',
|
|
7
|
+
argsSchema: {
|
|
8
|
+
path: completable(z.string().min(1).describe('Target path for the operation'), (value) => {
|
|
9
|
+
const dirs = getAllowedDirectories();
|
|
10
|
+
return dirs.filter((d) => d.toLowerCase().includes(value.toLowerCase()) ||
|
|
11
|
+
value.toLowerCase().includes(d.toLowerCase().slice(0, 10)));
|
|
12
|
+
}),
|
|
13
|
+
operation: z
|
|
14
|
+
.enum([
|
|
15
|
+
'explore',
|
|
16
|
+
'find-files',
|
|
17
|
+
'search-code',
|
|
18
|
+
'analyze-size',
|
|
19
|
+
'recent-changes',
|
|
20
|
+
])
|
|
21
|
+
.describe('Operation type: explore (structure), find-files (by pattern), search-code (content search), analyze-size (disk usage), recent-changes (modified files)'),
|
|
22
|
+
pattern: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Search pattern (glob for find-files, regex for search-code)'),
|
|
26
|
+
depth: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.min(1)
|
|
30
|
+
.max(20)
|
|
31
|
+
.optional()
|
|
32
|
+
.default(5)
|
|
33
|
+
.describe('Maximum depth for exploration (default: 5)'),
|
|
34
|
+
},
|
|
35
|
+
}, ({ path, operation, pattern, depth }) => {
|
|
36
|
+
const operationPrompts = {
|
|
37
|
+
explore: `Explore the filesystem structure at "${path}".
|
|
38
|
+
|
|
39
|
+
Use these tools in sequence:
|
|
40
|
+
1. \`directory_tree\` with maxDepth=${String(depth)} to visualize the hierarchy
|
|
41
|
+
2. \`analyze_directory\` to get file statistics (types, sizes, counts)
|
|
42
|
+
3. \`list_directory\` with sortBy="modified" for recent activity
|
|
43
|
+
|
|
44
|
+
Provide:
|
|
45
|
+
- **Structure Overview**: Main directories and their purposes
|
|
46
|
+
- **File Distribution**: Breakdown by type and location
|
|
47
|
+
- **Key Files**: Important configuration or entry point files
|
|
48
|
+
- **Notable Findings**: Unusual patterns or large files`,
|
|
49
|
+
'find-files': `Find files matching pattern "${pattern ?? '**/*'}" in "${path}".
|
|
50
|
+
|
|
51
|
+
Use these tools:
|
|
52
|
+
1. \`search_files\` with pattern="${pattern ?? '**/*'}" to find matching files
|
|
53
|
+
2. \`read_multiple_files\` to examine the most relevant matches
|
|
54
|
+
3. Optionally \`get_file_info\` for detailed metadata on specific files
|
|
55
|
+
|
|
56
|
+
Provide:
|
|
57
|
+
- **Matched Files**: List with paths and sizes
|
|
58
|
+
- **Pattern Analysis**: What the pattern captured
|
|
59
|
+
- **Content Preview**: Summary of matched file contents
|
|
60
|
+
- **Suggestions**: Related patterns that might be useful`,
|
|
61
|
+
'search-code': `Search for code pattern "${pattern ?? ''}" in "${path}".
|
|
62
|
+
|
|
63
|
+
Use these tools:
|
|
64
|
+
1. \`search_content\` with pattern="${pattern ?? ''}" and contextLines=2
|
|
65
|
+
2. \`read_multiple_files\` to get full context for important matches
|
|
66
|
+
3. Group results by file and analyze patterns
|
|
67
|
+
|
|
68
|
+
Provide:
|
|
69
|
+
- **Match Summary**: Total matches, files affected
|
|
70
|
+
- **Code Context**: Key matches with surrounding code
|
|
71
|
+
- **Pattern Usage**: How and where the pattern appears
|
|
72
|
+
- **Related Code**: Suggest related patterns to explore`,
|
|
73
|
+
'analyze-size': `Analyze disk usage and file sizes in "${path}".
|
|
74
|
+
|
|
75
|
+
Use these tools:
|
|
76
|
+
1. \`analyze_directory\` to get size statistics and largest files
|
|
77
|
+
2. \`directory_tree\` with includeSize=true for size visualization
|
|
78
|
+
3. \`search_files\` to find specific file types if needed
|
|
79
|
+
|
|
80
|
+
Provide:
|
|
81
|
+
- **Size Summary**: Total size, file count, directory count
|
|
82
|
+
- **Largest Files**: Top 10 with sizes and paths
|
|
83
|
+
- **Type Breakdown**: Size by file extension
|
|
84
|
+
- **Cleanup Suggestions**: Files that could be removed or compressed`,
|
|
85
|
+
'recent-changes': `Find recently modified files in "${path}".
|
|
86
|
+
|
|
87
|
+
Use these tools:
|
|
88
|
+
1. \`analyze_directory\` to see recentlyModified list
|
|
89
|
+
2. \`list_directory\` with sortBy="modified" for detailed listing
|
|
90
|
+
3. \`read_multiple_files\` to examine recent changes
|
|
91
|
+
|
|
92
|
+
Provide:
|
|
93
|
+
- **Recent Activity**: Files modified in last 24h, week, month
|
|
94
|
+
- **Change Patterns**: Which areas are most active
|
|
95
|
+
- **File Diffs**: Summary of what changed in key files
|
|
96
|
+
- **Activity Insights**: Development patterns or areas of focus`,
|
|
97
|
+
};
|
|
98
|
+
const promptText = operationPrompts[operation] ??
|
|
99
|
+
`Perform "${operation}" operation at "${path}".`;
|
|
100
|
+
return {
|
|
101
|
+
messages: [
|
|
102
|
+
{
|
|
103
|
+
role: 'user',
|
|
104
|
+
content: {
|
|
105
|
+
type: 'text',
|
|
106
|
+
text: promptText,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=filesystem-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem-query.js","sourceRoot":"","sources":["../../src/prompts/filesystem-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAG9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,UAAU,6BAA6B,CAAC,MAAiB;IAC7D,MAAM,CAAC,cAAc,CACnB,kBAAkB,EAClB;QACE,WAAW,EACT,qJAAqJ;QACvJ,UAAU,EAAE;YACV,IAAI,EAAE,WAAW,CACf,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAC3D,CAAC,KAAK,EAAE,EAAE;gBACR,MAAM,IAAI,GAAG,qBAAqB,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC,MAAM,CAChB,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;oBAC7C,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAC7D,CAAC;YACJ,CAAC,CACF;YACD,SAAS,EAAE,CAAC;iBACT,IA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}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-duplicates.d.ts","sourceRoot":"","sources":["../../src/prompts/find-duplicates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA8EpE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { completable } from '@modelcontextprotocol/sdk/server/completable.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getAllowedDirectories } from '../lib/path-validation.js';
|
|
4
|
+
export function registerFindDuplicatesPrompt(server) {
|
|
5
|
+
server.registerPrompt('find-duplicates', {
|
|
6
|
+
description: 'Find duplicate or similar code patterns, files, and potential refactoring opportunities',
|
|
7
|
+
argsSchema: {
|
|
8
|
+
path: completable(z.string().min(1).describe('Root path to search for duplicates'), (value) => {
|
|
9
|
+
const dirs = getAllowedDirectories();
|
|
10
|
+
return dirs.filter((d) => d.toLowerCase().includes(value.toLowerCase()) ||
|
|
11
|
+
value.toLowerCase().includes(d.toLowerCase().slice(0, 10)));
|
|
12
|
+
}),
|
|
13
|
+
pattern: z
|
|
14
|
+
.string()
|
|
15
|
+
.optional()
|
|
16
|
+
.default('**/*.{ts,js,tsx,jsx,py,java}')
|
|
17
|
+
.describe('Glob pattern for files to check (default: source files)'),
|
|
18
|
+
searchTerm: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Optional specific pattern or function name to find duplicates of'),
|
|
22
|
+
},
|
|
23
|
+
}, ({ path, pattern, searchTerm }) => ({
|
|
24
|
+
messages: [
|
|
25
|
+
{
|
|
26
|
+
role: 'user',
|
|
27
|
+
content: {
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: `Find duplicate code and refactoring opportunities in "${path}".
|
|
30
|
+
|
|
31
|
+
Use the available filesystem tools:
|
|
32
|
+
|
|
33
|
+
1. **File Discovery**
|
|
34
|
+
- Use \`search_files\` with pattern "${pattern}" to find all relevant files
|
|
35
|
+
- Use \`analyze_directory\` to identify files of similar sizes (potential duplicates)
|
|
36
|
+
|
|
37
|
+
2. **Content Analysis**
|
|
38
|
+
${searchTerm
|
|
39
|
+
? `- Use \`search_content\` to find all occurrences of "${searchTerm}"`
|
|
40
|
+
: `- Use \`search_content\` to find common duplicate patterns:
|
|
41
|
+
- Similar function signatures
|
|
42
|
+
- Repeated import statements
|
|
43
|
+
- Common utility patterns (error handling, logging, validation)
|
|
44
|
+
- Copied configuration blocks`}
|
|
45
|
+
|
|
46
|
+
3. **Detailed Inspection**
|
|
47
|
+
- Use \`read_multiple_files\` to compare files with similar sizes or names
|
|
48
|
+
- Look for:
|
|
49
|
+
- Copy-pasted code blocks
|
|
50
|
+
- Functions with similar logic but different names
|
|
51
|
+
- Repeated patterns that could be abstracted
|
|
52
|
+
- Similar error handling or validation logic
|
|
53
|
+
|
|
54
|
+
4. **Report Findings**
|
|
55
|
+
- **Exact Duplicates**: Files or code blocks that are identical
|
|
56
|
+
- **Near Duplicates**: Similar code with minor variations
|
|
57
|
+
- **Pattern Opportunities**: Repeated patterns that could be abstracted into utilities
|
|
58
|
+
- **Refactoring Suggestions**: Specific recommendations with:
|
|
59
|
+
- Which files are affected
|
|
60
|
+
- Proposed abstraction or consolidation
|
|
61
|
+
- Estimated complexity reduction
|
|
62
|
+
- Potential risks of refactoring`,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=find-duplicates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-duplicates.js","sourceRoot":"","sources":["../../src/prompts/find-duplicates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAG9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAA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ACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQzE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAM1D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { registerAnalyzeCodebasePrompt } from './analyze-codebase.js';
|
|
2
|
+
import { registerFilesystemQueryPrompt } from './filesystem-query.js';
|
|
3
|
+
import { registerFindDuplicatesPrompt } from './find-duplicates.js';
|
|
4
|
+
import { registerProjectOverviewPrompt } from './project-overview.js';
|
|
5
|
+
import { registerSearchAndReplacePrompt } from './search-and-replace.js';
|
|
6
|
+
export function registerAllPrompts(server) {
|
|
7
|
+
registerProjectOverviewPrompt(server);
|
|
8
|
+
registerAnalyzeCodebasePrompt(server);
|
|
9
|
+
registerFindDuplicatesPrompt(server);
|
|
10
|
+
registerSearchAndReplacePrompt(server);
|
|
11
|
+
registerFilesystemQueryPrompt(server);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.js.map
|