converse-mcp-server 2.19.3 → 2.20.0

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/bin/converse.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  * Converse MCP Server - CLI Entry Point
@@ -10,6 +10,19 @@ import { fileURLToPath, pathToFileURL } from 'url';
10
10
  import { dirname, join } from 'path';
11
11
  import { createRequire } from 'module';
12
12
 
13
+ // Capture the caller's working directory before we chdir to the package root.
14
+ // This is critical for resolving relative file paths passed by MCP clients.
15
+ // Parse --cwd <path> from CLI args as an explicit override.
16
+ const cwdArgIndex = process.argv.indexOf('--cwd');
17
+ const callerCwd = (cwdArgIndex !== -1 && process.argv[cwdArgIndex + 1])
18
+ ? process.argv[cwdArgIndex + 1]
19
+ : process.cwd();
20
+
21
+ // Expose as env var so config.js can pick it up (only if not already set)
22
+ if (!process.env.CLIENT_CWD) {
23
+ process.env.CLIENT_CWD = callerCwd;
24
+ }
25
+
13
26
  // Get the directory of this script
14
27
  const __filename = fileURLToPath(import.meta.url);
15
28
  const __dirname = dirname(__filename);
@@ -24,7 +37,7 @@ process.chdir(projectRoot);
24
37
  try {
25
38
  const indexPath = join(projectRoot, 'src/index.js');
26
39
  const { main } = await import(pathToFileURL(indexPath).href);
27
-
40
+
28
41
  // The main function will handle all logging appropriately based on transport type
29
42
  await main();
30
43
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "converse-mcp-server",
3
- "version": "2.19.3",
3
+ "version": "2.20.0",
4
4
  "description": "Converse MCP Server - Converse with other LLMs with chat and consensus tools",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/config.js CHANGED
@@ -10,7 +10,7 @@ import dotenv from 'dotenv';
10
10
  import { createLogger, configureLogger } from './utils/logger.js';
11
11
  import { ConfigurationError } from './utils/errorHandler.js';
12
12
  import { fileURLToPath } from 'url';
13
- import { dirname, join } from 'path';
13
+ import { dirname, join, resolve } from 'path';
14
14
  import { readFileSync } from 'fs';
15
15
 
16
16
  // Load environment variables from appropriate .env file
@@ -407,6 +407,23 @@ function validateApiKeyFormat(provider, apiKey) {
407
407
  }
408
408
  }
409
409
 
410
+ /**
411
+ * Normalize Git Bash paths to Windows paths on Windows.
412
+ * Converts /c/Users/... to C:\Users\... so path.resolve() works correctly.
413
+ * On non-Windows platforms, returns the path unchanged.
414
+ */
415
+ function normalizeGitBashPath(inputPath) {
416
+ if (
417
+ process.platform === 'win32' &&
418
+ /^\/[a-zA-Z]\//.test(inputPath)
419
+ ) {
420
+ return resolve(
421
+ inputPath[1].toUpperCase() + ':' + inputPath.slice(2).replace(/\//g, '\\'),
422
+ );
423
+ }
424
+ return inputPath;
425
+ }
426
+
410
427
  /**
411
428
  * Loads and validates complete configuration from environment variables
412
429
  * @returns {Promise<object>} Validated configuration object
@@ -437,19 +454,17 @@ export async function loadConfig() {
437
454
  for (const [key, schema] of Object.entries(CONFIG_SCHEMA.server)) {
438
455
  try {
439
456
  // Special handling for CLIENT_CWD - auto-detect if not explicitly set
440
- if (key === 'CLIENT_CWD' && !process.env[key]) {
441
- // Try to detect the client's working directory from various sources
442
- // When run via npx, INIT_CWD contains the directory where npx was invoked
443
- // PWD is another common variable set to the working directory
444
- // npm_config_local_prefix is set when run via npm/npx
445
- const detectedCwd =
457
+ if (key === 'CLIENT_CWD') {
458
+ const explicitCwd = process.env[key];
459
+ const detectedCwd = explicitCwd ||
446
460
  process.env.INIT_CWD ||
447
461
  process.env.PWD ||
448
462
  process.env.npm_config_local_prefix ||
449
463
  process.cwd();
450
- config.server.client_cwd = detectedCwd;
464
+ // Normalize Git Bash paths (/c/Users/... -> C:\Users\...)
465
+ config.server.client_cwd = normalizeGitBashPath(detectedCwd);
451
466
  configLogger.debug(
452
- `Auto-detected client working directory: ${detectedCwd}`,
467
+ `Client working directory: ${config.server.client_cwd}${explicitCwd ? ' (from CLIENT_CWD)' : ' (auto-detected)'}`,
453
468
  );
454
469
  } else {
455
470
  config.server[key.toLowerCase()] = validateEnvVar(