converse-mcp-server 2.3.1 → 2.4.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/README.md +771 -738
- package/docs/API.md +10 -1
- package/docs/PROVIDERS.md +8 -4
- package/package.json +12 -12
- package/src/async/asyncJobStore.js +82 -52
- package/src/async/eventBus.js +25 -20
- package/src/async/fileCache.js +121 -40
- package/src/async/jobRunner.js +65 -39
- package/src/async/providerStreamNormalizer.js +203 -117
- package/src/config.js +374 -102
- package/src/continuationStore.js +32 -24
- package/src/index.js +45 -25
- package/src/prompts/helpPrompt.js +328 -305
- package/src/providers/anthropic.js +303 -119
- package/src/providers/codex.js +103 -45
- package/src/providers/deepseek.js +24 -8
- package/src/providers/google.js +323 -93
- package/src/providers/index.js +1 -1
- package/src/providers/interface.js +16 -11
- package/src/providers/mistral.js +179 -69
- package/src/providers/openai-compatible.js +231 -94
- package/src/providers/openai.js +1094 -914
- package/src/providers/openrouter-endpoints-client.js +220 -216
- package/src/providers/openrouter.js +426 -381
- package/src/providers/xai.js +153 -56
- package/src/resources/helpResource.js +70 -67
- package/src/router.js +95 -67
- package/src/services/summarizationService.js +51 -24
- package/src/systemPrompts.js +89 -89
- package/src/tools/cancelJob.js +31 -19
- package/src/tools/chat.js +997 -883
- package/src/tools/checkStatus.js +86 -65
- package/src/tools/consensus.js +400 -234
- package/src/tools/index.js +39 -16
- package/src/transport/httpTransport.js +82 -55
- package/src/utils/contextProcessor.js +54 -37
- package/src/utils/errorHandler.js +95 -45
- package/src/utils/fileValidator.js +107 -98
- package/src/utils/formatStatus.js +122 -64
- package/src/utils/logger.js +459 -449
- package/src/utils/pathUtils.js +2 -2
- package/src/utils/tokenLimiter.js +216 -216
|
@@ -1,305 +1,328 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Help Prompt Implementation
|
|
3
|
-
*
|
|
4
|
-
* Provides comprehensive help documentation for the Converse MCP Server
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { getProviders } from '../providers/index.js';
|
|
8
|
-
import { getTools } from '../tools/index.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Generate comprehensive help content dynamically based on current providers
|
|
12
|
-
* @param {object} config - Configuration object (optional)
|
|
13
|
-
*/
|
|
14
|
-
export function generateHelpContent(config = null) {
|
|
15
|
-
const providers = getProviders();
|
|
16
|
-
|
|
17
|
-
// Collect all models from all providers
|
|
18
|
-
const allModels = {
|
|
19
|
-
openai: providers.openai?.getSupportedModels() || {},
|
|
20
|
-
google: providers.google?.getSupportedModels() || {},
|
|
21
|
-
xai: providers.xai?.getSupportedModels() || {},
|
|
22
|
-
anthropic: providers.anthropic?.getSupportedModels() || {},
|
|
23
|
-
mistral: providers.mistral?.getSupportedModels() || {},
|
|
24
|
-
deepseek: providers.deepseek?.getSupportedModels() || {},
|
|
25
|
-
openrouter: providers.openrouter?.getSupportedModels() || {}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Format provider models for display
|
|
29
|
-
const formatProviderModels = (providerName, models) => {
|
|
30
|
-
if (!models || Object.keys(models).length === 0) return '';
|
|
31
|
-
|
|
32
|
-
let output = `\n### ${providerName.toUpperCase()} Models\n\n`;
|
|
33
|
-
|
|
34
|
-
for (const [modelId, config] of Object.entries(models)) {
|
|
35
|
-
output += `**${modelId}** - ${config.friendlyName}\n`;
|
|
36
|
-
output += `- Description: ${config.description}\n`;
|
|
37
|
-
output += `- Context Window: ${config.contextWindow.toLocaleString()} tokens\n`;
|
|
38
|
-
output += `- Max Output: ${config.maxOutputTokens.toLocaleString()} tokens\n`;
|
|
39
|
-
output += '- Features: ';
|
|
40
|
-
|
|
41
|
-
const features = [];
|
|
42
|
-
if (config.supportsStreaming) features.push('Streaming');
|
|
43
|
-
if (config.supportsImages) features.push('Images');
|
|
44
|
-
if (config.supportsTemperature) features.push('Temperature');
|
|
45
|
-
if (config.supportsWebSearch) features.push('Web Search');
|
|
46
|
-
if (config.supportsThinking) features.push('Thinking Mode');
|
|
47
|
-
if (config.supportsResponsesAPI) features.push('Responses API');
|
|
48
|
-
|
|
49
|
-
output += features.join(', ') + '\n';
|
|
50
|
-
|
|
51
|
-
if (config.aliases && config.aliases.length > 0) {
|
|
52
|
-
output += `- Aliases: ${config.aliases.join(', ')}\n`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
output += '\n';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return output;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// Get tools and format their documentation
|
|
62
|
-
const tools = getTools(config);
|
|
63
|
-
const formatToolParameters = (inputSchema) => {
|
|
64
|
-
if (!inputSchema || !inputSchema.properties) return '';
|
|
65
|
-
|
|
66
|
-
const params = [];
|
|
67
|
-
const { properties, required = [] } = inputSchema;
|
|
68
|
-
|
|
69
|
-
for (const [name, prop] of Object.entries(properties)) {
|
|
70
|
-
const isRequired = required.includes(name);
|
|
71
|
-
const defaultValue =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
${
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
${
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
- **
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- **
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
- **
|
|
151
|
-
- **
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
###
|
|
156
|
-
- **
|
|
157
|
-
- **
|
|
158
|
-
- **0
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
- **
|
|
164
|
-
- **
|
|
165
|
-
- **
|
|
166
|
-
- **
|
|
167
|
-
|
|
168
|
-
###
|
|
169
|
-
-
|
|
170
|
-
-
|
|
171
|
-
-
|
|
172
|
-
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
- Use
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
- \`
|
|
214
|
-
- \`
|
|
215
|
-
- \`
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
- \`
|
|
221
|
-
- \`
|
|
222
|
-
- \`
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Help Prompt Implementation
|
|
3
|
+
*
|
|
4
|
+
* Provides comprehensive help documentation for the Converse MCP Server
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { getProviders } from '../providers/index.js';
|
|
8
|
+
import { getTools } from '../tools/index.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generate comprehensive help content dynamically based on current providers
|
|
12
|
+
* @param {object} config - Configuration object (optional)
|
|
13
|
+
*/
|
|
14
|
+
export function generateHelpContent(config = null) {
|
|
15
|
+
const providers = getProviders();
|
|
16
|
+
|
|
17
|
+
// Collect all models from all providers
|
|
18
|
+
const allModels = {
|
|
19
|
+
openai: providers.openai?.getSupportedModels() || {},
|
|
20
|
+
google: providers.google?.getSupportedModels() || {},
|
|
21
|
+
xai: providers.xai?.getSupportedModels() || {},
|
|
22
|
+
anthropic: providers.anthropic?.getSupportedModels() || {},
|
|
23
|
+
mistral: providers.mistral?.getSupportedModels() || {},
|
|
24
|
+
deepseek: providers.deepseek?.getSupportedModels() || {},
|
|
25
|
+
openrouter: providers.openrouter?.getSupportedModels() || {},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Format provider models for display
|
|
29
|
+
const formatProviderModels = (providerName, models) => {
|
|
30
|
+
if (!models || Object.keys(models).length === 0) return '';
|
|
31
|
+
|
|
32
|
+
let output = `\n### ${providerName.toUpperCase()} Models\n\n`;
|
|
33
|
+
|
|
34
|
+
for (const [modelId, config] of Object.entries(models)) {
|
|
35
|
+
output += `**${modelId}** - ${config.friendlyName}\n`;
|
|
36
|
+
output += `- Description: ${config.description}\n`;
|
|
37
|
+
output += `- Context Window: ${config.contextWindow.toLocaleString()} tokens\n`;
|
|
38
|
+
output += `- Max Output: ${config.maxOutputTokens.toLocaleString()} tokens\n`;
|
|
39
|
+
output += '- Features: ';
|
|
40
|
+
|
|
41
|
+
const features = [];
|
|
42
|
+
if (config.supportsStreaming) features.push('Streaming');
|
|
43
|
+
if (config.supportsImages) features.push('Images');
|
|
44
|
+
if (config.supportsTemperature) features.push('Temperature');
|
|
45
|
+
if (config.supportsWebSearch) features.push('Web Search');
|
|
46
|
+
if (config.supportsThinking) features.push('Thinking Mode');
|
|
47
|
+
if (config.supportsResponsesAPI) features.push('Responses API');
|
|
48
|
+
|
|
49
|
+
output += features.join(', ') + '\n';
|
|
50
|
+
|
|
51
|
+
if (config.aliases && config.aliases.length > 0) {
|
|
52
|
+
output += `- Aliases: ${config.aliases.join(', ')}\n`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
output += '\n';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return output;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Get tools and format their documentation
|
|
62
|
+
const tools = getTools(config);
|
|
63
|
+
const formatToolParameters = (inputSchema) => {
|
|
64
|
+
if (!inputSchema || !inputSchema.properties) return '';
|
|
65
|
+
|
|
66
|
+
const params = [];
|
|
67
|
+
const { properties, required = [] } = inputSchema;
|
|
68
|
+
|
|
69
|
+
for (const [name, prop] of Object.entries(properties)) {
|
|
70
|
+
const isRequired = required.includes(name);
|
|
71
|
+
const defaultValue =
|
|
72
|
+
prop.default !== undefined
|
|
73
|
+
? ` (default: ${JSON.stringify(prop.default)})`
|
|
74
|
+
: '';
|
|
75
|
+
params.push(
|
|
76
|
+
`- **${name}** (${isRequired ? 'required' : 'optional'}, ${prop.type}): ${prop.description}${defaultValue}`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return params.join('\n');
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const formatToolExample = (toolName) => {
|
|
84
|
+
if (toolName === 'chat') {
|
|
85
|
+
return `\`\`\`json
|
|
86
|
+
{
|
|
87
|
+
"prompt": "Explain the code in main.js",
|
|
88
|
+
"model": "gpt-5",
|
|
89
|
+
"files": ["C:\\\\Users\\\\username\\\\project\\\\main.js"],
|
|
90
|
+
"temperature": 0.7,
|
|
91
|
+
"use_websearch": false
|
|
92
|
+
}
|
|
93
|
+
\`\`\``;
|
|
94
|
+
} else if (toolName === 'consensus') {
|
|
95
|
+
return `\`\`\`json
|
|
96
|
+
{
|
|
97
|
+
"prompt": "Should we use microservices architecture for our new project?",
|
|
98
|
+
"models": ["gpt-5", "gemini-2.5-pro", "grok-4"],
|
|
99
|
+
"files": ["./requirements.md", "C:\\\\Users\\\\username\\\\architecture.md"],
|
|
100
|
+
"enable_cross_feedback": true,
|
|
101
|
+
"temperature": 0.3
|
|
102
|
+
}
|
|
103
|
+
\`\`\``;
|
|
104
|
+
}
|
|
105
|
+
return '';
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const toolsSection = Object.entries(tools)
|
|
109
|
+
.map(([name, tool], index) => {
|
|
110
|
+
return `### ${index + 1}. ${name.charAt(0).toUpperCase() + name.slice(1)} Tool
|
|
111
|
+
${tool.description}
|
|
112
|
+
|
|
113
|
+
**Parameters:**
|
|
114
|
+
${formatToolParameters(tool.inputSchema)}
|
|
115
|
+
|
|
116
|
+
**Example Usage:**
|
|
117
|
+
${formatToolExample(name)}`;
|
|
118
|
+
})
|
|
119
|
+
.join('\n\n');
|
|
120
|
+
|
|
121
|
+
const helpContent = `# Converse MCP Server - Comprehensive Guide
|
|
122
|
+
|
|
123
|
+
Welcome to the Converse MCP Server! This guide provides detailed information about all available tools, parameters, providers, and models.
|
|
124
|
+
|
|
125
|
+
## Available Tools
|
|
126
|
+
|
|
127
|
+
${toolsSection}
|
|
128
|
+
|
|
129
|
+
## Provider Models
|
|
130
|
+
${formatProviderModels('OpenAI', allModels.openai)}
|
|
131
|
+
${formatProviderModels('Google Gemini', allModels.google)}
|
|
132
|
+
${formatProviderModels('X.AI (Grok)', allModels.xai)}
|
|
133
|
+
${formatProviderModels('Anthropic', allModels.anthropic)}
|
|
134
|
+
${formatProviderModels('Mistral', allModels.mistral)}
|
|
135
|
+
${formatProviderModels('DeepSeek', allModels.deepseek)}
|
|
136
|
+
${formatProviderModels('OpenRouter', allModels.openrouter)}
|
|
137
|
+
|
|
138
|
+
## Model Selection Tips
|
|
139
|
+
|
|
140
|
+
### For Complex Reasoning Tasks
|
|
141
|
+
- **Most Intelligent**: gpt-5, gpt-5-pro, gemini-2.5-pro, grok-4
|
|
142
|
+
- **Fast & Smart**: gpt-5-mini, gpt-5-mini, o4-mini, gemini-2.5-flash
|
|
143
|
+
- **Budget-Friendly**: gpt-5-nano, gpt-4o-mini, gemini-2.0-flash-lite
|
|
144
|
+
|
|
145
|
+
### For Quick Responses
|
|
146
|
+
- **Ultra-Fast**: gpt-5-nano, gemini-2.5-flash, gemini-2.0-flash, gpt-4o-mini
|
|
147
|
+
- **Good Balance**: gpt-5-mini, o4-mini, grok-code-fast-1
|
|
148
|
+
|
|
149
|
+
### For Large Context Windows
|
|
150
|
+
- **1M+ Tokens**: gpt-4.1 (1M), all Gemini models (1M)
|
|
151
|
+
- **400K Tokens**: gpt-5 family (gpt-5, gpt-5-mini, gpt-5-nano, gpt-5-pro)
|
|
152
|
+
- **256K Tokens**: grok-4 series
|
|
153
|
+
- **200K Tokens**: o3 series, o4-mini
|
|
154
|
+
|
|
155
|
+
### Special Features
|
|
156
|
+
- **Web Search**: gpt-5, gpt-5-mini, gpt-5-pro, o3 series, o4-mini, gpt-4 series, gemini models with grounding, grok-4
|
|
157
|
+
- **Thinking Mode**: gpt-5 series (reasoning_effort), gemini models (thinking budget)
|
|
158
|
+
- **Image Support**: All models except gemini-2.0-flash-lite and grok-code-fast-1
|
|
159
|
+
|
|
160
|
+
## Configuration Tips
|
|
161
|
+
|
|
162
|
+
### Temperature Settings
|
|
163
|
+
- **0.0-0.3**: Factual, deterministic responses
|
|
164
|
+
- **0.4-0.7**: Balanced creativity and accuracy (recommended)
|
|
165
|
+
- **0.8-1.2**: Creative writing, brainstorming
|
|
166
|
+
- **1.3-2.0**: Highly experimental, unpredictable
|
|
167
|
+
|
|
168
|
+
### Reasoning Effort (for supported models)
|
|
169
|
+
- **minimal**: Quick responses with minimal reasoning
|
|
170
|
+
- **low**: Light analysis, simple problems
|
|
171
|
+
- **medium**: Balanced reasoning (default)
|
|
172
|
+
- **high**: Deep analysis, complex problems
|
|
173
|
+
- **max**: Maximum reasoning capability
|
|
174
|
+
|
|
175
|
+
### File Context
|
|
176
|
+
- Supports multiple file formats: code files, text, markdown, JSON, etc.
|
|
177
|
+
- Use git-bash style paths on Windows: \`/c/Users/username/file.txt\`
|
|
178
|
+
- Files are automatically chunked if too large
|
|
179
|
+
- Images are base64 encoded and sent to models that support vision
|
|
180
|
+
|
|
181
|
+
### Continuation IDs
|
|
182
|
+
- Automatically generated for new conversations
|
|
183
|
+
- Returned in the response for continuing conversations
|
|
184
|
+
- Conversations expire after 24 hours of inactivity
|
|
185
|
+
|
|
186
|
+
## Best Practices
|
|
187
|
+
|
|
188
|
+
1. **Model Selection**
|
|
189
|
+
- Use "auto" to let the system choose based on availability
|
|
190
|
+
- Specify models when you need specific capabilities
|
|
191
|
+
- Consider cost vs performance tradeoffs
|
|
192
|
+
|
|
193
|
+
2. **Consensus Tool**
|
|
194
|
+
- Mix different model types for diverse perspectives
|
|
195
|
+
- Enable cross-feedback for refined responses
|
|
196
|
+
- Use lower temperature for more consistent consensus
|
|
197
|
+
|
|
198
|
+
3. **Context Management**
|
|
199
|
+
- Include only relevant files to avoid token limits
|
|
200
|
+
- Use descriptive prompts to guide model focus
|
|
201
|
+
- Leverage continuation IDs for multi-turn conversations
|
|
202
|
+
|
|
203
|
+
4. **Error Handling**
|
|
204
|
+
- Check for API key configuration if providers fail
|
|
205
|
+
- Monitor token usage to avoid context limits
|
|
206
|
+
- Use appropriate timeout settings for long-running queries
|
|
207
|
+
|
|
208
|
+
## Environment Variables
|
|
209
|
+
|
|
210
|
+
### API Keys (at least one required):
|
|
211
|
+
- \`OPENAI_API_KEY\`: For OpenAI models
|
|
212
|
+
- \`GOOGLE_API_KEY\`: For Google Gemini models
|
|
213
|
+
- \`XAI_API_KEY\`: For X.AI Grok models
|
|
214
|
+
- \`ANTHROPIC_API_KEY\`: For Anthropic Claude models
|
|
215
|
+
- \`MISTRAL_API_KEY\`: For Mistral models
|
|
216
|
+
- \`DEEPSEEK_API_KEY\`: For DeepSeek models
|
|
217
|
+
- \`OPENROUTER_API_KEY\`: For OpenRouter models
|
|
218
|
+
|
|
219
|
+
### OpenRouter Configuration:
|
|
220
|
+
- \`OPENROUTER_REFERER\`: OpenRouter referer header for compliance (required for OpenRouter)
|
|
221
|
+
- \`OPENROUTER_TITLE\`: OpenRouter X-Title header for request tracking (optional)
|
|
222
|
+
- \`OPENROUTER_DYNAMIC_MODELS\`: Enable dynamic model discovery via OpenRouter endpoints API (default: false). Must be set to true to use models in \`provider/model\` format (e.g., \`anthropic/claude-3.5-sonnet\`). When enabled, fetches actual model capabilities from API.
|
|
223
|
+
|
|
224
|
+
### Server Configuration:
|
|
225
|
+
- \`MAX_MCP_OUTPUT_TOKENS\`: Maximum response size (default: 25000)
|
|
226
|
+
- \`LOG_LEVEL\`: Logging verbosity (debug, info, warn, error)
|
|
227
|
+
- \`PORT\`: HTTP server port (default: 3157)
|
|
228
|
+
- \`HTTP_ENABLED\`: Enable HTTP transport (default: true)
|
|
229
|
+
- \`HTTP_RATE_LIMIT_ENABLED\`: Enable rate limiting (default: false)
|
|
230
|
+
- \`HTTP_RATE_LIMIT_WINDOW\`: Rate limit window in milliseconds (default: 900000 - 15 minutes)
|
|
231
|
+
- \`HTTP_RATE_LIMIT_MAX_REQUESTS\`: Maximum requests per window (default: 1000)
|
|
232
|
+
|
|
233
|
+
Note: Server name and version are automatically read from package.json.
|
|
234
|
+
|
|
235
|
+
## Need More Help?
|
|
236
|
+
|
|
237
|
+
- Check the documentation at: https://github.com/FallDownTheSystem/converse
|
|
238
|
+
- Report issues at: https://github.com/FallDownTheSystem/converse/issues
|
|
239
|
+
- View examples in the \`/examples\` directory`;
|
|
240
|
+
|
|
241
|
+
return helpContent;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Help prompt handler function
|
|
246
|
+
* @param {object} args - Prompt arguments
|
|
247
|
+
* @param {object} config - Configuration object (optional)
|
|
248
|
+
*/
|
|
249
|
+
export async function helpPromptHandler(args = {}, config = null) {
|
|
250
|
+
const { topic } = args;
|
|
251
|
+
|
|
252
|
+
const fullHelp = generateHelpContent(config);
|
|
253
|
+
|
|
254
|
+
// If no topic specified, return full help
|
|
255
|
+
if (!topic) {
|
|
256
|
+
return {
|
|
257
|
+
messages: [
|
|
258
|
+
{
|
|
259
|
+
role: 'user',
|
|
260
|
+
content: {
|
|
261
|
+
type: 'text',
|
|
262
|
+
text: `Please provide the following comprehensive help guide for the Converse MCP Server to the user. Share all of this information with them:\n\n${fullHelp}`,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Extract specific sections based on topic
|
|
270
|
+
const topicLower = topic.toLowerCase();
|
|
271
|
+
let sectionContent = '';
|
|
272
|
+
|
|
273
|
+
if (topicLower === 'tools') {
|
|
274
|
+
const toolsMatch = fullHelp.match(/## Available Tools[\s\S]*?(?=##|$)/);
|
|
275
|
+
sectionContent = toolsMatch ? toolsMatch[0] : 'Tools section not found';
|
|
276
|
+
} else if (topicLower === 'models' || topicLower === 'providers') {
|
|
277
|
+
const modelsMatch = fullHelp.match(
|
|
278
|
+
/## Provider Models[\s\S]*?(?=## Model Selection Tips|$)/,
|
|
279
|
+
);
|
|
280
|
+
sectionContent = modelsMatch ? modelsMatch[0] : 'Models section not found';
|
|
281
|
+
} else if (topicLower === 'parameters') {
|
|
282
|
+
const paramsMatch = fullHelp.match(
|
|
283
|
+
/## Configuration Tips[\s\S]*?(?=## Best Practices|$)/,
|
|
284
|
+
);
|
|
285
|
+
sectionContent = paramsMatch
|
|
286
|
+
? paramsMatch[0]
|
|
287
|
+
: 'Parameters section not found';
|
|
288
|
+
} else if (topicLower === 'examples') {
|
|
289
|
+
// Extract example usage from both tools
|
|
290
|
+
const examples = fullHelp.match(
|
|
291
|
+
/\*\*Example Usage:\*\*[\s\S]*?```[\s\S]*?```/g,
|
|
292
|
+
);
|
|
293
|
+
sectionContent = examples
|
|
294
|
+
? '## Examples\n\n' + examples.join('\n\n')
|
|
295
|
+
: 'Examples not found';
|
|
296
|
+
} else {
|
|
297
|
+
sectionContent = `Topic "${topic}" not found. Available topics: tools, models, providers, parameters, examples`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
messages: [
|
|
302
|
+
{
|
|
303
|
+
role: 'user',
|
|
304
|
+
content: {
|
|
305
|
+
type: 'text',
|
|
306
|
+
text: `Please share this help information about "${topic}" for the Converse MCP Server with the user:\n\n${sectionContent}`,
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Help prompt metadata
|
|
315
|
+
*/
|
|
316
|
+
export const helpPromptMetadata = {
|
|
317
|
+
name: 'help',
|
|
318
|
+
description:
|
|
319
|
+
'Comprehensive guide for using the Converse MCP Server with all tools, parameters, and models',
|
|
320
|
+
arguments: [
|
|
321
|
+
{
|
|
322
|
+
name: 'topic',
|
|
323
|
+
description:
|
|
324
|
+
'Specific topic to get help on (optional). Options: tools, models, providers, parameters, examples',
|
|
325
|
+
required: false,
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
};
|