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