@mixio-pro/kalaasetu-mcp 2.3.28 → 2.3.29

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": "@mixio-pro/kalaasetu-mcp",
3
- "version": "2.3.28",
3
+ "version": "2.3.29",
4
4
  "description": "A powerful Model Context Protocol server providing AI tools for content generation and analysis",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
@@ -10,6 +10,9 @@ export function getStorage(): StorageProvider {
10
10
  const type = process.env.STORAGE_PROVIDER || "local";
11
11
  logger.info(`Initializing storage provider: ${type}`);
12
12
  logger.info(`Base path (cwd): ${process.cwd()}`);
13
+ if (process.env.VSCODE_CWD) {
14
+ logger.info(`VSCode CWD: ${process.env.VSCODE_CWD}`);
15
+ }
13
16
 
14
17
  if (type === "gcs") {
15
18
  const bucket = process.env.GCS_BUCKET;
@@ -20,7 +23,8 @@ export function getStorage(): StorageProvider {
20
23
 
21
24
  storageInstance = new GCSStorageProvider(bucket);
22
25
  } else {
23
- storageInstance = new LocalStorageProvider(process.cwd());
26
+ const basePath = process.env.VSCODE_CWD || process.cwd();
27
+ storageInstance = new LocalStorageProvider(basePath);
24
28
  }
25
29
 
26
30
  // Initialize async
@@ -13,19 +13,31 @@ export class LocalStorageProvider implements StorageProvider {
13
13
  // No-op for local
14
14
  }
15
15
 
16
- async readFile(filePath: string): Promise<Buffer> {
17
- let fullPath = filePath;
18
- if (!path.isAbsolute(filePath)) {
19
- fullPath = path.resolve(this.basePath, filePath);
16
+ private resolvePath(filePath: string): string {
17
+ if (path.isAbsolute(filePath)) {
18
+ return filePath;
19
+ }
20
+
21
+ // Handle LLM hallucinations: if path is relative but doesn't start with ./ or ../,
22
+ // and VSCODE_CWD is available, use it as the base.
23
+ if (
24
+ process.env.VSCODE_CWD &&
25
+ !filePath.startsWith("./") &&
26
+ !filePath.startsWith("../")
27
+ ) {
28
+ return path.resolve(process.env.VSCODE_CWD, filePath);
20
29
  }
30
+
31
+ return path.resolve(this.basePath, filePath);
32
+ }
33
+
34
+ async readFile(filePath: string): Promise<Buffer> {
35
+ const fullPath = this.resolvePath(filePath);
21
36
  return fs.promises.readFile(fullPath);
22
37
  }
23
38
 
24
39
  async writeFile(filePath: string, data: Buffer | string): Promise<string> {
25
- let fullPath = filePath;
26
- if (!path.isAbsolute(filePath)) {
27
- fullPath = path.resolve(this.basePath, filePath);
28
- }
40
+ const fullPath = this.resolvePath(filePath);
29
41
 
30
42
  const dir = path.dirname(fullPath);
31
43
  if (!fs.existsSync(dir)) {
@@ -36,10 +48,7 @@ export class LocalStorageProvider implements StorageProvider {
36
48
  }
37
49
 
38
50
  async exists(filePath: string): Promise<boolean> {
39
- let fullPath = filePath;
40
- if (!path.isAbsolute(filePath)) {
41
- fullPath = path.resolve(this.basePath, filePath);
42
- }
51
+ const fullPath = this.resolvePath(filePath);
43
52
  try {
44
53
  await fs.promises.access(fullPath, fs.constants.F_OK);
45
54
  return true;
@@ -49,10 +58,6 @@ export class LocalStorageProvider implements StorageProvider {
49
58
  }
50
59
 
51
60
  async getPublicUrl(filePath: string): Promise<string> {
52
- let fullPath = filePath;
53
- if (!path.isAbsolute(filePath)) {
54
- fullPath = path.resolve(this.basePath, filePath);
55
- }
56
- return fullPath;
61
+ return this.resolvePath(filePath);
57
62
  }
58
63
  }