converse-mcp-server 2.3.1 → 2.4.1
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 +337 -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
package/src/systemPrompts.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* System Prompts for Converse MCP Server Tools
|
|
3
|
-
*
|
|
4
|
-
* Matches the Python implementation system prompts exactly for feature parity.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Chat tool system prompt - matches Python systemprompts/chat_prompt.py
|
|
9
|
-
*/
|
|
10
|
-
export const CHAT_PROMPT = `
|
|
11
|
-
You are a senior engineering thought-partner collaborating with another AI agent. Your mission is to brainstorm, validate ideas,
|
|
12
|
-
and offer well-reasoned second opinions on technical decisions when they are justified and practical.
|
|
13
|
-
|
|
14
|
-
CRITICAL LINE NUMBER INSTRUCTIONS
|
|
15
|
-
Code is presented with line number markers "LINE│ code". These markers are for reference ONLY and MUST NOT be
|
|
16
|
-
included in any code you generate. Always reference specific line numbers in your replies in order to locate
|
|
17
|
-
exact positions if needed to point to exact locations. Include a very short code excerpt alongside for clarity.
|
|
18
|
-
Include context_start_text and context_end_text as backup references. Never include "LINE│" markers in generated code
|
|
19
|
-
snippets.
|
|
20
|
-
|
|
21
|
-
IF MORE INFORMATION IS NEEDED
|
|
22
|
-
If the agent is discussing specific code, functions, or project components that was not given as part of the context,
|
|
23
|
-
and you need additional context (e.g., related files, configuration, dependencies, test files) to provide meaningful
|
|
24
|
-
collaboration, you MUST respond ONLY with this JSON format (and nothing else). Do NOT ask for the same file you've been
|
|
25
|
-
provided unless for some reason its content is missing or incomplete:
|
|
26
|
-
{
|
|
27
|
-
"status": "files_required_to_continue",
|
|
28
|
-
"mandatory_instructions": "<your critical instructions for the agent>",
|
|
29
|
-
"files_needed": ["[file name here]", "[or some folder/]"]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
CORE PRINCIPLES
|
|
33
|
-
• Work within the existing tech stack and architecture
|
|
34
|
-
• Avoid overengineering - prefer simple, practical solutions
|
|
35
|
-
• Focus on current scope, not speculative future needs
|
|
36
|
-
• Provide concrete, actionable recommendations with clear trade-offs
|
|
37
|
-
• Surface potential issues early and challenge assumptions constructively
|
|
38
|
-
`.trim();
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Consensus tool system prompt - matches Python systemprompts/consensus_prompt.py
|
|
42
|
-
*/
|
|
43
|
-
export const CONSENSUS_PROMPT = `
|
|
44
|
-
You're analyzing a technical problem alongside other AI models. Each model will propose solutions independently, then potentially see others' approaches.
|
|
45
|
-
|
|
46
|
-
Your goal: Find the best solution, whether it's yours or another model's. The key is often a single insight that makes everything click.
|
|
47
|
-
|
|
48
|
-
CRITICAL LINE NUMBER INSTRUCTIONS
|
|
49
|
-
Code is presented with line number markers "LINE│ code". These markers are for reference ONLY and MUST NOT be
|
|
50
|
-
included in any code you generate. Always reference specific line numbers in your replies in order to locate
|
|
51
|
-
exact positions if needed to point to exact locations. Include a very short code excerpt alongside for clarity.
|
|
52
|
-
Never include "LINE│" markers in generated code snippets.
|
|
53
|
-
|
|
54
|
-
IF MORE INFORMATION IS NEEDED
|
|
55
|
-
If you need to see specific code, files, or technical context to properly analyze the problem, respond with this exact JSON:
|
|
56
|
-
{
|
|
57
|
-
"status": "files_required_to_continue",
|
|
58
|
-
"mandatory_instructions": "<your critical instructions for the agent>",
|
|
59
|
-
"files_needed": ["[file name here]", "[or some folder/]"]
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
MANDATORY RESPONSE FORMAT
|
|
63
|
-
You MUST respond in exactly this Markdown structure:
|
|
64
|
-
|
|
65
|
-
## Approach
|
|
66
|
-
Present your solution and the key insight behind it. Be direct and clear about what makes your approach work.
|
|
67
|
-
If you're reviewing others' solutions, you'll do that in a later phase.
|
|
68
|
-
|
|
69
|
-
## Why This Works
|
|
70
|
-
Explain the technical reasoning. Be specific about why this approach solves the problem effectively.
|
|
71
|
-
What's the core mechanism or principle that makes it succeed?
|
|
72
|
-
|
|
73
|
-
## Implementation
|
|
74
|
-
Provide concrete code or steps if relevant. Show exactly how to implement your approach.
|
|
75
|
-
Focus on clarity and correctness.
|
|
76
|
-
|
|
77
|
-
## Trade-offs
|
|
78
|
-
What are the limitations or considerations? Be honest about where this approach might struggle
|
|
79
|
-
or what alternatives might be better in certain contexts.
|
|
80
|
-
|
|
81
|
-
QUALITY STANDARDS
|
|
82
|
-
- Focus on finding the most elegant solution
|
|
83
|
-
- Look for the key insight that simplifies the problem
|
|
84
|
-
- Be direct - don't hedge unnecessarily
|
|
85
|
-
- Value clarity and simplicity
|
|
86
|
-
- Consider edge cases and robustness
|
|
87
|
-
- Stay technical and grounded
|
|
88
|
-
|
|
89
|
-
Remember: The best solution often has one breakthrough insight that makes the complexity fall away.
|
|
1
|
+
/**
|
|
2
|
+
* System Prompts for Converse MCP Server Tools
|
|
3
|
+
*
|
|
4
|
+
* Matches the Python implementation system prompts exactly for feature parity.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Chat tool system prompt - matches Python systemprompts/chat_prompt.py
|
|
9
|
+
*/
|
|
10
|
+
export const CHAT_PROMPT = `
|
|
11
|
+
You are a senior engineering thought-partner collaborating with another AI agent. Your mission is to brainstorm, validate ideas,
|
|
12
|
+
and offer well-reasoned second opinions on technical decisions when they are justified and practical.
|
|
13
|
+
|
|
14
|
+
CRITICAL LINE NUMBER INSTRUCTIONS
|
|
15
|
+
Code is presented with line number markers "LINE│ code". These markers are for reference ONLY and MUST NOT be
|
|
16
|
+
included in any code you generate. Always reference specific line numbers in your replies in order to locate
|
|
17
|
+
exact positions if needed to point to exact locations. Include a very short code excerpt alongside for clarity.
|
|
18
|
+
Include context_start_text and context_end_text as backup references. Never include "LINE│" markers in generated code
|
|
19
|
+
snippets.
|
|
20
|
+
|
|
21
|
+
IF MORE INFORMATION IS NEEDED
|
|
22
|
+
If the agent is discussing specific code, functions, or project components that was not given as part of the context,
|
|
23
|
+
and you need additional context (e.g., related files, configuration, dependencies, test files) to provide meaningful
|
|
24
|
+
collaboration, you MUST respond ONLY with this JSON format (and nothing else). Do NOT ask for the same file you've been
|
|
25
|
+
provided unless for some reason its content is missing or incomplete:
|
|
26
|
+
{
|
|
27
|
+
"status": "files_required_to_continue",
|
|
28
|
+
"mandatory_instructions": "<your critical instructions for the agent>",
|
|
29
|
+
"files_needed": ["[file name here]", "[or some folder/]"]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
CORE PRINCIPLES
|
|
33
|
+
• Work within the existing tech stack and architecture
|
|
34
|
+
• Avoid overengineering - prefer simple, practical solutions
|
|
35
|
+
• Focus on current scope, not speculative future needs
|
|
36
|
+
• Provide concrete, actionable recommendations with clear trade-offs
|
|
37
|
+
• Surface potential issues early and challenge assumptions constructively
|
|
38
|
+
`.trim();
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Consensus tool system prompt - matches Python systemprompts/consensus_prompt.py
|
|
42
|
+
*/
|
|
43
|
+
export const CONSENSUS_PROMPT = `
|
|
44
|
+
You're analyzing a technical problem alongside other AI models. Each model will propose solutions independently, then potentially see others' approaches.
|
|
45
|
+
|
|
46
|
+
Your goal: Find the best solution, whether it's yours or another model's. The key is often a single insight that makes everything click.
|
|
47
|
+
|
|
48
|
+
CRITICAL LINE NUMBER INSTRUCTIONS
|
|
49
|
+
Code is presented with line number markers "LINE│ code". These markers are for reference ONLY and MUST NOT be
|
|
50
|
+
included in any code you generate. Always reference specific line numbers in your replies in order to locate
|
|
51
|
+
exact positions if needed to point to exact locations. Include a very short code excerpt alongside for clarity.
|
|
52
|
+
Never include "LINE│" markers in generated code snippets.
|
|
53
|
+
|
|
54
|
+
IF MORE INFORMATION IS NEEDED
|
|
55
|
+
If you need to see specific code, files, or technical context to properly analyze the problem, respond with this exact JSON:
|
|
56
|
+
{
|
|
57
|
+
"status": "files_required_to_continue",
|
|
58
|
+
"mandatory_instructions": "<your critical instructions for the agent>",
|
|
59
|
+
"files_needed": ["[file name here]", "[or some folder/]"]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
MANDATORY RESPONSE FORMAT
|
|
63
|
+
You MUST respond in exactly this Markdown structure:
|
|
64
|
+
|
|
65
|
+
## Approach
|
|
66
|
+
Present your solution and the key insight behind it. Be direct and clear about what makes your approach work.
|
|
67
|
+
If you're reviewing others' solutions, you'll do that in a later phase.
|
|
68
|
+
|
|
69
|
+
## Why This Works
|
|
70
|
+
Explain the technical reasoning. Be specific about why this approach solves the problem effectively.
|
|
71
|
+
What's the core mechanism or principle that makes it succeed?
|
|
72
|
+
|
|
73
|
+
## Implementation
|
|
74
|
+
Provide concrete code or steps if relevant. Show exactly how to implement your approach.
|
|
75
|
+
Focus on clarity and correctness.
|
|
76
|
+
|
|
77
|
+
## Trade-offs
|
|
78
|
+
What are the limitations or considerations? Be honest about where this approach might struggle
|
|
79
|
+
or what alternatives might be better in certain contexts.
|
|
80
|
+
|
|
81
|
+
QUALITY STANDARDS
|
|
82
|
+
- Focus on finding the most elegant solution
|
|
83
|
+
- Look for the key insight that simplifies the problem
|
|
84
|
+
- Be direct - don't hedge unnecessarily
|
|
85
|
+
- Value clarity and simplicity
|
|
86
|
+
- Consider edge cases and robustness
|
|
87
|
+
- Stay technical and grounded
|
|
88
|
+
|
|
89
|
+
Remember: The best solution often has one breakthrough insight that makes the complexity fall away.
|
|
90
90
|
`.trim();
|
package/src/tools/cancelJob.js
CHANGED
|
@@ -45,7 +45,9 @@ export async function cancelJobTool(args, dependencies) {
|
|
|
45
45
|
|
|
46
46
|
if (!dependencies?.asyncJobStore) {
|
|
47
47
|
debugError('CancelJob: Missing AsyncJobStore dependency');
|
|
48
|
-
return createToolError(
|
|
48
|
+
return createToolError(
|
|
49
|
+
'Service not available: AsyncJobStore not configured',
|
|
50
|
+
);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
const { jobRunner, asyncJobStore, config, providers } = dependencies;
|
|
@@ -53,7 +55,9 @@ export async function cancelJobTool(args, dependencies) {
|
|
|
53
55
|
try {
|
|
54
56
|
// Validate continuation_id
|
|
55
57
|
if (!continuation_id || typeof continuation_id !== 'string') {
|
|
56
|
-
return createToolError(
|
|
58
|
+
return createToolError(
|
|
59
|
+
'Invalid continuation_id: must be a non-empty string',
|
|
60
|
+
);
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
debugLog(`CancelJob: Attempting to cancel job ${continuation_id}`);
|
|
@@ -68,14 +72,17 @@ export async function cancelJobTool(args, dependencies) {
|
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
debugLog(
|
|
75
|
+
debugLog(
|
|
76
|
+
`CancelJob: Found job ${continuation_id} with status: ${jobState.status}`,
|
|
77
|
+
);
|
|
72
78
|
|
|
73
79
|
// Check if job is in a cancellable state
|
|
74
80
|
const cancellableStatuses = ['queued', 'running'];
|
|
75
81
|
if (!cancellableStatuses.includes(jobState.status)) {
|
|
76
|
-
const message =
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
const message =
|
|
83
|
+
jobState.status === 'cancelled'
|
|
84
|
+
? `Job ${continuation_id} is already cancelled`
|
|
85
|
+
: `Job ${continuation_id} cannot be cancelled (status: ${jobState.status})`;
|
|
79
86
|
|
|
80
87
|
return createToolResponse({
|
|
81
88
|
status: 'not_cancellable',
|
|
@@ -95,7 +102,9 @@ export async function cancelJobTool(args, dependencies) {
|
|
|
95
102
|
const updatedJobState = await asyncJobStore.get(continuation_id);
|
|
96
103
|
|
|
97
104
|
// Calculate actual elapsed time from job creation
|
|
98
|
-
const elapsedMs =
|
|
105
|
+
const elapsedMs =
|
|
106
|
+
Date.now() -
|
|
107
|
+
(updatedJobState?.createdAt || jobState.createdAt || Date.now());
|
|
99
108
|
const elapsedSeconds = elapsedMs / 1000;
|
|
100
109
|
|
|
101
110
|
// Format elapsed time
|
|
@@ -113,7 +122,9 @@ export async function cancelJobTool(args, dependencies) {
|
|
|
113
122
|
|
|
114
123
|
// Status line with proper timing
|
|
115
124
|
const statusEmoji = '⛔';
|
|
116
|
-
const startTime = updatedJobState?.createdAt
|
|
125
|
+
const startTime = updatedJobState?.createdAt
|
|
126
|
+
? new Date(updatedJobState.createdAt).toLocaleString()
|
|
127
|
+
: 'unknown';
|
|
117
128
|
|
|
118
129
|
let statusLine = `${statusEmoji} CANCELLED | ${updatedJobState?.tool?.toUpperCase() || jobState.tool?.toUpperCase() || 'UNKNOWN'} | ${continuation_id} | Started: ${startTime} | ${timeStr} elapsed`;
|
|
119
130
|
|
|
@@ -130,9 +141,10 @@ export async function cancelJobTool(args, dependencies) {
|
|
|
130
141
|
|
|
131
142
|
// Add partial results info if available
|
|
132
143
|
if (updatedJobState?.accumulated_content) {
|
|
133
|
-
const preview =
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
const preview =
|
|
145
|
+
updatedJobState.accumulated_content.length > 200
|
|
146
|
+
? updatedJobState.accumulated_content.substring(0, 200) + '...'
|
|
147
|
+
: updatedJobState.accumulated_content;
|
|
136
148
|
parts.push(`Partial results available: "${preview}"`);
|
|
137
149
|
} else if (updatedJobState?.result) {
|
|
138
150
|
parts.push('Partial results available in job state');
|
|
@@ -149,11 +161,15 @@ export async function cancelJobTool(args, dependencies) {
|
|
|
149
161
|
cancelled_at: new Date().toISOString(),
|
|
150
162
|
previous_status: jobState.status,
|
|
151
163
|
elapsed_seconds: elapsedSeconds,
|
|
152
|
-
has_partial_results: !!(
|
|
153
|
-
|
|
164
|
+
has_partial_results: !!(
|
|
165
|
+
updatedJobState?.result || updatedJobState?.accumulated_content
|
|
166
|
+
),
|
|
167
|
+
},
|
|
154
168
|
});
|
|
155
169
|
} else {
|
|
156
|
-
debugLog(
|
|
170
|
+
debugLog(
|
|
171
|
+
`CancelJob: Failed to cancel job ${continuation_id} - may have completed`,
|
|
172
|
+
);
|
|
157
173
|
|
|
158
174
|
// Job may have completed between our checks
|
|
159
175
|
const currentJobState = await asyncJobStore.get(continuation_id);
|
|
@@ -165,14 +181,10 @@ export async function cancelJobTool(args, dependencies) {
|
|
|
165
181
|
current_status: currentJobState?.status || 'unknown',
|
|
166
182
|
});
|
|
167
183
|
}
|
|
168
|
-
|
|
169
184
|
} catch (error) {
|
|
170
185
|
debugError(`CancelJob: Error cancelling job ${continuation_id}:`, error);
|
|
171
186
|
|
|
172
|
-
return createToolError(
|
|
173
|
-
`Failed to cancel job ${continuation_id}`,
|
|
174
|
-
error
|
|
175
|
-
);
|
|
187
|
+
return createToolError(`Failed to cancel job ${continuation_id}`, error);
|
|
176
188
|
}
|
|
177
189
|
}
|
|
178
190
|
|