converse-mcp-server 1.1.2 → 1.3.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 +15 -0
- package/README.md +136 -5
- package/bin/converse.js +1 -1
- package/docs/PROVIDERS.md +179 -0
- package/package.json +3 -3
- package/src/config.js +54 -24
- package/src/index.js +19 -19
- package/src/prompts/helpPrompt.js +277 -0
- package/src/providers/anthropic.js +501 -0
- package/src/providers/deepseek.js +103 -0
- package/src/providers/google.js +6 -6
- package/src/providers/index.js +9 -2
- package/src/providers/interface.js +214 -0
- package/src/providers/mistral.js +413 -0
- package/src/providers/openai-compatible.js +432 -0
- package/src/providers/openai.js +13 -13
- package/src/providers/openrouter.js +202 -0
- package/src/providers/xai.js +3 -3
- package/src/resources/helpResource.js +66 -0
- package/src/router.js +67 -14
- package/src/systemPrompts.js +2 -2
- package/src/tools/chat.js +30 -30
- package/src/tools/consensus.js +26 -26
- package/src/tools/index.js +7 -7
- package/src/transport/httpTransport.js +48 -48
- package/src/utils/console.js +2 -2
- package/src/utils/errorHandler.js +50 -50
- package/src/utils/fileValidator.js +6 -6
- package/src/utils/logger.js +35 -35
- package/src/utils/tokenLimiter.js +16 -16
package/.env.example
CHANGED
|
@@ -19,4 +19,19 @@ OPENAI_API_KEY=your_openai_api_key_here
|
|
|
19
19
|
# Get your X.AI API key from: https://console.x.ai/
|
|
20
20
|
XAI_API_KEY=your_xai_api_key_here
|
|
21
21
|
|
|
22
|
+
# Get your Anthropic API key from: https://console.anthropic.com/
|
|
23
|
+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
24
|
+
|
|
25
|
+
# Get your Mistral API key from: https://console.mistral.ai/
|
|
26
|
+
MISTRAL_API_KEY=your_mistral_api_key_here
|
|
27
|
+
|
|
28
|
+
# Get your DeepSeek API key from: https://platform.deepseek.com/
|
|
29
|
+
DEEPSEEK_API_KEY=your_deepseek_api_key_here
|
|
30
|
+
|
|
31
|
+
# Get your OpenRouter API key from: https://openrouter.ai/keys
|
|
32
|
+
OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
33
|
+
|
|
34
|
+
# OpenRouter requires a referer for compliance (your app URL or GitHub repo)
|
|
35
|
+
OPENROUTER_REFERER=https://github.com/FallDownTheSystem/converse
|
|
36
|
+
|
|
22
37
|
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ npm start
|
|
|
39
39
|
|
|
40
40
|
- **Node.js**: >= 20.0.0 (LTS recommended)
|
|
41
41
|
- **Package Manager**: npm, pnpm, or yarn
|
|
42
|
-
- **API Keys**: At least one
|
|
42
|
+
- **API Keys**: At least one provider API key (OpenAI, Google, X.AI, Anthropic, Mistral, DeepSeek, or OpenRouter)
|
|
43
43
|
|
|
44
44
|
## 🔑 Configuration
|
|
45
45
|
|
|
@@ -52,6 +52,10 @@ Create a `.env` file in your project root:
|
|
|
52
52
|
OPENAI_API_KEY=sk-proj-your_openai_key_here
|
|
53
53
|
GOOGLE_API_KEY=your_google_api_key_here
|
|
54
54
|
XAI_API_KEY=xai-your_xai_key_here
|
|
55
|
+
ANTHROPIC_API_KEY=sk-ant-your_anthropic_key_here
|
|
56
|
+
MISTRAL_API_KEY=your_mistral_key_here
|
|
57
|
+
DEEPSEEK_API_KEY=your_deepseek_key_here
|
|
58
|
+
OPENROUTER_API_KEY=sk-or-your_openrouter_key_here
|
|
55
59
|
|
|
56
60
|
# Optional: Server configuration
|
|
57
61
|
PORT=3157
|
|
@@ -61,6 +65,7 @@ MAX_MCP_OUTPUT_TOKENS=200000
|
|
|
61
65
|
# Optional: Provider-specific settings
|
|
62
66
|
GOOGLE_LOCATION=us-central1
|
|
63
67
|
XAI_BASE_URL=https://api.x.ai/v1
|
|
68
|
+
OPENROUTER_REFERER=https://github.com/FallDownTheSystem/converse
|
|
64
69
|
```
|
|
65
70
|
|
|
66
71
|
### 2. Get API Keys
|
|
@@ -70,10 +75,16 @@ XAI_BASE_URL=https://api.x.ai/v1
|
|
|
70
75
|
| **OpenAI** | [platform.openai.com/api-keys](https://platform.openai.com/api-keys) | `sk-proj-...` |
|
|
71
76
|
| **Google** | [makersuite.google.com/app/apikey](https://makersuite.google.com/app/apikey) | `AIzaSy...` |
|
|
72
77
|
| **X.AI** | [console.x.ai](https://console.x.ai/) | `xai-...` |
|
|
78
|
+
| **Anthropic** | [console.anthropic.com](https://console.anthropic.com/) | `sk-ant-...` |
|
|
79
|
+
| **Mistral** | [console.mistral.ai](https://console.mistral.ai/) | 32+ chars |
|
|
80
|
+
| **DeepSeek** | [platform.deepseek.com](https://platform.deepseek.com/) | 32+ chars |
|
|
81
|
+
| **OpenRouter** | [openrouter.ai/keys](https://openrouter.ai/keys) | `sk-or-...` |
|
|
73
82
|
|
|
74
|
-
### 3.
|
|
83
|
+
### 3. Installing in Claude Code or Claude Desktop
|
|
75
84
|
|
|
76
|
-
|
|
85
|
+
There are several ways to add the Converse MCP Server to Claude:
|
|
86
|
+
|
|
87
|
+
#### Option A: Using NPX (Recommended)
|
|
77
88
|
|
|
78
89
|
```json
|
|
79
90
|
{
|
|
@@ -84,13 +95,110 @@ Add to your MCP client configuration (e.g., Claude Desktop):
|
|
|
84
95
|
"env": {
|
|
85
96
|
"OPENAI_API_KEY": "your_key_here",
|
|
86
97
|
"GOOGLE_API_KEY": "your_key_here",
|
|
87
|
-
"XAI_API_KEY": "your_key_here"
|
|
98
|
+
"XAI_API_KEY": "your_key_here",
|
|
99
|
+
"ANTHROPIC_API_KEY": "your_key_here",
|
|
100
|
+
"MISTRAL_API_KEY": "your_key_here",
|
|
101
|
+
"DEEPSEEK_API_KEY": "your_key_here",
|
|
102
|
+
"OPENROUTER_API_KEY": "your_key_here",
|
|
103
|
+
"OPENROUTER_REFERER": "https://github.com/YourUsername/YourApp",
|
|
104
|
+
"MAX_MCP_OUTPUT_TOKENS": "200000"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Option B: Using NPX with stdio transport
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"mcpServers": {
|
|
116
|
+
"converse": {
|
|
117
|
+
"command": "npx",
|
|
118
|
+
"args": ["FallDownTheSystem/converse", "--transport", "stdio"],
|
|
119
|
+
"env": {
|
|
120
|
+
"OPENAI_API_KEY": "your_key_here",
|
|
121
|
+
"GOOGLE_API_KEY": "your_key_here",
|
|
122
|
+
"XAI_API_KEY": "your_key_here",
|
|
123
|
+
"ANTHROPIC_API_KEY": "your_key_here",
|
|
124
|
+
"MISTRAL_API_KEY": "your_key_here",
|
|
125
|
+
"DEEPSEEK_API_KEY": "your_key_here",
|
|
126
|
+
"OPENROUTER_API_KEY": "your_key_here",
|
|
127
|
+
"OPENROUTER_REFERER": "https://github.com/YourUsername/YourApp",
|
|
128
|
+
"MAX_MCP_OUTPUT_TOKENS": "200000"
|
|
88
129
|
}
|
|
89
130
|
}
|
|
90
131
|
}
|
|
91
132
|
}
|
|
92
133
|
```
|
|
93
134
|
|
|
135
|
+
#### Option C: Direct Node.js execution
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"mcpServers": {
|
|
140
|
+
"converse": {
|
|
141
|
+
"command": "node",
|
|
142
|
+
"args": [
|
|
143
|
+
"C:\\Users\\YourUsername\\Documents\\Projects\\converse\\src\\index.js",
|
|
144
|
+
"--transport",
|
|
145
|
+
"stdio"
|
|
146
|
+
],
|
|
147
|
+
"env": {
|
|
148
|
+
"OPENAI_API_KEY": "your_key_here",
|
|
149
|
+
"GOOGLE_API_KEY": "your_key_here",
|
|
150
|
+
"XAI_API_KEY": "your_key_here",
|
|
151
|
+
"ANTHROPIC_API_KEY": "your_key_here",
|
|
152
|
+
"MISTRAL_API_KEY": "your_key_here",
|
|
153
|
+
"DEEPSEEK_API_KEY": "your_key_here",
|
|
154
|
+
"OPENROUTER_API_KEY": "your_key_here",
|
|
155
|
+
"OPENROUTER_REFERER": "https://github.com/YourUsername/YourApp",
|
|
156
|
+
"MAX_MCP_OUTPUT_TOKENS": "200000"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Option D: Using environment variable for transport
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"mcpServers": {
|
|
168
|
+
"converse": {
|
|
169
|
+
"command": "npx",
|
|
170
|
+
"args": ["FallDownTheSystem/converse"],
|
|
171
|
+
"env": {
|
|
172
|
+
"MCP_TRANSPORT": "stdio",
|
|
173
|
+
"OPENAI_API_KEY": "your_key_here",
|
|
174
|
+
"GOOGLE_API_KEY": "your_key_here",
|
|
175
|
+
"XAI_API_KEY": "your_key_here",
|
|
176
|
+
"MAX_MCP_OUTPUT_TOKENS": "200000"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### Installation Steps
|
|
184
|
+
|
|
185
|
+
1. **For Claude Code**:
|
|
186
|
+
- Open the command palette (Ctrl/Cmd + Shift + P)
|
|
187
|
+
- Run "Claude Code: Edit MCP Settings"
|
|
188
|
+
- Add one of the configurations above
|
|
189
|
+
|
|
190
|
+
2. **For Claude Desktop**:
|
|
191
|
+
- Navigate to Settings → Developer → MCP Servers
|
|
192
|
+
- Click "Add Server" and paste one of the configurations above
|
|
193
|
+
|
|
194
|
+
3. **Manual Configuration**:
|
|
195
|
+
- The configuration file is typically located at:
|
|
196
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
197
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
198
|
+
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
199
|
+
|
|
200
|
+
For more detailed instructions, see the [official MCP configuration guide](https://docs.anthropic.com/en/docs/claude-code/mcp#configure-mcp-servers).
|
|
201
|
+
|
|
94
202
|
## 🛠️ Available Tools
|
|
95
203
|
|
|
96
204
|
### 1. Chat Tool
|
|
@@ -129,6 +237,23 @@ Multi-provider parallel execution with cross-model feedback.
|
|
|
129
237
|
}
|
|
130
238
|
```
|
|
131
239
|
|
|
240
|
+
## 📚 Help & Documentation
|
|
241
|
+
|
|
242
|
+
The Converse MCP Server provides built-in help through:
|
|
243
|
+
|
|
244
|
+
### Help Prompt
|
|
245
|
+
Access comprehensive documentation directly in Claude:
|
|
246
|
+
- `/converse:help` - Full documentation
|
|
247
|
+
- `/converse:help tools` - Tool-specific help
|
|
248
|
+
- `/converse:help models` - Model information
|
|
249
|
+
- `/converse:help parameters` - Configuration details
|
|
250
|
+
- `/converse:help examples` - Usage examples
|
|
251
|
+
|
|
252
|
+
### Help Resource
|
|
253
|
+
Programmatic access to documentation:
|
|
254
|
+
- Resource URI: `converse://help`
|
|
255
|
+
- Includes all documentation plus current server version
|
|
256
|
+
|
|
132
257
|
## 📊 Supported Models
|
|
133
258
|
|
|
134
259
|
### OpenAI Models
|
|
@@ -341,9 +466,15 @@ converse/
|
|
|
341
466
|
│ ├── systemPrompts.js # Tool system prompts
|
|
342
467
|
│ ├── providers/ # AI provider implementations
|
|
343
468
|
│ │ ├── index.js # Provider registry
|
|
469
|
+
│ │ ├── interface.js # Unified provider interface
|
|
344
470
|
│ │ ├── openai.js # OpenAI provider
|
|
345
471
|
│ │ ├── xai.js # XAI provider
|
|
346
|
-
│ │
|
|
472
|
+
│ │ ├── google.js # Google provider
|
|
473
|
+
│ │ ├── anthropic.js # Anthropic provider
|
|
474
|
+
│ │ ├── mistral.js # Mistral AI provider
|
|
475
|
+
│ │ ├── deepseek.js # DeepSeek provider
|
|
476
|
+
│ │ ├── openrouter.js # OpenRouter provider
|
|
477
|
+
│ │ └── openai-compatible.js # Base for OpenAI-compatible APIs
|
|
347
478
|
│ ├── tools/ # MCP tool implementations
|
|
348
479
|
│ │ ├── index.js # Tool registry
|
|
349
480
|
│ │ ├── chat.js # Chat tool
|
package/bin/converse.js
CHANGED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# AI Provider Configuration Guide
|
|
2
|
+
|
|
3
|
+
This guide documents all supported AI providers in the Converse MCP Server and their configuration options.
|
|
4
|
+
|
|
5
|
+
## Supported Providers
|
|
6
|
+
|
|
7
|
+
### OpenAI
|
|
8
|
+
- **API Key Format**: `sk-proj-...` (starts with `sk-`)
|
|
9
|
+
- **Get Key**: [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
|
|
10
|
+
- **Environment Variable**: `OPENAI_API_KEY`
|
|
11
|
+
- **Supported Models**:
|
|
12
|
+
- `o3`, `o3-mini`, `o3-pro` - Advanced reasoning models
|
|
13
|
+
- `o4-mini` - Latest fast reasoning model
|
|
14
|
+
- `gpt-4.1` - Large context (1M tokens)
|
|
15
|
+
- `gpt-4o`, `gpt-4o-mini` - Multimodal models
|
|
16
|
+
|
|
17
|
+
### Google (Gemini)
|
|
18
|
+
- **API Key Format**: `AIzaSy...` (varies)
|
|
19
|
+
- **Get Key**: [makersuite.google.com/app/apikey](https://makersuite.google.com/app/apikey)
|
|
20
|
+
- **Environment Variable**: `GOOGLE_API_KEY`
|
|
21
|
+
- **Supported Models**:
|
|
22
|
+
- `gemini-2.5-pro` - Deep reasoning with thinking mode
|
|
23
|
+
- `gemini-2.5-flash` - Ultra-fast model
|
|
24
|
+
- `gemini-2.0-flash`, `gemini-2.0-flash-lite` - Latest generation
|
|
25
|
+
|
|
26
|
+
### X.AI (Grok)
|
|
27
|
+
- **API Key Format**: `xai-...` (starts with `xai-`)
|
|
28
|
+
- **Get Key**: [console.x.ai](https://console.x.ai/)
|
|
29
|
+
- **Environment Variable**: `XAI_API_KEY`
|
|
30
|
+
- **Supported Models**:
|
|
31
|
+
- `grok-4-0709` - Latest with image support and web search
|
|
32
|
+
- `grok-3`, `grok-3-fast` - Previous generation
|
|
33
|
+
|
|
34
|
+
### Anthropic (Claude)
|
|
35
|
+
- **API Key Format**: `sk-ant-...` (starts with `sk-ant-`)
|
|
36
|
+
- **Get Key**: [console.anthropic.com](https://console.anthropic.com/)
|
|
37
|
+
- **Environment Variable**: `ANTHROPIC_API_KEY`
|
|
38
|
+
- **Supported Models**:
|
|
39
|
+
- `claude-opus-4-20250514` - Highest intelligence with extended thinking (32K output)
|
|
40
|
+
- `claude-sonnet-4-20250514` - Balanced performance with extended thinking (64K output)
|
|
41
|
+
- `claude-3-7-sonnet-20250219` - Enhanced 3.x generation with thinking (64K output)
|
|
42
|
+
- `claude-3-5-sonnet-20241022` - Fast and intelligent model (8K output)
|
|
43
|
+
- `claude-3-5-haiku-20241022` - Fastest Claude model (8K output)
|
|
44
|
+
- `claude-3-opus-20240229`, `claude-3-sonnet-20240229`, `claude-3-haiku-20240307` - Previous generation
|
|
45
|
+
|
|
46
|
+
### Mistral
|
|
47
|
+
- **API Key Format**: 32+ character string
|
|
48
|
+
- **Get Key**: [console.mistral.ai](https://console.mistral.ai/)
|
|
49
|
+
- **Environment Variable**: `MISTRAL_API_KEY`
|
|
50
|
+
- **Supported Models**:
|
|
51
|
+
- `mistral-large-latest` - Most capable model
|
|
52
|
+
- `mistral-medium-latest` - Balanced performance
|
|
53
|
+
- `mistral-small-latest` - Fast and efficient
|
|
54
|
+
- `open-mistral-7b`, `open-mixtral-8x7b`, `open-mixtral-8x22b` - Open-source models
|
|
55
|
+
|
|
56
|
+
### DeepSeek
|
|
57
|
+
- **API Key Format**: 32+ character string
|
|
58
|
+
- **Get Key**: [platform.deepseek.com](https://platform.deepseek.com/)
|
|
59
|
+
- **Environment Variable**: `DEEPSEEK_API_KEY`
|
|
60
|
+
- **Supported Models**:
|
|
61
|
+
- `deepseek-chat` - Advanced conversational model
|
|
62
|
+
- `deepseek-coder` - Specialized for code generation
|
|
63
|
+
|
|
64
|
+
### OpenRouter
|
|
65
|
+
- **API Key Format**: `sk-or-...` (starts with `sk-or-`)
|
|
66
|
+
- **Get Key**: [openrouter.ai/keys](https://openrouter.ai/keys)
|
|
67
|
+
- **Environment Variables**:
|
|
68
|
+
- `OPENROUTER_API_KEY` - Your API key
|
|
69
|
+
- `OPENROUTER_REFERER` - Required referer URL (e.g., your GitHub repo)
|
|
70
|
+
- **Supported Models**: Access to multiple providers through unified API
|
|
71
|
+
- `anthropic/claude-3.5-sonnet`
|
|
72
|
+
- `openai/gpt-4-turbo`
|
|
73
|
+
- `google/gemini-pro`
|
|
74
|
+
- `mistralai/mistral-large`
|
|
75
|
+
- `meta-llama/llama-3.1-405b-instruct`
|
|
76
|
+
|
|
77
|
+
## Configuration Examples
|
|
78
|
+
|
|
79
|
+
### Basic Configuration (.env file)
|
|
80
|
+
```bash
|
|
81
|
+
# Choose one or more providers
|
|
82
|
+
OPENAI_API_KEY=sk-proj-your_key_here
|
|
83
|
+
ANTHROPIC_API_KEY=sk-ant-your_key_here
|
|
84
|
+
MISTRAL_API_KEY=your_mistral_key_here
|
|
85
|
+
DEEPSEEK_API_KEY=your_deepseek_key_here
|
|
86
|
+
|
|
87
|
+
# OpenRouter requires both API key and referer
|
|
88
|
+
OPENROUTER_API_KEY=sk-or-your_key_here
|
|
89
|
+
OPENROUTER_REFERER=https://github.com/YourUsername/YourApp
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Claude Configuration (claude_desktop_config.json)
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"mcpServers": {
|
|
96
|
+
"converse": {
|
|
97
|
+
"command": "npx",
|
|
98
|
+
"args": ["FallDownTheSystem/converse"],
|
|
99
|
+
"env": {
|
|
100
|
+
"OPENAI_API_KEY": "your_key_here",
|
|
101
|
+
"ANTHROPIC_API_KEY": "your_key_here",
|
|
102
|
+
"MISTRAL_API_KEY": "your_key_here",
|
|
103
|
+
"DEEPSEEK_API_KEY": "your_key_here",
|
|
104
|
+
"OPENROUTER_API_KEY": "your_key_here",
|
|
105
|
+
"OPENROUTER_REFERER": "https://github.com/YourUsername/YourApp"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Provider-Specific Features
|
|
113
|
+
|
|
114
|
+
### Streaming Support
|
|
115
|
+
All providers support streaming responses for real-time output.
|
|
116
|
+
|
|
117
|
+
### Image Support
|
|
118
|
+
- **Full Support**: OpenAI, Google, X.AI (Grok-4), Anthropic (Claude-3.5-Sonnet, Claude-3-Opus)
|
|
119
|
+
- **Via OpenRouter**: Depends on the underlying model
|
|
120
|
+
- **No Support**: DeepSeek, Mistral (except Large), Claude-3.5-Haiku
|
|
121
|
+
|
|
122
|
+
### Web Search
|
|
123
|
+
- **Native Support**: OpenAI, Google, X.AI (Grok-4)
|
|
124
|
+
- **No Support**: Anthropic, Mistral, DeepSeek, OpenRouter
|
|
125
|
+
|
|
126
|
+
### Thinking/Reasoning Modes
|
|
127
|
+
- **OpenAI**: O3 series models support `reasoning_effort` parameter
|
|
128
|
+
- **Google**: Gemini Pro/Flash support thinking mode with configurable budget
|
|
129
|
+
- **Anthropic**: Claude 4 and 3.7 models support extended thinking with `reasoning_effort`
|
|
130
|
+
- **Others**: Standard inference only
|
|
131
|
+
|
|
132
|
+
## Model Selection in Tools
|
|
133
|
+
|
|
134
|
+
When using the chat or consensus tools, specify models using their identifiers:
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
// Chat tool examples
|
|
138
|
+
{
|
|
139
|
+
"model": "gpt-4o", // OpenAI
|
|
140
|
+
"model": "claude-opus-4", // Anthropic (auto-resolves to claude-opus-4-20250514)
|
|
141
|
+
"model": "sonnet", // Anthropic (resolves to latest Sonnet 4)
|
|
142
|
+
"model": "gemini-2.5-pro", // Google
|
|
143
|
+
"model": "grok-4-0709", // X.AI
|
|
144
|
+
"model": "mistral-large", // Mistral
|
|
145
|
+
"model": "deepseek-chat", // DeepSeek
|
|
146
|
+
"model": "anthropic/claude-3.5-sonnet" // OpenRouter
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Consensus tool with multiple providers
|
|
150
|
+
{
|
|
151
|
+
"models": [
|
|
152
|
+
{"model": "o3"},
|
|
153
|
+
{"model": "claude-3-5-sonnet"},
|
|
154
|
+
{"model": "gemini-2.5-pro"}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Troubleshooting
|
|
160
|
+
|
|
161
|
+
### Invalid API Key Errors
|
|
162
|
+
- Ensure your API key matches the expected format for each provider
|
|
163
|
+
- Check that environment variables are properly set
|
|
164
|
+
- Verify API keys are active and have available quota
|
|
165
|
+
|
|
166
|
+
### Model Not Found
|
|
167
|
+
- Use exact model identifiers as listed above
|
|
168
|
+
- Some providers support aliases (e.g., "claude" → "claude-3-5-sonnet")
|
|
169
|
+
- Check provider documentation for model availability in your region
|
|
170
|
+
|
|
171
|
+
### Rate Limits
|
|
172
|
+
- Each provider has different rate limits
|
|
173
|
+
- OpenRouter provides unified rate limiting across providers
|
|
174
|
+
- Consider using multiple providers for better availability
|
|
175
|
+
|
|
176
|
+
### OpenRouter Compliance
|
|
177
|
+
- The `OPENROUTER_REFERER` header is **required**
|
|
178
|
+
- Use your application URL or GitHub repository
|
|
179
|
+
- This helps OpenRouter track usage for compliance
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "converse-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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",
|
|
@@ -88,13 +88,13 @@
|
|
|
88
88
|
"@google/genai": "^1.11.0",
|
|
89
89
|
"@modelcontextprotocol/sdk": "^1.17.0",
|
|
90
90
|
"cors": "^2.8.5",
|
|
91
|
-
"dotenv": "^
|
|
91
|
+
"dotenv": "^17.2.1",
|
|
92
92
|
"express": "^5.1.0",
|
|
93
93
|
"openai": "^5.0.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@vitest/coverage-v8": "^3.2.4",
|
|
97
|
-
"eslint": "^9.
|
|
97
|
+
"eslint": "^9.32.0",
|
|
98
98
|
"prettier": "^3.0.0",
|
|
99
99
|
"vitest": "^3.2.4"
|
|
100
100
|
}
|
package/src/config.js
CHANGED
|
@@ -14,12 +14,12 @@ import { ConfigurationError } from './utils/errorHandler.js';
|
|
|
14
14
|
// Priority: .env.test (for test env) > .env (default)
|
|
15
15
|
if (process.env.NODE_ENV === 'test') {
|
|
16
16
|
// Load test environment first
|
|
17
|
-
dotenv.config({ path: '.env.test' });
|
|
17
|
+
dotenv.config({ path: '.env.test', quiet: true });
|
|
18
18
|
// Fall back to .env for any missing variables
|
|
19
|
-
dotenv.config({ override: false });
|
|
19
|
+
dotenv.config({ override: false, quiet: true });
|
|
20
20
|
} else {
|
|
21
21
|
// Load default .env file
|
|
22
|
-
dotenv.config();
|
|
22
|
+
dotenv.config({ quiet: true });
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Configure logger early
|
|
@@ -45,25 +45,25 @@ const CONFIG_SCHEMA = {
|
|
|
45
45
|
// Transport configuration
|
|
46
46
|
transport: {
|
|
47
47
|
MCP_TRANSPORT: { type: 'string', default: 'http', description: 'MCP transport type (http or stdio)' },
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// HTTP server settings
|
|
50
50
|
HTTP_PORT: { type: 'number', default: 3157, description: 'HTTP server port' },
|
|
51
51
|
HTTP_HOST: { type: 'string', default: 'localhost', description: 'HTTP server host' },
|
|
52
52
|
HTTP_REQUEST_TIMEOUT: { type: 'number', default: 300000, description: 'HTTP request timeout in milliseconds (5 minutes)' },
|
|
53
53
|
HTTP_MAX_REQUEST_SIZE: { type: 'string', default: '10mb', description: 'Maximum HTTP request body size' },
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
// Session management
|
|
56
56
|
HTTP_SESSION_TIMEOUT: { type: 'number', default: 1800000, description: 'Session timeout in milliseconds (30 minutes)' },
|
|
57
57
|
HTTP_SESSION_CLEANUP_INTERVAL: { type: 'number', default: 300000, description: 'Session cleanup interval in milliseconds (5 minutes)' },
|
|
58
58
|
HTTP_MAX_CONCURRENT_SESSIONS: { type: 'number', default: 100, description: 'Maximum concurrent sessions' },
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
// CORS configuration
|
|
61
61
|
HTTP_ENABLE_CORS: { type: 'boolean', default: true, description: 'Enable CORS for HTTP transport' },
|
|
62
62
|
HTTP_CORS_ORIGINS: { type: 'string', default: '*', description: 'CORS allowed origins (comma-separated)' },
|
|
63
63
|
HTTP_CORS_METHODS: { type: 'string', default: 'GET,POST,DELETE,OPTIONS', description: 'CORS allowed methods' },
|
|
64
64
|
HTTP_CORS_HEADERS: { type: 'string', default: 'Content-Type,mcp-session-id,Authorization', description: 'CORS allowed headers' },
|
|
65
65
|
HTTP_CORS_CREDENTIALS: { type: 'boolean', default: false, description: 'CORS allow credentials' },
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
// Security settings
|
|
68
68
|
HTTP_DNS_REBINDING_PROTECTION: { type: 'boolean', default: false, description: 'Enable DNS rebinding protection' },
|
|
69
69
|
HTTP_ALLOWED_HOSTS: { type: 'string', default: '127.0.0.1,localhost', description: 'Allowed hosts for DNS rebinding protection (comma-separated)' },
|
|
@@ -77,6 +77,15 @@ const CONFIG_SCHEMA = {
|
|
|
77
77
|
OPENAI_API_KEY: { type: 'string', required: false, secret: true, description: 'OpenAI API key' },
|
|
78
78
|
XAI_API_KEY: { type: 'string', required: false, secret: true, description: 'XAI API key' },
|
|
79
79
|
GOOGLE_API_KEY: { type: 'string', required: false, secret: true, description: 'Google API key' },
|
|
80
|
+
ANTHROPIC_API_KEY: { type: 'string', required: false, secret: true, description: 'Anthropic API key' },
|
|
81
|
+
MISTRAL_API_KEY: { type: 'string', required: false, secret: true, description: 'Mistral API key' },
|
|
82
|
+
DEEPSEEK_API_KEY: { type: 'string', required: false, secret: true, description: 'DeepSeek API key' },
|
|
83
|
+
OPENROUTER_API_KEY: { type: 'string', required: false, secret: true, description: 'OpenRouter API key' },
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
// Provider-specific configuration
|
|
87
|
+
providers: {
|
|
88
|
+
OPENROUTER_REFERER: { type: 'string', required: false, description: 'OpenRouter referer header for compliance' },
|
|
80
89
|
},
|
|
81
90
|
|
|
82
91
|
|
|
@@ -150,6 +159,14 @@ function validateApiKeyFormat(provider, apiKey) {
|
|
|
150
159
|
return apiKey.startsWith('xai-') && apiKey.length > 20;
|
|
151
160
|
case 'google':
|
|
152
161
|
return apiKey.length > 20; // Google keys vary in format
|
|
162
|
+
case 'anthropic':
|
|
163
|
+
return apiKey.startsWith('sk-ant-') && apiKey.length >= 30;
|
|
164
|
+
case 'mistral':
|
|
165
|
+
return apiKey.length >= 32; // Mistral keys are typically 32+ chars
|
|
166
|
+
case 'deepseek':
|
|
167
|
+
return apiKey.length >= 32; // DeepSeek keys are typically 32+ chars
|
|
168
|
+
case 'openrouter':
|
|
169
|
+
return apiKey.startsWith('sk-or-') && apiKey.length >= 40;
|
|
153
170
|
default:
|
|
154
171
|
return apiKey.length >= 10; // Basic minimum length check
|
|
155
172
|
}
|
|
@@ -163,7 +180,7 @@ function validateApiKeyFormat(provider, apiKey) {
|
|
|
163
180
|
export async function loadConfig() {
|
|
164
181
|
const configLogger = logger.operation('loadConfig');
|
|
165
182
|
configLogger.debug('Starting configuration loading');
|
|
166
|
-
|
|
183
|
+
|
|
167
184
|
const config = {
|
|
168
185
|
server: {},
|
|
169
186
|
transport: {},
|
|
@@ -193,7 +210,7 @@ export async function loadConfig() {
|
|
|
193
210
|
for (const [key, schema] of Object.entries(CONFIG_SCHEMA.transport)) {
|
|
194
211
|
try {
|
|
195
212
|
const value = validateEnvVar(key, process.env[key], schema);
|
|
196
|
-
|
|
213
|
+
|
|
197
214
|
if (key === 'MCP_TRANSPORT') {
|
|
198
215
|
config.transport.mcptransport = value;
|
|
199
216
|
} else if (key.startsWith('HTTP_')) {
|
|
@@ -219,8 +236,19 @@ export async function loadConfig() {
|
|
|
219
236
|
}
|
|
220
237
|
}
|
|
221
238
|
|
|
222
|
-
//
|
|
239
|
+
// Load provider-specific configuration
|
|
223
240
|
config.providers = {};
|
|
241
|
+
for (const [key, schema] of Object.entries(CONFIG_SCHEMA.providers)) {
|
|
242
|
+
try {
|
|
243
|
+
const value = validateEnvVar(key, process.env[key], schema);
|
|
244
|
+
if (value) {
|
|
245
|
+
const configKey = key.toLowerCase().replace(/_/g, '');
|
|
246
|
+
config.providers[configKey] = value;
|
|
247
|
+
}
|
|
248
|
+
} catch (error) {
|
|
249
|
+
errors.push(error.message);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
224
252
|
|
|
225
253
|
// Load MCP configuration
|
|
226
254
|
for (const [key, schema] of Object.entries(CONFIG_SCHEMA.mcp)) {
|
|
@@ -245,7 +273,7 @@ export async function loadConfig() {
|
|
|
245
273
|
const availableKeys = Object.keys(config.apiKeys);
|
|
246
274
|
if (availableKeys.length === 0) {
|
|
247
275
|
errors.push(
|
|
248
|
-
'At least one API key must be configured: OPENAI_API_KEY, XAI_API_KEY, or
|
|
276
|
+
'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'
|
|
249
277
|
);
|
|
250
278
|
}
|
|
251
279
|
|
|
@@ -286,7 +314,7 @@ export async function loadConfig() {
|
|
|
286
314
|
*/
|
|
287
315
|
export function getHttpTransportConfig(config) {
|
|
288
316
|
const transport = config.transport;
|
|
289
|
-
|
|
317
|
+
|
|
290
318
|
// Parse comma-separated values
|
|
291
319
|
const corsOrigins = transport.corsorigins === '*' ? '*' : transport.corsorigins?.split(',').map(o => o.trim()) || ['*'];
|
|
292
320
|
const corsMethods = transport.corsmethods?.split(',').map(m => m.trim()) || ['GET', 'POST', 'DELETE', 'OPTIONS'];
|
|
@@ -299,12 +327,12 @@ export function getHttpTransportConfig(config) {
|
|
|
299
327
|
host: transport.host || 'localhost',
|
|
300
328
|
requestTimeout: transport.requesttimeout || 300000,
|
|
301
329
|
maxRequestSize: transport.maxrequestsize || '10mb',
|
|
302
|
-
|
|
330
|
+
|
|
303
331
|
// Session management
|
|
304
332
|
sessionTimeout: transport.sessiontimeout || 1800000,
|
|
305
333
|
sessionCleanupInterval: transport.sessioncleanupinterval || 300000,
|
|
306
334
|
maxConcurrentSessions: transport.maxconcurrentsessions || 100,
|
|
307
|
-
|
|
335
|
+
|
|
308
336
|
// CORS configuration
|
|
309
337
|
enableCors: transport.enablecors !== false,
|
|
310
338
|
corsOptions: {
|
|
@@ -314,10 +342,10 @@ export function getHttpTransportConfig(config) {
|
|
|
314
342
|
credentials: transport.corscredentials || false,
|
|
315
343
|
exposedHeaders: ['Mcp-Session-Id'],
|
|
316
344
|
},
|
|
317
|
-
|
|
345
|
+
|
|
318
346
|
// Security settings
|
|
319
347
|
enableDnsRebindingProtection: transport.dnsrebindingprotection || false,
|
|
320
|
-
allowedHosts
|
|
348
|
+
allowedHosts,
|
|
321
349
|
rateLimitEnabled: transport.ratelimitenabled || false,
|
|
322
350
|
rateLimitWindow: transport.ratelimitwindow || 900000,
|
|
323
351
|
rateLimitMaxRequests: transport.ratelimitmaxrequests || 1000,
|
|
@@ -396,36 +424,36 @@ export async function validateRuntimeConfig(config) {
|
|
|
396
424
|
// Validate HTTP transport configuration
|
|
397
425
|
if (config.transport.mcptransport === 'http') {
|
|
398
426
|
const httpConfig = getHttpTransportConfig(config);
|
|
399
|
-
|
|
427
|
+
|
|
400
428
|
// Validate HTTP port
|
|
401
429
|
if (httpConfig.port < 1 || httpConfig.port > 65535) {
|
|
402
430
|
throw new ConfigurationError(`Invalid HTTP_PORT: ${httpConfig.port}. Must be between 1 and 65535`);
|
|
403
431
|
}
|
|
404
|
-
|
|
432
|
+
|
|
405
433
|
// Validate timeouts
|
|
406
434
|
if (httpConfig.requestTimeout < 1000) {
|
|
407
435
|
throw new ConfigurationError(`Invalid HTTP_REQUEST_TIMEOUT: ${httpConfig.requestTimeout}. Must be at least 1000ms`);
|
|
408
436
|
}
|
|
409
|
-
|
|
437
|
+
|
|
410
438
|
if (httpConfig.sessionTimeout < 60000) {
|
|
411
439
|
throw new ConfigurationError(`Invalid HTTP_SESSION_TIMEOUT: ${httpConfig.sessionTimeout}. Must be at least 60000ms (1 minute)`);
|
|
412
440
|
}
|
|
413
|
-
|
|
441
|
+
|
|
414
442
|
if (httpConfig.sessionCleanupInterval < 10000) {
|
|
415
443
|
throw new ConfigurationError(`Invalid HTTP_SESSION_CLEANUP_INTERVAL: ${httpConfig.sessionCleanupInterval}. Must be at least 10000ms (10 seconds)`);
|
|
416
444
|
}
|
|
417
|
-
|
|
445
|
+
|
|
418
446
|
// Validate max concurrent sessions
|
|
419
447
|
if (httpConfig.maxConcurrentSessions < 1 || httpConfig.maxConcurrentSessions > 10000) {
|
|
420
448
|
throw new ConfigurationError(`Invalid HTTP_MAX_CONCURRENT_SESSIONS: ${httpConfig.maxConcurrentSessions}. Must be between 1 and 10000`);
|
|
421
449
|
}
|
|
422
|
-
|
|
450
|
+
|
|
423
451
|
// Validate rate limiting
|
|
424
452
|
if (httpConfig.rateLimitEnabled) {
|
|
425
453
|
if (httpConfig.rateLimitWindow < 1000) {
|
|
426
454
|
throw new ConfigurationError(`Invalid HTTP_RATE_LIMIT_WINDOW: ${httpConfig.rateLimitWindow}. Must be at least 1000ms`);
|
|
427
455
|
}
|
|
428
|
-
|
|
456
|
+
|
|
429
457
|
if (httpConfig.rateLimitMaxRequests < 1) {
|
|
430
458
|
throw new ConfigurationError(`Invalid HTTP_RATE_LIMIT_MAX_REQUESTS: ${httpConfig.rateLimitMaxRequests}. Must be at least 1`);
|
|
431
459
|
}
|
|
@@ -461,7 +489,7 @@ function logConfigurationSummary(config) {
|
|
|
461
489
|
if (process.stdin.isTTY === false || process.env.NODE_ENV === 'test') {
|
|
462
490
|
return;
|
|
463
491
|
}
|
|
464
|
-
|
|
492
|
+
|
|
465
493
|
const availableProviders = getAvailableProviders(config);
|
|
466
494
|
|
|
467
495
|
// Log configuration summary
|
|
@@ -491,6 +519,8 @@ export function getMcpClientConfig(config) {
|
|
|
491
519
|
version: config.mcp.version,
|
|
492
520
|
capabilities: {
|
|
493
521
|
tools: {},
|
|
522
|
+
prompts: {},
|
|
523
|
+
resources: {},
|
|
494
524
|
},
|
|
495
525
|
environment: config.environment.nodeEnv,
|
|
496
526
|
providers: getAvailableProviders(config),
|