Skip to content

Commit fb17ddb

Browse files
committed
feat: Update version to 0.1.0-beta.5; fix typos in interface names and descriptions; enhance workflow state management with step status tracking and progress formatting
1 parent 24e9d33 commit fb17ddb

File tree

10 files changed

+406
-129
lines changed

10 files changed

+406
-129
lines changed

packages/core/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcpc/core",
3-
"version": "0.1.0-beta.4",
3+
"version": "0.1.0-beta.5",
44
"tasks": {
55
"server:compile": "echo \"no need to compile\""
66
},

packages/core/src/compose.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "@modelcontextprotocol/sdk/server/index.js";
1414
import type z from "zod";
1515
import { composeMcpDepTools, parseTags } from "../mod.ts";
16-
import type { ComposeDefination } from "./set-up-mcp-compose.ts";
16+
import type { ComposeDefinition } from "./set-up-mcp-compose.ts";
1717
import { updateRefPaths } from "./utils/common/schema.ts";
1818
import type { ToolCallback, JSONSchema } from "./types.ts";
1919
import { registerAgenticTool } from "./workflow/agentic-tool-registrar.ts";
@@ -215,7 +215,7 @@ export class ComposableMCPServer extends Server {
215215
name: string,
216216
description: string,
217217
depsConfig: z.infer<typeof McpSettingsSchema> = { mcpServers: {} },
218-
options: ComposeDefination["options"] = { mode: "agentic" }
218+
options: ComposeDefinition["options"] = { mode: "agentic" }
219219
) {
220220
const { tagToResults, $ } = parseTags(description, ["tool", "fn"]);
221221

packages/core/src/controllers/core.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const coreHandler = (app: OpenAPIHono) => {
1010
info: {
1111
title: "tencentcloudapi openapi spec",
1212
version: "1.0.0",
13-
description: "openapi defination of tencentcloudapi",
13+
description: "openapi definition of tencentcloudapi",
1414
},
1515
});
1616
};

packages/core/src/prompts/index.ts

Lines changed: 142 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* MCPC Prompt Management System
3-
*
3+
*
44
* Centralized management for all prompts and templates used across MCPC.
55
* Supports dynamic content replacement and template variables.
66
*/
@@ -25,7 +25,6 @@ export const SystemPrompts = {
2525
2. **Plan Next Action:** Anticipate the likely next step needed (if any)
2626
2727
**⚡ Key Rules:**
28-
- Execute ONE action per iteration
2928
- Use structured protocol - no direct tool calls
3029
- Always analyze results before proceeding`,
3130

@@ -44,7 +43,7 @@ export const SystemPrompts = {
4443
**⚡ SUBSEQUENT CALLS (Execution):**
4544
- Provide ONLY current step parameters
4645
- **ADVANCE STEP**: Set \`proceed: true\` to move to next step
47-
- **RETRY STEP**: Set \`proceed: false\` (or omit) to retry current step
46+
- **RETRY STEP**: Set \`proceed: false\`
4847
- Use \`reasoning\` action for thinking/analysis
4948
5049
**🚫 Do NOT include \`steps\` parameter during normal execution**
@@ -83,7 +82,7 @@ export const WorkflowPrompts = {
8382
*/
8483
WORKFLOW_INIT: `Workflow initialized with {stepCount} steps. You MUST start the workflow with the first step to \`{currentStepDescription}\`.
8584
86-
## EXECUTE tool \`{toolName}\` with following new tool arguments
85+
## EXECUTE tool \`{toolName}\` with the following new parameter definition
8786
8887
{schemaDefinition}
8988
@@ -92,8 +91,9 @@ export const WorkflowPrompts = {
9291
- **Do NOT include 'steps' parameter during normal step execution**
9392
- **MUST Use the provided JSON schema definition above for parameter generation and validation**
9493
- **ADVANCE STEP: Set 'proceed' to true to advance to next step**
95-
- **RETRY STEP: Set 'proceed' to false or omit it to re-execute current step**
96-
- **⚠️ CRITICAL: When retrying failed steps, NEVER set 'proceed' to true**
94+
- **RETRY STEP: Set 'proceed' to false to re-execute current step**
95+
- **⚠️ CRITICAL: When retrying failed steps, MUST set 'proceed' to false**
96+
9797
{workflowSteps}`,
9898

9999
/**
@@ -112,16 +112,79 @@ export const WorkflowPrompts = {
112112
* Planning instructions for dynamic workflows
113113
*/
114114
DYNAMIC_WORKFLOW_PLANNING: `- Set \`init: true\` and define complete \`steps\` array`,
115+
116+
/**
117+
* Next step decision prompt
118+
*/
119+
NEXT_STEP_DECISION: `**Next Step Decision Required**
120+
121+
Previous step completed. Choose your action:
122+
123+
**🔄 RETRY Current Step:**
124+
- Call \`{toolName}\` with current parameters
125+
- ⚠️ CRITICAL: Set \`proceed: false\`
126+
127+
**▶️ PROCEED to Next Step:**
128+
- Call \`{toolName}\` with parameters below
129+
- Set \`proceed: true\`
130+
131+
Next step: \`{nextStepDescription}\`
132+
133+
{nextStepSchema}
134+
135+
**Important:** Exclude \`steps\` key from your parameters`,
136+
137+
/**
138+
* Final step completion prompt
139+
*/
140+
FINAL_STEP_COMPLETION: `**Step Complete - Workflow Ending** {statusIcon}
141+
142+
Current step executed {statusText}. Choose your next action:
143+
144+
**1. ▶️ Complete Workflow:** Call \`{toolName}\` with \`proceed: true\` to finish
145+
**2. 🔄 Retry Final Step:** Call \`{toolName}\` with final step parameters
146+
**3. 🆕 New Workflow:** Call \`{toolName}\` with \`init: true\`{newWorkflowInstructions}
147+
148+
**Note:** Use \`proceed: true\` to officially complete the workflow.`,
149+
150+
/**
151+
* Workflow completion success message
152+
*/
153+
WORKFLOW_COMPLETED: `**Workflow Completed Successfully** ✅
154+
155+
All workflow steps have been executed and the workflow is now complete.
156+
157+
**Summary:**
158+
- Total steps: {totalSteps}
159+
- All steps executed successfully
160+
161+
You can now start a new workflow if needed by calling \`{toolName}\` with \`init: true\`{newWorkflowInstructions}.`,
162+
163+
/**
164+
* Error messages
165+
*/
166+
ERRORS: {
167+
NOT_INITIALIZED: {
168+
WITH_PREDEFINED:
169+
"Error: Workflow not initialized. Please provide 'init' parameter to start a new workflow.",
170+
WITHOUT_PREDEFINED:
171+
"Error: Workflow not initialized. Please provide 'init' and 'steps' parameter to start a new workflow.",
172+
},
173+
ALREADY_AT_FINAL:
174+
"Error: Cannot proceed, you are already at the final step.",
175+
NO_STEPS_PROVIDED: "Error: No steps provided",
176+
NO_CURRENT_STEP: "Error: No current step to execute",
177+
},
115178
};
116179

117180
/**
118181
* Response templates for different scenarios
119182
*/
120183
export const ResponseTemplates = {
121184
/**
122-
* Success response for tool execution
185+
* Success response for action execution
123186
*/
124-
TOOL_SUCCESS: `# You WILL call this tool(\`{toolName}\`) AGAIN using the \`{nextAction}\` action, after evaluating the result from previous action({currentAction}):`,
187+
ACTION_SUCCESS: `# You WILL call this tool(\`{toolName}\`) AGAIN using the \`{nextAction}\` action, after evaluating the result from previous action({currentAction}):`,
125188

126189
/**
127190
* Planning prompt when no next action is specified
@@ -131,12 +194,12 @@ export const ResponseTemplates = {
131194
/**
132195
* Error response template
133196
*/
134-
ERROR_RESPONSE: `Tool/Function argument validation failed: {errorMessage}`,
197+
ERROR_RESPONSE: `Action/Function argument validation failed: {errorMessage}`,
135198

136199
/**
137200
* Completion message
138201
*/
139-
COMPLETION_MESSAGE: `Completed, no dependent tools to execute`,
202+
COMPLETION_MESSAGE: `Completed, no dependent actions to execute`,
140203

141204
/**
142205
* Security validation messages
@@ -183,7 +246,10 @@ export const CompiledPrompts = {
183246
toolUsageInstructions: p(SystemPrompts.TOOL_USAGE_INSTRUCTIONS),
184247
workflowInit: p(WorkflowPrompts.WORKFLOW_INIT),
185248
workflowToolDescription: p(WorkflowPrompts.WORKFLOW_TOOL_DESCRIPTION),
186-
toolSuccess: p(ResponseTemplates.TOOL_SUCCESS),
249+
nextStepDecision: p(WorkflowPrompts.NEXT_STEP_DECISION),
250+
finalStepCompletion: p(WorkflowPrompts.FINAL_STEP_COMPLETION),
251+
workflowCompleted: p(WorkflowPrompts.WORKFLOW_COMPLETED),
252+
actionSuccess: p(ResponseTemplates.ACTION_SUCCESS),
187253
planningPrompt: p(ResponseTemplates.PLANNING_PROMPT),
188254
errorResponse: p(ResponseTemplates.ERROR_RESPONSE),
189255
securityPassed: p(ResponseTemplates.SECURITY_VALIDATION.PASSED),
@@ -199,36 +265,77 @@ export const PromptUtils = {
199265
/**
200266
* Generate tool list for descriptions
201267
*/
202-
generateToolList: (tools: Array<{ name: string; description?: string; hide?: boolean }>) => {
268+
generateToolList: (
269+
tools: Array<{ name: string; description?: string; hide?: boolean }>
270+
) => {
203271
return tools
204-
.filter(tool => !tool.hide)
205-
.map(tool => `<tool name="${tool.name}"${tool.description ? ` description="${tool.description}"` : ''}/>`)
206-
.join('\n');
272+
.filter((tool) => !tool.hide)
273+
.map(
274+
(tool) =>
275+
`<tool name="${tool.name}"${
276+
tool.description ? ` description="${tool.description}"` : ""
277+
}/>`
278+
)
279+
.join("\n");
207280
},
208281

209282
/**
210283
* Generate hidden tool list for descriptions
211284
*/
212285
generateHiddenToolList: (tools: Array<{ name: string; hide?: boolean }>) => {
213286
return tools
214-
.filter(tool => tool.hide)
215-
.map(tool => `<tool name="${tool.name}" hide/>`)
216-
.join('\n');
287+
.filter((tool) => tool.hide)
288+
.map((tool) => `<tool name="${tool.name}" hide/>`)
289+
.join("\n");
217290
},
218291

219292
/**
220293
* Format workflow steps for display
221294
*/
222-
formatWorkflowSteps: (steps: Array<{ description: string; actions: string[] }>) => {
223-
if (!steps.length) return '';
295+
formatWorkflowSteps: (
296+
steps: Array<{ description: string; actions: string[] }>
297+
) => {
298+
if (!steps.length) return "";
224299
return `## Workflow Steps\n${JSON.stringify(steps, null, 2)}`;
225300
},
226301

302+
/**
303+
* Format workflow progress display with status icons
304+
*/
305+
formatWorkflowProgress: (progressData: {
306+
steps: Array<{ description: string; actions: string[] }>;
307+
statuses: Array<string>;
308+
currentStepIndex: number;
309+
}) => {
310+
const statusIcons = {
311+
pending: "⏳",
312+
running: "🔄",
313+
completed: "✅",
314+
failed: "❌",
315+
};
316+
317+
return progressData.steps
318+
.map((step, index) => {
319+
const status = progressData.statuses[index] || "pending";
320+
const icon = statusIcons[status as keyof typeof statusIcons] || "⏳";
321+
const current =
322+
index === progressData.currentStepIndex ? " **[CURRENT]**" : "";
323+
const actions =
324+
step.actions.length > 0
325+
? ` | Action: ${step.actions.join(", ")}`
326+
: "";
327+
return `${icon} **Step ${index + 1}:** ${
328+
step.description
329+
}${actions}${current}`;
330+
})
331+
.join("\n");
332+
},
333+
227334
/**
228335
* Generate user info for audit logs
229336
*/
230337
formatUserInfo: (user?: string) => {
231-
return user ? ` by ${user}` : '';
338+
return user ? ` by ${user}` : "";
232339
},
233340

234341
/**
@@ -237,6 +344,20 @@ export const PromptUtils = {
237344
formatTimestamp: () => {
238345
return new Date().toISOString();
239346
},
347+
348+
/**
349+
* Extract and format text content from CallToolResult
350+
*/
351+
extractActionResultText: (actionResult: {
352+
content?: Array<{ type: string; text?: string }>;
353+
}) => {
354+
return (
355+
actionResult.content
356+
?.filter((item) => item.type === "text")
357+
?.map((item) => item.text)
358+
?.join("\n") || "No text content"
359+
);
360+
},
240361
};
241362

242363
/**

packages/core/src/set-up-mcp-compose.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { MCPSetting } from "./service/tools.ts";
66

77
export const INCOMING_MSG_ROUTE_PATH = "/core/messages";
88

9-
export interface ComposeDefination {
9+
export interface ComposeDefinition {
1010
name: string;
1111
description: string;
1212
deps?: MCPSetting;
@@ -31,12 +31,12 @@ export interface ComposeDefination {
3131
}
3232

3333
export interface ComposibleMCPConfig {
34-
[key: string]: ComposeDefination[];
34+
[key: string]: ComposeDefinition[];
3535
}
3636

3737
export function parseMcpcConfigs(
38-
conf?: ComposeDefination[]
39-
): ComposeDefination[] {
38+
conf?: ComposeDefinition[]
39+
): ComposeDefinition[] {
4040
const mcpcConfigRaw =
4141
minimist(process.argv.slice(2))?.["mcpc-config"] ?? process.env.MCPC_CONFIG;
4242
const mcpcConfigs = conf ?? JSON.parse(mcpcConfigRaw);
@@ -61,7 +61,7 @@ export function parseMcpcConfigs(
6161

6262
export async function mcpc(
6363
serverConf: ConstructorParameters<typeof ComposableMCPServer>,
64-
composeConf?: ComposeDefination[],
64+
composeConf?: ComposeDefinition[],
6565
setupCallback?: (server: ComposableMCPServer) => void | Promise<void>
6666
): Promise<InstanceType<typeof ComposableMCPServer>> {
6767
const server = new ComposableMCPServer(...serverConf);

packages/core/src/utils/common/ai.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ export async function composeMcpDepTools(
151151
const allTools: Record<string, any> = {};
152152

153153
// Process each MCP definition sequentially
154-
for (const [name, defination] of Object.entries(mcpConfig.mcpServers)) {
155-
const def = defination as z.infer<typeof ServerConfigSchema>;
154+
for (const [name, definition] of Object.entries(mcpConfig.mcpServers)) {
155+
const def = definition as z.infer<typeof ServerConfigSchema>;
156156

157157
if (def.disabled) {
158158
continue;

0 commit comments

Comments
 (0)