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 +15 -2
- package/package.json +1 -1
- package/src/config.js +24 -9
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
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'
|
|
441
|
-
|
|
442
|
-
|
|
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
|
-
|
|
464
|
+
// Normalize Git Bash paths (/c/Users/... -> C:\Users\...)
|
|
465
|
+
config.server.client_cwd = normalizeGitBashPath(detectedCwd);
|
|
451
466
|
configLogger.debug(
|
|
452
|
-
`
|
|
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(
|