agent-workflow-mcp-tool
v1.0.4
Published
Code controlled agent workflow. Agent lies, code not.
Downloads
42
Readme
agent-workflow-mcp-tool
Code controlled agent workflow. Agent lies, code not.
- typescript support
- async await support
- throw catch support
- sub agent support
- works well with claude & deepseek-v3.2 & kimi-k2
usage
npm install agent-workflow-mcp-toolimport { registerWorkflowTool, Prompt, ClaudeCodeTools, z } from 'agent-workflow-mcp-tool';simple demo to sum number with claude code:
const server = new McpServer({
name: "agent-workflow",
version: "0.0.1",
});
registerWorkflowTool(
server,
"sum-number",
{
title: "sum number",
description: `ask user input number, and sum from 1 to input number.`,
},
async function* Workflow() {
const count = yield* ClaudeCodeTools.AskUserQuestion(
`please input a number`,
z.number()
);
let sum = 0;
for (let i = 1; i <= count; i++) {
sum = yield* Prompt(`calculate ${sum} + ${i}`, z.number());
}
return sum;
}
);Ask: use mcp "agent-workflow" tool "sum-number" directlyanother complex demo to auto commit:
registerWorkflowTool(
server,
"auto-commit",
{
title: "Auto Commit",
description: "Automatically generates a commit message and commits current changes.",
},
async function* Workflow() {
// Step 1: Get the list of changed files
const filesChangeList = yield* Prompt(
"Get the list of currently changed files",
z.array(z.string())
);
if (filesChangeList.length === 0) {
return "No code changes detected.";
}
// Step 2: Generate a structured commit message
const commitMessage = yield* Prompt(
`Generate a commit message based on the current changes. The format must follow:
(fix|feat|chore): a concise single-line summary
Detailed description of changes in multiple lines if necessary.`,
z.string()
);
// Step 3: User confirmation
const { is_confirm } = yield* ClaudeCodeTools.AskUserQuestion(
`The suggested commit message is: \n\n${commitMessage}\n\nDo you want to proceed with the commit?`,
z.object({
is_confirm: z.boolean(),
})
);
if (!is_confirm) return "Commit cancelled by user.";
// Step 4: Execute the commit
yield* Prompt(`Commit the current changes with the following message: ${commitMessage}`);
return "Changes committed successfully!";
}
);