@j0hanz/fs-context-mcp 2.0.4 → 2.0.5
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/dist/instructions.md +182 -68
- package/package.json +1 -1
package/dist/instructions.md
CHANGED
|
@@ -1,112 +1,226 @@
|
|
|
1
|
-
# FS Context MCP Server
|
|
1
|
+
# FS Context MCP Server — AI Usage Instructions
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
This server can only access explicitly allowed “workspace roots” and never writes to disk.
|
|
3
|
+
Use this server to explore, search, and read filesystem content within allowed workspace roots. All operations are read-only. Prefer using these tools over "remembering" file contents in chat.
|
|
5
4
|
|
|
6
5
|
---
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Operating Rules
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
- Use tools only when you need to verify, discover, or read filesystem state.
|
|
10
|
+
- Call `roots` first to confirm accessible directories before any other operation.
|
|
11
|
+
- Operate by paths (relative to roots when practical) rather than guessing file locations.
|
|
12
|
+
- Batch operations when available: use `read_many` for 2+ files, `stat_many` for 2+ metadata checks.
|
|
13
|
+
- All tools are read-only; no destructive operations exist.
|
|
14
|
+
- Keep operations atomic; if a request is vague, ask a clarifying question before calling tools.
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
### Quick Decision Rules
|
|
17
|
+
|
|
18
|
+
- If you are unsure what directories are accessible: call `roots` first.
|
|
19
|
+
- If you need to locate files by name or pattern: use `find` (glob search).
|
|
20
|
+
- If you need to locate text inside files: use `grep` (content search).
|
|
21
|
+
- If reading multiple files: use `read_many` (up to 100 paths).
|
|
22
|
+
- If unsure whether a file is text or binary: use `stat` to check `mimeType` first.
|
|
23
|
+
- If a file is too large: use `head` parameter to preview first N lines.
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
### Client UX Notes (VS Code)
|
|
20
26
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- **Symlink policy:** directory scans do not traverse symlinked directories; direct symlink targets are allowed only if they resolve within roots.
|
|
27
|
+
- Non-read-only tools typically require user confirmation — this server has none.
|
|
28
|
+
- Tool lists can be cached; users can reset cached tools via **MCP: Reset Cached Tools**.
|
|
29
|
+
- Only run MCP servers from trusted sources; VS Code prompts users to trust servers.
|
|
25
30
|
|
|
26
31
|
---
|
|
27
32
|
|
|
28
|
-
##
|
|
33
|
+
## Data Model (What the Server Operates On)
|
|
34
|
+
|
|
35
|
+
### Workspace Roots
|
|
36
|
+
|
|
37
|
+
- Absolute directory paths the server is allowed to access.
|
|
38
|
+
- Configured via CLI arguments, `--allow-cwd` flag, or client-provided MCP Roots protocol.
|
|
39
|
+
- All path operations are validated against these roots.
|
|
40
|
+
|
|
41
|
+
### File/Directory Entries
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
- `name` — basename of the entry
|
|
44
|
+
- `path` — absolute or relative path
|
|
45
|
+
- `type` — `file` | `directory` | `symlink` | `other`
|
|
46
|
+
- `size` — bytes (optional for directories)
|
|
47
|
+
- `modified` — ISO 8601 timestamp
|
|
48
|
+
- `mimeType` — extension-based MIME type (for `stat` results)
|
|
49
|
+
|
|
50
|
+
### Search Matches (grep)
|
|
51
|
+
|
|
52
|
+
- `file` — relative path from search base
|
|
53
|
+
- `line` — 1-based line number
|
|
54
|
+
- `content` — matched line text (truncated to 200 chars)
|
|
40
55
|
|
|
41
56
|
---
|
|
42
57
|
|
|
43
|
-
##
|
|
58
|
+
## Workflows (Recommended)
|
|
44
59
|
|
|
45
|
-
### Project
|
|
60
|
+
### 1) Project Discovery
|
|
46
61
|
|
|
47
62
|
```text
|
|
48
|
-
roots
|
|
49
|
-
ls(path=".")
|
|
50
|
-
read_many(paths=["package.json", "README.md"]
|
|
63
|
+
roots → confirm access
|
|
64
|
+
ls(path=".") → see top-level structure
|
|
65
|
+
read_many(paths=["package.json", "README.md"]) → understand project
|
|
51
66
|
```
|
|
52
67
|
|
|
53
|
-
###
|
|
68
|
+
### 2) Find & Read Code
|
|
54
69
|
|
|
55
70
|
```text
|
|
56
|
-
find(pattern="
|
|
57
|
-
grep(path="src", pattern="registerTool")
|
|
58
|
-
read(path="src/tools.ts", head=
|
|
71
|
+
find(pattern="**/*.ts", maxResults=500) → locate candidates
|
|
72
|
+
grep(path="src", pattern="registerTool") → find references
|
|
73
|
+
read(path="src/tools.ts", head=100) → read implementation
|
|
59
74
|
```
|
|
60
75
|
|
|
61
|
-
### Check
|
|
76
|
+
### 3) Check Before Reading (Avoid Binary/Huge Files)
|
|
62
77
|
|
|
63
78
|
```text
|
|
64
|
-
stat(path="docs/logo.png")
|
|
65
|
-
stat_many(paths=["README.md", "dist/index.js"])
|
|
79
|
+
stat(path="docs/logo.png") → confirm type/size
|
|
80
|
+
stat_many(paths=["README.md", "dist/index.js"])→ batch metadata check
|
|
66
81
|
```
|
|
67
82
|
|
|
68
83
|
---
|
|
69
84
|
|
|
70
|
-
##
|
|
85
|
+
## Tools (What to Use, When)
|
|
86
|
+
|
|
87
|
+
### roots
|
|
88
|
+
|
|
89
|
+
List workspace roots this server can access.
|
|
90
|
+
|
|
91
|
+
- Use when: first call in any session, or when access errors occur.
|
|
92
|
+
- Args: none
|
|
93
|
+
- Notes: If empty, no other tools will work until roots are configured.
|
|
94
|
+
|
|
95
|
+
### ls
|
|
96
|
+
|
|
97
|
+
List immediate contents of a directory (non-recursive).
|
|
98
|
+
|
|
99
|
+
- Use when: orienting in a directory, seeing what files exist.
|
|
100
|
+
- Args:
|
|
101
|
+
- `path` (optional) — directory to list; omit for first root
|
|
102
|
+
- `includeHidden` (optional, default false) — include dotfiles
|
|
103
|
+
- Notes: Returns name, relativePath, type, size, modified. Use `find` for recursive search.
|
|
104
|
+
|
|
105
|
+
### find
|
|
106
|
+
|
|
107
|
+
Find files by glob pattern (e.g., `**/*.ts`).
|
|
108
|
+
|
|
109
|
+
- Use when: locating files by name/extension pattern.
|
|
110
|
+
- Args:
|
|
111
|
+
- `pattern` (required) — glob pattern (max 1000 chars, no absolute paths)
|
|
112
|
+
- `path` (optional) — base directory; omit for first root
|
|
113
|
+
- `maxResults` (optional, default 100, max 10000)
|
|
114
|
+
- `includeIgnored` (optional, default false) — include node_modules, dist, .git, etc.
|
|
115
|
+
- Notes: Default excludes common build/dependency directories. Returns relative paths.
|
|
116
|
+
|
|
117
|
+
### grep
|
|
118
|
+
|
|
119
|
+
Search for text within file contents (case-insensitive, literal match).
|
|
71
120
|
|
|
72
|
-
|
|
121
|
+
- Use when: finding references, function usages, or specific text in code.
|
|
122
|
+
- Args:
|
|
123
|
+
- `pattern` (required) — text to search for (max 1000 chars)
|
|
124
|
+
- `path` (optional) — directory or single file to search; omit for first root
|
|
125
|
+
- `includeHidden` (optional, default false) — include dotfiles
|
|
126
|
+
- Notes: Skips binary files and files > 1MB (configurable). Returns file, line, content.
|
|
73
127
|
|
|
74
|
-
|
|
75
|
-
- Default behavior excludes common directories like `node_modules`, `dist`, `.git`, etc.
|
|
76
|
-
Use `includeIgnored=true` when you explicitly want to search those.
|
|
77
|
-
- Prefer scoping with `path` and limiting with `maxResults` for large repos.
|
|
128
|
+
### read
|
|
78
129
|
|
|
79
|
-
|
|
130
|
+
Read text contents of a single file.
|
|
80
131
|
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
132
|
+
- Use when: opening one file, previewing large files.
|
|
133
|
+
- Args:
|
|
134
|
+
- `path` (required) — file path
|
|
135
|
+
- `head` (optional, 1-100000) — read only first N lines
|
|
136
|
+
- Notes: Rejects binary files. Use `head` for large files to avoid E_TOO_LARGE.
|
|
84
137
|
|
|
85
|
-
###
|
|
138
|
+
### read_many
|
|
86
139
|
|
|
87
|
-
|
|
88
|
-
- Matching is **case-insensitive**.
|
|
89
|
-
- By design, it **skips binary files** and **skips very large files** (size limits are configurable by the server environment).
|
|
90
|
-
“No matches” is not proof that a string doesn’t exist in a binary/large file.
|
|
140
|
+
Read multiple text files in one request.
|
|
91
141
|
|
|
92
|
-
|
|
142
|
+
- Use when: opening 2+ files efficiently.
|
|
143
|
+
- Args:
|
|
144
|
+
- `paths` (required) — array of file paths (max 100)
|
|
145
|
+
- `head` (optional) — limit lines per file
|
|
146
|
+
- Notes: Does not detect binary; use `stat_many` first if unsure. Returns per-file results with content or error.
|
|
93
147
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
148
|
+
### stat
|
|
149
|
+
|
|
150
|
+
Get metadata for a single file or directory.
|
|
151
|
+
|
|
152
|
+
- Use when: checking file type, size, or mimeType before reading.
|
|
153
|
+
- Args:
|
|
154
|
+
- `path` (required) — file or directory path
|
|
155
|
+
- Notes: Returns name, path, type, size, modified, permissions, mimeType, symlinkTarget.
|
|
156
|
+
|
|
157
|
+
### stat_many
|
|
158
|
+
|
|
159
|
+
Get metadata for multiple files/directories in one request.
|
|
160
|
+
|
|
161
|
+
- Use when: batch checking 2+ paths.
|
|
162
|
+
- Args:
|
|
163
|
+
- `paths` (required) — array of paths (max 100)
|
|
164
|
+
- Notes: Returns per-path results with info or error.
|
|
97
165
|
|
|
98
166
|
---
|
|
99
167
|
|
|
100
|
-
##
|
|
168
|
+
## Response Shape
|
|
101
169
|
|
|
102
|
-
|
|
103
|
-
|
|
170
|
+
All tools return structured JSON with:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"ok": true
|
|
175
|
+
// ... tool-specific data
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
On error:
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"ok": false,
|
|
184
|
+
"error": {
|
|
185
|
+
"code": "E_NOT_FOUND",
|
|
186
|
+
"message": "File not found: src/missing.ts",
|
|
187
|
+
"path": "src/missing.ts",
|
|
188
|
+
"suggestion": "Check the path exists within allowed roots"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Common Error Codes
|
|
194
|
+
|
|
195
|
+
| Code | Meaning | Resolution |
|
|
196
|
+
| --------------------- | ----------------------- | --------------------------------- |
|
|
197
|
+
| `E_ACCESS_DENIED` | Path outside roots | Check `roots`, use valid path |
|
|
198
|
+
| `E_NOT_FOUND` | Path does not exist | Verify path with `ls` or `find` |
|
|
199
|
+
| `E_NOT_FILE` | Expected file, got dir | Use `ls` instead |
|
|
200
|
+
| `E_NOT_DIRECTORY` | Expected dir, got file | Use `read` instead |
|
|
201
|
+
| `E_TOO_LARGE` | File exceeds size limit | Use `head` parameter |
|
|
202
|
+
| `E_TIMEOUT` | Operation took too long | Narrow scope, reduce `maxResults` |
|
|
203
|
+
| `E_INVALID_PATTERN` | Malformed glob pattern | Simplify pattern |
|
|
204
|
+
| `E_PERMISSION_DENIED` | OS-level access denied | Check file permissions |
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Limits & Defaults
|
|
209
|
+
|
|
210
|
+
| Limit | Default | Configurable Via |
|
|
211
|
+
| ----------------------- | ---------- | ------------------------- |
|
|
212
|
+
| Max file size (read) | 10 MB | `MAX_FILE_SIZE` env |
|
|
213
|
+
| Max search file size | 1 MB | `MAX_SEARCH_SIZE` env |
|
|
214
|
+
| Search timeout | 30 seconds | `DEFAULT_SEARCH_TIMEOUT` |
|
|
215
|
+
| Max results (find) | 100 | `maxResults` arg (≤10000) |
|
|
216
|
+
| Max paths (read_many) | 100 | — |
|
|
217
|
+
| Line content truncation | 200 chars | — |
|
|
218
|
+
|
|
219
|
+
---
|
|
104
220
|
|
|
105
|
-
|
|
221
|
+
## Security Notes
|
|
106
222
|
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
- `
|
|
110
|
-
-
|
|
111
|
-
- `E_TIMEOUT` (narrow scope, reduce results)
|
|
112
|
-
- `E_PERMISSION_DENIED`
|
|
223
|
+
- **Read-only:** no writes, deletes, or modifications.
|
|
224
|
+
- **Path validation:** symlinks cannot escape allowed roots.
|
|
225
|
+
- **Binary detection:** `read` rejects binary files; `grep` skips them.
|
|
226
|
+
- **Input sanitization:** glob patterns validated to prevent ReDoS.
|
package/package.json
CHANGED