@philau2512/fast-context-mcp 1.5.5 → 1.5.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@philau2512/fast-context-mcp",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "description": "AI-driven semantic code search MCP server (Node.js) — Windsurf/Devin protocol",
5
5
  "type": "module",
6
6
  "main": "src/server.mjs",
@@ -53,4 +53,4 @@
53
53
  "access": "public"
54
54
  },
55
55
  "license": "MIT"
56
- }
56
+ }
@@ -1,5 +1,6 @@
1
1
  import { statSync } from "node:fs";
2
- import { isAbsolute } from "node:path";
2
+ import { homedir } from "node:os";
3
+ import { isAbsolute, normalize } from "node:path";
3
4
  import { z } from "zod";
4
5
 
5
6
  export const PROJECT_PATH_REQUIRED_MESSAGE =
@@ -10,6 +11,28 @@ export const projectPathSchema = z
10
11
  .trim()
11
12
  .min(1, PROJECT_PATH_REQUIRED_MESSAGE);
12
13
 
14
+ /**
15
+ * Check if a path points to the user's home directory or system root.
16
+ * @param {string} p
17
+ * @returns {boolean}
18
+ */
19
+ export function isHomeOrRootDir(p) {
20
+ if (!p || typeof p !== "string") return false;
21
+ const trimmed = p.trim();
22
+ if (trimmed === "/" || trimmed === "\\" || /^[a-zA-Z]:[\\/]*$/.test(trimmed)) {
23
+ return true;
24
+ }
25
+ const norm = normalize(trimmed).replace(/[\\/]+$/, "");
26
+ const home = normalize(homedir()).replace(/[\\/]+$/, "");
27
+ if (norm.toLowerCase() === home.toLowerCase()) {
28
+ return true;
29
+ }
30
+ if (/^[a-zA-Z]:$/.test(norm) || norm === "" || norm === "/" || norm === "\\") {
31
+ return true;
32
+ }
33
+ return false;
34
+ }
35
+
13
36
  /**
14
37
  * Validate the project root path provided to fast_context_search.
15
38
  * Returns null when valid, otherwise an MCP-friendly error string.
@@ -27,6 +50,10 @@ export function validateProjectPath(projectPath, statFn = statSync) {
27
50
  return `Error: project_path must be an absolute path, got: ${projectPath}`;
28
51
  }
29
52
 
53
+ if (isHomeOrRootDir(projectPath)) {
54
+ return `Error: project_path cannot be the user home directory or system root: ${projectPath}. Please provide the specific workspace path (e.g. 'C:/PROJECTS/my-app').`;
55
+ }
56
+
30
57
  try {
31
58
  const st = statFn(projectPath);
32
59
  if (!st.isDirectory()) {
package/src/server.mjs CHANGED
@@ -122,9 +122,8 @@ export function buildFastContextSearchTool({
122
122
  'Add local-language business terms only when needed.'
123
123
  ),
124
124
  project_path: projectPathSchema.describe(
125
- "MANDATORY: Absolute path to project root directory (required). " +
126
- "You MUST supply this parameter explicitly on every call (e.g. /Users/username/projects/myproject or C:/Users/username/projects/myproject). " +
127
- "Never leave empty or omit."
125
+ "Absolute path to the project root directory (REQUIRED). " +
126
+ "Pass the active workspace directory from your session context (e.g. 'C:/PROJECTS/myproject' or '/Users/name/projects/myproject')."
128
127
  ),
129
128
  tree_depth: z
130
129
  .number()