@j0hanz/fs-context-mcp 2.0.4 → 2.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.
@@ -1,112 +1,131 @@
1
- # FS Context MCP Server
1
+ # FS Context MCP Server — AI Usage Instructions
2
2
 
3
- Read-only tools for safe filesystem inspection via the Model Context Protocol (MCP).
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
- ## TL;DR (Agent Workflow)
7
+ ## Operating Rules
9
8
 
10
- 1. `roots` learn what you can access
11
- 2. `ls` orient yourself in a directory
12
- 3. `find` locate candidate files by glob
13
- 4. `grep` find references/content (text search)
14
- 5. `read` / `read_many` → open the exact files you need
15
- 6. `stat` / `stat_many` → confirm type/size/mime before reading
9
+ - Call `roots` first to confirm accessible directories.
10
+ - Operate by paths relative to roots rather than guessing locations.
11
+ - Batch operations: `read_many` for 2+ files, `stat_many` for 2+ checks.
12
+ - If request is vague, ask clarifying questions before calling tools.
16
13
 
17
- ---
18
-
19
- ## Key Rules (Avoid Surprises)
14
+ ### Strategies
20
15
 
21
- - **Access is root-scoped:** if `roots` returns an empty list, other tools will fail until the client/CLI config provides roots.
22
- - **Paths must stay within roots:** attempts to escape (e.g., via `..` or symlinks that resolve outside roots) are denied.
23
- - **`find` is glob search; `grep` is content search:** use `find` to locate files, `grep` to locate text inside files.
24
- - **Symlink policy:** directory scans do not traverse symlinked directories; direct symlink targets are allowed only if they resolve within roots.
16
+ - **Discovery:** Unsure directories? Call `roots`. File name pattern? `find`. Content text? `grep`.
17
+ - **Reading:** Multiple files? `read_many`. Large file? `read` with `head`. Binary check? `stat`.
25
18
 
26
19
  ---
27
20
 
28
- ## Quick Reference
21
+ ## Data Model
29
22
 
30
- | Goal | Tool | Notes |
31
- | ---------------- | ----------- | ------------------------------------------------------------------------------ |
32
- | Check access | `roots` | Always call first |
33
- | List a directory | `ls` | Non-recursive; `includeHidden` optional |
34
- | Find files | `find` | Glob patterns; default excludes common build/deps unless `includeIgnored=true` |
35
- | Search text | `grep` | Literal, case-insensitive text search; can scan a dir or a single file |
36
- | Read one file | `read` | UTF-8 text; rejects binary; use `head` to preview |
37
- | Read many files | `read_many` | Up to 100 paths; may skip files if combined reads exceed budget |
38
- | File metadata | `stat` | Type, size, modified, permissions, mimeType (extension-based) |
39
- | Metadata batch | `stat_many` | Prefer for 2+ paths |
23
+ - **Workspace Roots:** Absolute paths; all operations validated against these.
24
+ - **Entries:** `name`, `path` (abs/rel), `type` (file/directory/symlink), `size`, `modified`.
25
+ - **Search Matches:** `file` (relative), `line`, `content` (truncated).
40
26
 
41
27
  ---
42
28
 
43
- ## Practical Recipes
29
+ ## Workflows
44
30
 
45
- ### Project discovery
31
+ ### 1) Project Discovery
46
32
 
47
33
  ```text
48
- roots
49
- ls(path=".")
50
- read_many(paths=["package.json", "README.md"], head=200)
34
+ roots → confirm access
35
+ ls(path=".") → see top-level structure
36
+ read_many(paths=["package.json", "README.md"]) → understand project
51
37
  ```
52
38
 
53
- ### Locate & open implementation
39
+ ### 2) Find & Read Code
54
40
 
55
41
  ```text
56
- find(pattern="src/**/*.ts", maxResults=2000)
57
- grep(path="src", pattern="registerTool")
58
- read(path="src/tools.ts", head=200)
42
+ find(pattern="**/*.ts", maxResults=500) → locate candidates
43
+ grep(path="src", pattern="registerTool") → find references
44
+ read(path="src/tools.ts", head=100) → read implementation
59
45
  ```
60
46
 
61
- ### Check before reading (avoid binary/huge files)
47
+ ### 3) Check Before Reading
62
48
 
63
49
  ```text
64
- stat(path="docs/logo.png")
65
- stat_many(paths=["README.md", "dist/index.js"])
50
+ stat(path="docs/logo.png") → confirm type/size
51
+ stat_many(paths=["README.md", "dist/index.js"])→ batch metadata check
66
52
  ```
67
53
 
68
54
  ---
69
55
 
70
- ## Tool Notes (Behavior That Matters)
56
+ ## Tools
57
+
58
+ ### roots
59
+
60
+ List accessible workspace roots.
61
+
62
+ - **Use when:** First call, or access errors.
63
+
64
+ ### ls
65
+
66
+ List immediate directory contents (non-recursive).
67
+
68
+ - **Args:** `path` (opt), `includeHidden` (opt/false).
69
+ - **Returns:** Name, type, size, modified.
70
+
71
+ ### find
72
+
73
+ Find files by glob pattern.
74
+
75
+ - **Args:** `pattern` (req, max 1000ch), `path` (opt), `maxResults` (opt/100), `includeIgnored` (opt/false).
76
+ - **Ref:** `**/*.ts` (recursive), `src/*` (flat). Matches relative paths.
71
77
 
72
- ### `find` (glob)
78
+ ### grep
73
79
 
74
- - Uses glob patterns like `**/*.ts` or `src/**/index.*`.
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.
80
+ Search text within file contents (literal, case-insensitive).
78
81
 
79
- Common patterns:
82
+ - **Args:** `pattern` (req), `path` (opt), `includeHidden` (opt/false).
83
+ - **Ref:** Skips binary files and >1MB files.
80
84
 
81
- - `**/*.ts`
82
- - `src/**/*.{ts,tsx}`
83
- - `**/*.test.ts`
85
+ ### read
86
+
87
+ Read single text file content.
88
+
89
+ - **Args:** `path` (req), `head` (opt/lines).
90
+ - **Ref:** Rejects binary. Use `head` for large files.
91
+
92
+ ### read_many
93
+
94
+ Read multiple text files.
95
+
96
+ - **Args:** `paths` (req, max 100), `head` (opt).
97
+ - **Ref:** No binary detection (use `stat` first). Returns per-file result/error.
98
+
99
+ ### stat / stat_many
100
+
101
+ Get metadata for single or multiple paths.
102
+
103
+ - **Args:** `path` (req) / `paths` (req).
104
+ - **Returns:** Type, size, modified, permissions, mimeType.
105
+
106
+ ---
84
107
 
85
- ### `grep` (text search)
108
+ ## Response Shape
86
109
 
87
- - Searches for **literal text** (not a user-supplied regex).
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.
110
+ Success: `{ "ok": true, ...data }`
111
+ Error: `{ "ok": false, "error": { "code": "E_...", "message": "...", "suggestion": "..." } }`
91
112
 
92
- ### `read` vs `read_many`
113
+ ### Common Errors
93
114
 
94
- - `read` is safest for text: it enforces size limits and refuses binary.
95
- - `read_many` is best for efficiency (2+ files), but it does **not** do binary detection.
96
- If you’re unsure, do `stat_many` first and only read obvious text files.
115
+ - `E_ACCESS_DENIED`: Path outside roots.
116
+ - `E_NOT_FOUND`: Path missing.
117
+ - `E_TOO_LARGE`: File exceeds limit (use `head`).
118
+ - `E_TIMEOUT`: Reduce scope/results.
97
119
 
98
120
  ---
99
121
 
100
- ## Output & Errors
122
+ ## Limits
101
123
 
102
- - Each tool returns structured data with `ok: true|false`.
103
- - On failure you’ll get `ok: false` with an `error` object containing at least `code` and `message` (often `path` and a `suggestion`).
124
+ - **Max Read:** 10MB (file), 1MB (search).
125
+ - **Max Items:** 100 (read/stat batch), 100 (find default).
126
+ - **Timeout:** 30s.
104
127
 
105
- Common error codes:
128
+ ## Security
106
129
 
107
- - `E_ACCESS_DENIED` (outside allowed roots)
108
- - `E_NOT_FOUND`, `E_NOT_FILE`, `E_NOT_DIRECTORY`
109
- - `E_TOO_LARGE` (use `head`)
110
- - `E_INVALID_PATTERN` (glob pattern issues in `find`)
111
- - `E_TIMEOUT` (narrow scope, reduce results)
112
- - `E_PERMISSION_DENIED`
130
+ - **Read-only:** No writes/deletes.
131
+ - **Sandboxed:** Symlinks cannot escape roots.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j0hanz/fs-context-mcp",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "mcpName": "io.github.j0hanz/fs-context",
5
5
  "description": "🔍 Read-only MCP server for secure filesystem exploration, searching, and analysis",
6
6
  "type": "module",