converse-mcp-server 3.1.0 → 3.2.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
@@ -2,13 +2,21 @@
2
2
 
3
3
  /**
4
4
  * Converse MCP Server - CLI Entry Point
5
- *
5
+ *
6
6
  * This script allows the MCP server to be run via npx/pnpm dlx for easy installation and execution.
7
7
  */
8
8
 
9
9
  import { fileURLToPath, pathToFileURL } from 'url';
10
10
  import { dirname, join } from 'path';
11
11
  import { createRequire } from 'module';
12
+ import { getPackageVersion } from '../src/utils/version.js';
13
+
14
+ // Answer --version before loading the server: version.js pulls in nothing but
15
+ // node builtins, so this stays a sub-100ms round trip for `npx converse -v`.
16
+ if (process.argv.includes('--version') || process.argv.includes('-v')) {
17
+ console.log(getPackageVersion());
18
+ process.exit(0);
19
+ }
12
20
 
13
21
  // Capture the caller's working directory before we chdir to the package root.
14
22
  // This is critical for resolving relative file paths passed by MCP clients.
@@ -45,4 +53,4 @@ try {
45
53
  // For http transport, this will be logged by the error handler in main
46
54
  // Just exit with error code
47
55
  process.exit(1);
48
- }
56
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "converse-mcp-server",
3
- "version": "3.1.0",
3
+ "version": "3.2.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/index.js CHANGED
@@ -19,7 +19,8 @@ import {
19
19
  import { createRouter } from './router.js';
20
20
  import { createHTTPTransport } from './transport/httpTransport.js';
21
21
  import { createLogger, startTimer } from './utils/logger.js';
22
- import { debugError } from './utils/console.js';
22
+ import { debugError, forceLog } from './utils/console.js';
23
+ import { getPackageVersion } from './utils/version.js';
23
24
  import { ConfigurationError } from './utils/errorHandler.js';
24
25
 
25
26
  const logger = createLogger('server');
@@ -36,7 +37,8 @@ Usage: node src/index.js [OPTIONS]
36
37
  Options:
37
38
  --transport <type> Transport type: stdio (default) or http
38
39
  --transport=<type> Alternative format for transport type
39
- --help Show this help message
40
+ --version, -v Print the server version and exit
41
+ --help, -h Show this help message
40
42
 
41
43
  Environment Variables:
42
44
  MCP_TRANSPORT Transport type (stdio or http)
@@ -90,8 +92,16 @@ function getTransportType() {
90
92
  }
91
93
 
92
94
  async function main() {
93
- // Check for help flag
94
95
  const args = process.argv.slice(2);
96
+
97
+ // Version is printed unconditionally (not via debugError) so it still reaches
98
+ // stdout when MCP_TRANSPORT=stdio is set — the process exits before any
99
+ // JSON-RPC traffic starts, so there is no stream to corrupt.
100
+ if (args.includes('--version') || args.includes('-v')) {
101
+ forceLog(getPackageVersion());
102
+ process.exit(0);
103
+ }
104
+
95
105
  if (args.includes('--help') || args.includes('-h')) {
96
106
  showHelp();
97
107
  process.exit(0);
@@ -6,26 +6,7 @@
6
6
  */
7
7
 
8
8
  import { generateHelpContent } from '../prompts/helpPrompt.js';
9
- import { readFileSync } from 'fs';
10
- import { fileURLToPath } from 'url';
11
- import { dirname, join } from 'path';
12
-
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = dirname(__filename);
15
-
16
- /**
17
- * Get the current server version from package.json
18
- * @returns {string} Server version
19
- */
20
- function getServerVersion() {
21
- try {
22
- const packagePath = join(__dirname, '../../package.json');
23
- const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
24
- return packageJson.version || 'unknown';
25
- } catch (error) {
26
- return 'unknown';
27
- }
28
- }
9
+ import { getPackageVersion } from '../utils/version.js';
29
10
 
30
11
  /**
31
12
  * Resource metadata for the help documentation
@@ -45,7 +26,7 @@ export const helpResourceMetadata = {
45
26
  */
46
27
  export async function helpResourceHandler(config = null) {
47
28
  const helpContent = generateHelpContent(config);
48
- const version = getServerVersion();
29
+ const version = getPackageVersion();
49
30
 
50
31
  // Add version information to the help content
51
32
  const contentWithVersion = `${helpContent}\n\n## Server Information\n\n- **Version**: ${version}\n- **Protocol**: MCP (Model Context Protocol)\n- **Server Type**: HTTP Transport\n- **Default Port**: 3157\n`;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Package Version Utility
3
+ *
4
+ * Single source for the server version so the CLI, MCP handshake and help
5
+ * resource never disagree about which version is running.
6
+ */
7
+
8
+ import { readFileSync } from 'fs';
9
+ import { fileURLToPath } from 'url';
10
+ import { dirname, join } from 'path';
11
+
12
+ let cachedVersion;
13
+
14
+ /**
15
+ * Get the server version from package.json
16
+ * @returns {string} Semver string, or 'unknown' if package.json is unreadable
17
+ */
18
+ export function getPackageVersion() {
19
+ if (cachedVersion === undefined) {
20
+ try {
21
+ const packagePath = join(
22
+ dirname(fileURLToPath(import.meta.url)),
23
+ '../../package.json',
24
+ );
25
+ cachedVersion = JSON.parse(readFileSync(packagePath, 'utf8')).version || 'unknown';
26
+ } catch {
27
+ cachedVersion = 'unknown';
28
+ }
29
+ }
30
+
31
+ return cachedVersion;
32
+ }