converse-mcp-server 1.9.0 → 1.10.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/.env.example +25 -11
- package/README.md +10 -5
- package/bin/converse.js +33 -30
- package/package.json +2 -3
- package/src/config.js +35 -5
- package/src/providers/google.js +63 -12
package/.env.example
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Converse MCP Server Environment Configuration
|
|
2
2
|
# Copy this file to .env and fill in your values
|
|
3
3
|
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
#
|
|
4
|
+
# ============================================
|
|
5
|
+
# Google/Gemini Configuration Options
|
|
6
|
+
# ============================================
|
|
7
|
+
# You can use EITHER Gemini Developer API OR Vertex AI
|
|
8
|
+
|
|
9
|
+
# Option 1: Gemini Developer API (simpler setup)
|
|
10
|
+
# Get your API key from: https://makersuite.google.com/app/apikey
|
|
11
|
+
# You can use either GOOGLE_API_KEY or GEMINI_API_KEY (GOOGLE_API_KEY takes priority)
|
|
12
|
+
GOOGLE_API_KEY=your_google_api_key_here
|
|
13
|
+
# or
|
|
14
14
|
GEMINI_API_KEY=your_gemini_api_key_here
|
|
15
15
|
|
|
16
|
+
# Option 2: Google Vertex AI (enterprise/production)
|
|
17
|
+
# Requires Google Cloud project with billing and Vertex AI API enabled
|
|
18
|
+
# Set these THREE variables together:
|
|
19
|
+
# GOOGLE_GENAI_USE_VERTEXAI=true
|
|
20
|
+
# GOOGLE_CLOUD_PROJECT=your-project-id
|
|
21
|
+
# GOOGLE_CLOUD_LOCATION=us-central1
|
|
22
|
+
|
|
23
|
+
# Optional: API version (v1, v1beta, v1alpha) - defaults to v1beta
|
|
24
|
+
# GOOGLE_API_VERSION=v1beta
|
|
25
|
+
|
|
26
|
+
# ============================================
|
|
27
|
+
# Other Provider API Keys
|
|
28
|
+
# ============================================
|
|
29
|
+
|
|
16
30
|
# Get your OpenAI API key from: https://platform.openai.com/api-keys
|
|
17
31
|
OPENAI_API_KEY=your_openai_api_key_here
|
|
18
32
|
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ You need at least one API key from these providers:
|
|
|
19
19
|
| Provider | Where to Get | Example Format |
|
|
20
20
|
|----------|-------------|----------------|
|
|
21
21
|
| **OpenAI** | [platform.openai.com/api-keys](https://platform.openai.com/api-keys) | `sk-proj-...` |
|
|
22
|
-
| **Google** | [makersuite.google.com/app/apikey](https://makersuite.google.com/app/apikey) | `AIzaSy...` |
|
|
22
|
+
| **Google/Gemini** | [makersuite.google.com/app/apikey](https://makersuite.google.com/app/apikey) | `AIzaSy...` |
|
|
23
23
|
| **X.AI** | [console.x.ai](https://console.x.ai/) | `xai-...` |
|
|
24
24
|
| **Anthropic** | [console.anthropic.com](https://console.anthropic.com/) | `sk-ant-...` |
|
|
25
25
|
| **Mistral** | [console.mistral.ai](https://console.mistral.ai/) | `wfBMkWL0...` |
|
|
@@ -33,7 +33,7 @@ You need at least one API key from these providers:
|
|
|
33
33
|
# Add the server with your API keys
|
|
34
34
|
claude mcp add converse \
|
|
35
35
|
-e OPENAI_API_KEY=your_key_here \
|
|
36
|
-
-e
|
|
36
|
+
-e GEMINI_API_KEY=your_key_here \
|
|
37
37
|
-e XAI_API_KEY=your_key_here \
|
|
38
38
|
-e ANTHROPIC_API_KEY=your_key_here \
|
|
39
39
|
-e MISTRAL_API_KEY=your_key_here \
|
|
@@ -55,7 +55,7 @@ Add this configuration to your Claude Desktop settings:
|
|
|
55
55
|
"args": ["converse-mcp-server"],
|
|
56
56
|
"env": {
|
|
57
57
|
"OPENAI_API_KEY": "your_key_here",
|
|
58
|
-
"
|
|
58
|
+
"GEMINI_API_KEY": "your_key_here",
|
|
59
59
|
"XAI_API_KEY": "your_key_here",
|
|
60
60
|
"ANTHROPIC_API_KEY": "your_key_here",
|
|
61
61
|
"MISTRAL_API_KEY": "your_key_here",
|
|
@@ -140,6 +140,11 @@ Get multiple AI models to analyze the same question simultaneously. Each model c
|
|
|
140
140
|
- **gpt-4o-mini**: Fast multimodal (128K context)
|
|
141
141
|
|
|
142
142
|
### Google/Gemini Models
|
|
143
|
+
|
|
144
|
+
**API Key Options**:
|
|
145
|
+
- **GEMINI_API_KEY**: For Gemini Developer API (recommended)
|
|
146
|
+
- **GOOGLE_API_KEY**: Alternative name (GEMINI_API_KEY takes priority)
|
|
147
|
+
- **Vertex AI**: Use `GOOGLE_GENAI_USE_VERTEXAI=true` with project/location settings
|
|
143
148
|
- **gemini-2.5-flash** (alias: `flash`): Ultra-fast (1M context)
|
|
144
149
|
- **gemini-2.5-pro** (alias: `pro`): Deep reasoning (1M context)
|
|
145
150
|
- **gemini-2.0-flash**: Latest with experimental thinking
|
|
@@ -195,7 +200,7 @@ Create a `.env` file in your project root:
|
|
|
195
200
|
```bash
|
|
196
201
|
# Required: At least one API key
|
|
197
202
|
OPENAI_API_KEY=sk-proj-your_openai_key_here
|
|
198
|
-
|
|
203
|
+
GEMINI_API_KEY=your_gemini_api_key_here # Or GOOGLE_API_KEY (GEMINI_API_KEY takes priority)
|
|
199
204
|
XAI_API_KEY=xai-your_xai_key_here
|
|
200
205
|
ANTHROPIC_API_KEY=sk-ant-your_anthropic_key_here
|
|
201
206
|
MISTRAL_API_KEY=your_mistral_key_here
|
|
@@ -272,7 +277,7 @@ If you've cloned the repository locally:
|
|
|
272
277
|
],
|
|
273
278
|
"env": {
|
|
274
279
|
"OPENAI_API_KEY": "your_key_here",
|
|
275
|
-
"
|
|
280
|
+
"GEMINI_API_KEY": "your_key_here",
|
|
276
281
|
"XAI_API_KEY": "your_key_here",
|
|
277
282
|
"ANTHROPIC_API_KEY": "your_key_here",
|
|
278
283
|
"MISTRAL_API_KEY": "your_key_here",
|
package/bin/converse.js
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Converse MCP Server - CLI Entry Point
|
|
5
|
-
*
|
|
6
|
-
* This script allows the MCP server to be run via npx/pnpm dlx for easy installation and execution.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
10
|
-
import { dirname, join } from 'path';
|
|
11
|
-
import { createRequire } from 'module';
|
|
12
|
-
|
|
13
|
-
// Get the directory of this script
|
|
14
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
-
const __dirname = dirname(__filename);
|
|
16
|
-
|
|
17
|
-
// Get the project root (parent of bin directory)
|
|
18
|
-
const projectRoot = dirname(__dirname);
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
await
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converse MCP Server - CLI Entry Point
|
|
5
|
+
*
|
|
6
|
+
* This script allows the MCP server to be run via npx/pnpm dlx for easy installation and execution.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
10
|
+
import { dirname, join } from 'path';
|
|
11
|
+
import { createRequire } from 'module';
|
|
12
|
+
|
|
13
|
+
// Get the directory of this script
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
|
|
17
|
+
// Get the project root (parent of bin directory)
|
|
18
|
+
const projectRoot = dirname(__dirname);
|
|
19
|
+
|
|
20
|
+
// Change working directory to project root so Node.js can find dependencies
|
|
21
|
+
process.chdir(projectRoot);
|
|
22
|
+
|
|
23
|
+
// Import and start the server
|
|
24
|
+
try {
|
|
25
|
+
const indexPath = join(projectRoot, 'src/index.js');
|
|
26
|
+
const { main } = await import(pathToFileURL(indexPath).href);
|
|
27
|
+
|
|
28
|
+
// The main function will handle all logging appropriately based on transport type
|
|
29
|
+
await main();
|
|
30
|
+
} catch (error) {
|
|
31
|
+
// For stdio transport, we must not output anything to stdout
|
|
32
|
+
// For http transport, this will be logged by the error handler in main
|
|
33
|
+
// Just exit with error code
|
|
34
|
+
process.exit(1);
|
|
32
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "converse-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.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",
|
|
@@ -63,8 +63,7 @@
|
|
|
63
63
|
"validate": "node scripts/validate.js",
|
|
64
64
|
"validate:fix": "node scripts/validate.js --fix",
|
|
65
65
|
"validate:fast": "node scripts/validate.js --skip-tests --skip-lint",
|
|
66
|
-
"precommit": "npm run validate"
|
|
67
|
-
"prepublishOnly": "node scripts/fix-line-endings.js"
|
|
66
|
+
"precommit": "npm run validate"
|
|
68
67
|
},
|
|
69
68
|
"keywords": [
|
|
70
69
|
"mcp",
|
package/src/config.js
CHANGED
|
@@ -80,6 +80,7 @@ const CONFIG_SCHEMA = {
|
|
|
80
80
|
OPENAI_API_KEY: { type: 'string', required: false, secret: true, description: 'OpenAI API key' },
|
|
81
81
|
XAI_API_KEY: { type: 'string', required: false, secret: true, description: 'XAI API key' },
|
|
82
82
|
GOOGLE_API_KEY: { type: 'string', required: false, secret: true, description: 'Google API key' },
|
|
83
|
+
GEMINI_API_KEY: { type: 'string', required: false, secret: true, description: 'Gemini API key (alternative to GOOGLE_API_KEY)' },
|
|
83
84
|
ANTHROPIC_API_KEY: { type: 'string', required: false, secret: true, description: 'Anthropic API key' },
|
|
84
85
|
MISTRAL_API_KEY: { type: 'string', required: false, secret: true, description: 'Mistral API key' },
|
|
85
86
|
DEEPSEEK_API_KEY: { type: 'string', required: false, secret: true, description: 'DeepSeek API key' },
|
|
@@ -91,6 +92,12 @@ const CONFIG_SCHEMA = {
|
|
|
91
92
|
OPENROUTER_REFERER: { type: 'string', required: false, description: 'OpenRouter referer header for compliance' },
|
|
92
93
|
OPENROUTER_TITLE: { type: 'string', required: false, description: 'OpenRouter X-Title header for request tracking' },
|
|
93
94
|
OPENROUTER_DYNAMIC_MODELS: { type: 'boolean', default: false, description: 'Enable dynamic model discovery via OpenRouter endpoints API' },
|
|
95
|
+
|
|
96
|
+
// Google Vertex AI configuration
|
|
97
|
+
GOOGLE_GENAI_USE_VERTEXAI: { type: 'boolean', default: false, description: 'Use Google Vertex AI instead of Gemini Developer API' },
|
|
98
|
+
GOOGLE_CLOUD_PROJECT: { type: 'string', required: false, description: 'Google Cloud project ID for Vertex AI' },
|
|
99
|
+
GOOGLE_CLOUD_LOCATION: { type: 'string', required: false, description: 'Google Cloud location for Vertex AI (e.g., us-central1)' },
|
|
100
|
+
GOOGLE_API_VERSION: { type: 'string', default: 'v1beta', description: 'Google API version (v1, v1beta, v1alpha)' }
|
|
94
101
|
},
|
|
95
102
|
|
|
96
103
|
|
|
@@ -161,7 +168,10 @@ function validateApiKeyFormat(provider, apiKey) {
|
|
|
161
168
|
case 'xai':
|
|
162
169
|
return apiKey.startsWith('xai-') && apiKey.length > 20;
|
|
163
170
|
case 'google':
|
|
164
|
-
|
|
171
|
+
case 'gemini':
|
|
172
|
+
// Special case for Vertex AI marker
|
|
173
|
+
if (apiKey === 'VERTEX_AI') return true;
|
|
174
|
+
return apiKey.length > 20; // Google/Gemini keys vary in format
|
|
165
175
|
case 'anthropic':
|
|
166
176
|
return apiKey.startsWith('sk-ant-') && apiKey.length >= 30;
|
|
167
177
|
case 'mistral':
|
|
@@ -232,7 +242,15 @@ export async function loadConfig() {
|
|
|
232
242
|
const value = validateEnvVar(key, process.env[key], schema);
|
|
233
243
|
if (value) {
|
|
234
244
|
const providerName = key.replace('_API_KEY', '').toLowerCase();
|
|
235
|
-
|
|
245
|
+
// Map GEMINI_API_KEY to google provider
|
|
246
|
+
if (providerName === 'gemini') {
|
|
247
|
+
// Only use GEMINI_API_KEY if GOOGLE_API_KEY is not already set
|
|
248
|
+
if (!config.apiKeys.google) {
|
|
249
|
+
config.apiKeys.google = value;
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
config.apiKeys[providerName] = value;
|
|
253
|
+
}
|
|
236
254
|
}
|
|
237
255
|
} catch (error) {
|
|
238
256
|
errors.push(error.message);
|
|
@@ -285,14 +303,26 @@ export async function loadConfig() {
|
|
|
285
303
|
nodeEnv,
|
|
286
304
|
};
|
|
287
305
|
|
|
288
|
-
// Validate that at least one API key is present
|
|
306
|
+
// Validate that at least one API key is present OR Vertex AI is configured
|
|
289
307
|
const availableKeys = Object.keys(config.apiKeys);
|
|
290
|
-
|
|
308
|
+
const hasVertexAI = config.providers.googlegenaiusevertexai &&
|
|
309
|
+
config.providers.googlecloudproject &&
|
|
310
|
+
config.providers.googlecloudlocation;
|
|
311
|
+
|
|
312
|
+
if (availableKeys.length === 0 && !hasVertexAI) {
|
|
291
313
|
errors.push(
|
|
292
|
-
'At least one API key must be configured: OPENAI_API_KEY, XAI_API_KEY, GOOGLE_API_KEY, ANTHROPIC_API_KEY, MISTRAL_API_KEY, DEEPSEEK_API_KEY, or OPENROUTER_API_KEY'
|
|
314
|
+
'At least one API key must be configured: OPENAI_API_KEY, XAI_API_KEY, GOOGLE_API_KEY, GEMINI_API_KEY, ANTHROPIC_API_KEY, MISTRAL_API_KEY, DEEPSEEK_API_KEY, or OPENROUTER_API_KEY. Alternatively, configure Google Vertex AI with GOOGLE_GENAI_USE_VERTEXAI, GOOGLE_CLOUD_PROJECT, and GOOGLE_CLOUD_LOCATION.'
|
|
293
315
|
);
|
|
294
316
|
}
|
|
295
317
|
|
|
318
|
+
// If Vertex AI is enabled, add it as a special google provider config
|
|
319
|
+
if (hasVertexAI) {
|
|
320
|
+
// Mark google as available even without API key when using Vertex AI
|
|
321
|
+
if (!config.apiKeys.google) {
|
|
322
|
+
config.apiKeys.google = 'VERTEX_AI'; // Special marker for Vertex AI mode
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
296
326
|
// Validate API key formats
|
|
297
327
|
for (const [provider, apiKey] of Object.entries(config.apiKeys)) {
|
|
298
328
|
if (!validateApiKeyFormat(provider, apiKey)) {
|
package/src/providers/google.js
CHANGED
|
@@ -122,13 +122,18 @@ function resolveModelName(modelName) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
|
-
* Validate Google API key format
|
|
125
|
+
* Validate Google API key format or Vertex AI marker
|
|
126
126
|
*/
|
|
127
127
|
function validateApiKey(apiKey) {
|
|
128
128
|
if (!apiKey || typeof apiKey !== 'string') {
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
// Special marker for Vertex AI mode
|
|
133
|
+
if (apiKey === 'VERTEX_AI') {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
132
137
|
// Google API keys are typically long strings, usually starting with specific patterns
|
|
133
138
|
// They are generally 39+ characters long
|
|
134
139
|
return apiKey.length >= 20;
|
|
@@ -333,20 +338,58 @@ export const googleProvider = {
|
|
|
333
338
|
reasoning_effort = 'medium',
|
|
334
339
|
use_websearch = false,
|
|
335
340
|
config,
|
|
336
|
-
...
|
|
341
|
+
..._otherOptions
|
|
337
342
|
} = options;
|
|
338
343
|
|
|
339
|
-
//
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
344
|
+
// Check if using Vertex AI or Gemini Developer API
|
|
345
|
+
const useVertexAI = config?.providers?.googlegenaiusevertexai;
|
|
346
|
+
const vertexProject = config?.providers?.googlecloudproject;
|
|
347
|
+
const vertexLocation = config?.providers?.googlecloudlocation;
|
|
348
|
+
const apiVersion = config?.providers?.googleapiversion || 'v1beta';
|
|
349
|
+
|
|
350
|
+
let genAI;
|
|
351
|
+
|
|
352
|
+
if (useVertexAI) {
|
|
353
|
+
// Validate Vertex AI configuration
|
|
354
|
+
if (!vertexProject || !vertexLocation) {
|
|
355
|
+
throw new GoogleProviderError(
|
|
356
|
+
'Vertex AI requires GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION',
|
|
357
|
+
'MISSING_VERTEX_CONFIG'
|
|
358
|
+
);
|
|
359
|
+
}
|
|
343
360
|
|
|
344
|
-
|
|
345
|
-
throw new GoogleProviderError('Invalid Google API key format', 'INVALID_API_KEY');
|
|
346
|
-
}
|
|
361
|
+
debugLog(`[Google] Using Vertex AI: project=${vertexProject}, location=${vertexLocation}, apiVersion=${apiVersion}`);
|
|
347
362
|
|
|
348
|
-
|
|
349
|
-
|
|
363
|
+
// Initialize with Vertex AI configuration
|
|
364
|
+
genAI = new GoogleGenAI({
|
|
365
|
+
vertexai: true,
|
|
366
|
+
project: vertexProject,
|
|
367
|
+
location: vertexLocation,
|
|
368
|
+
apiVersion
|
|
369
|
+
});
|
|
370
|
+
} else {
|
|
371
|
+
// Use Gemini Developer API with API key
|
|
372
|
+
const apiKey = config?.apiKeys?.google;
|
|
373
|
+
|
|
374
|
+
if (!apiKey || apiKey === 'VERTEX_AI') {
|
|
375
|
+
throw new GoogleProviderError(
|
|
376
|
+
'Google API key not configured. Set GOOGLE_API_KEY or GEMINI_API_KEY, or configure Vertex AI',
|
|
377
|
+
'MISSING_API_KEY'
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (!validateApiKey(apiKey)) {
|
|
382
|
+
throw new GoogleProviderError('Invalid Google API key format', 'INVALID_API_KEY');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
debugLog(`[Google] Using Gemini Developer API with configured API key, apiVersion=${apiVersion}`);
|
|
386
|
+
|
|
387
|
+
// Initialize with API key - SDK will use GOOGLE_API_KEY as the actual key name
|
|
388
|
+
genAI = new GoogleGenAI({
|
|
389
|
+
apiKey,
|
|
390
|
+
apiVersion
|
|
391
|
+
});
|
|
392
|
+
}
|
|
350
393
|
|
|
351
394
|
// Resolve model name
|
|
352
395
|
const resolvedModel = resolveModelName(model);
|
|
@@ -466,7 +509,15 @@ export const googleProvider = {
|
|
|
466
509
|
* @returns {boolean} - True if configuration is valid
|
|
467
510
|
*/
|
|
468
511
|
validateConfig(config) {
|
|
469
|
-
|
|
512
|
+
// Check for Vertex AI configuration
|
|
513
|
+
const hasVertexAI = !!(config?.providers?.googlegenaiusevertexai &&
|
|
514
|
+
config?.providers?.googlecloudproject &&
|
|
515
|
+
config?.providers?.googlecloudlocation);
|
|
516
|
+
|
|
517
|
+
// Check for API key configuration
|
|
518
|
+
const hasApiKey = !!(config?.apiKeys?.google && validateApiKey(config.apiKeys.google));
|
|
519
|
+
|
|
520
|
+
return hasVertexAI || hasApiKey;
|
|
470
521
|
},
|
|
471
522
|
|
|
472
523
|
/**
|