@krr2020/taskflow-mcp-server 0.1.0-beta.1 → 0.1.0-beta.3

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/dist/index.js CHANGED
@@ -3,11 +3,13 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { CallToolRequestSchema, ListToolsRequestSchema, ErrorCode, McpError, } from "@modelcontextprotocol/sdk/types.js";
5
5
  import { z } from "zod";
6
- import { StateMachine, ConfigLoader, GitManager } from "@krr2020/taskflow-core";
7
- // Initialize Core Components
8
- const configLoader = new ConfigLoader();
9
- const gitManager = new GitManager();
10
- const stateMachine = new StateMachine(configLoader, gitManager);
6
+ import process from "node:process";
7
+ // Import all commands from core package
8
+ import { InitCommand, StatusCommand, NextCommand, StartCommand, CheckCommand, CommitCommand, ResumeCommand, SkipCommand, PrdCreateCommand, PrdGenerateArchCommand, TasksGenerateCommand, RetroAddCommand, RetroListCommand, } from "@krr2020/taskflow-core";
9
+ // Create command context
10
+ const context = {
11
+ projectRoot: process.cwd(),
12
+ };
11
13
  // Initialize MCP Server
12
14
  const server = new Server({
13
15
  name: "taskflow-mcp-server",
@@ -21,184 +23,364 @@ const server = new Server({
21
23
  server.setRequestHandler(ListToolsRequestSchema, async () => {
22
24
  return {
23
25
  tools: [
26
+ // Initialization
24
27
  {
25
- name: "start_task",
26
- description: "Start a new task, checking out the correct story branch and entering PLANNING mode.",
28
+ name: "init",
29
+ description: "Initialize Taskflow in the current project. Creates taskflow.config.json and .taskflow directory structure with template files.",
27
30
  inputSchema: {
28
31
  type: "object",
29
32
  properties: {
30
- taskId: {
33
+ projectName: {
31
34
  type: "string",
32
- description: "The ID of the task to start (e.g., '1.2.3')",
35
+ description: "Project name (optional, defaults to directory name)",
33
36
  },
34
- storyId: {
37
+ },
38
+ },
39
+ },
40
+ // Status & Navigation
41
+ {
42
+ name: "get_status",
43
+ description: "Get project status, feature status, or story status. Shows progress, tasks, and active task information.",
44
+ inputSchema: {
45
+ type: "object",
46
+ properties: {
47
+ id: {
35
48
  type: "string",
36
- description: "The Story ID this task belongs to (e.g., '15')",
49
+ description: "Optional: Feature ID (N) or Story ID (N.M) to get specific status",
37
50
  },
38
- slug: {
51
+ },
52
+ },
53
+ },
54
+ {
55
+ name: "find_next_task",
56
+ description: "Find the next available task that can be worked on. Checks dependencies and returns task details.",
57
+ inputSchema: {
58
+ type: "object",
59
+ properties: {},
60
+ },
61
+ },
62
+ // PRD Generation
63
+ {
64
+ name: "prd_create",
65
+ description: "Create a new PRD (Product Requirements Document) template. Generates a structured markdown template for defining features.",
66
+ inputSchema: {
67
+ type: "object",
68
+ properties: {
69
+ featureName: {
39
70
  type: "string",
40
- description: "Short slug for the story (e.g., 'user-auth')",
71
+ description: "Name of the feature (e.g., 'user-authentication')",
41
72
  },
42
73
  },
43
- required: ["taskId", "storyId", "slug"],
74
+ required: ["featureName"],
44
75
  },
45
76
  },
46
77
  {
47
- name: "approve_plan",
48
- description: "Approve the implementation plan and switch to EXECUTION mode.",
78
+ name: "prd_generate_arch",
79
+ description: "Generate CODING-STANDARDS.md and ARCHITECTURE-RULES.md from a PRD. Analyzes codebase and PRD to create project-specific standards.",
49
80
  inputSchema: {
50
81
  type: "object",
51
- properties: {},
82
+ properties: {
83
+ prdFile: {
84
+ type: "string",
85
+ description: "PRD filename (e.g., '2024-01-15-user-auth.md')",
86
+ },
87
+ },
88
+ required: ["prdFile"],
52
89
  },
53
90
  },
91
+ // Task Generation
54
92
  {
55
- name: "get_status",
56
- description: "Get the current state machine status and active task.",
93
+ name: "tasks_generate",
94
+ description: "Generate complete task breakdown from a PRD. Creates features, stories, and tasks with dependencies.",
95
+ inputSchema: {
96
+ type: "object",
97
+ properties: {
98
+ prdFile: {
99
+ type: "string",
100
+ description: "PRD filename to generate tasks from",
101
+ },
102
+ },
103
+ required: ["prdFile"],
104
+ },
105
+ },
106
+ // Task Workflow
107
+ {
108
+ name: "start_task",
109
+ description: "Start working on a task. Switches to story branch, loads requirements, sets status to SETUP. Provides comprehensive AI guidance.",
110
+ inputSchema: {
111
+ type: "object",
112
+ properties: {
113
+ taskId: {
114
+ type: "string",
115
+ description: "Task ID in format N.M.K (e.g., '1.1.0')",
116
+ },
117
+ },
118
+ required: ["taskId"],
119
+ },
120
+ },
121
+ {
122
+ name: "check_task",
123
+ description: "Validate current task and advance to next status. Behavior depends on current status (SETUP→IMPLEMENTING→VERIFYING→VALIDATING→COMMITTING).",
57
124
  inputSchema: {
58
125
  type: "object",
59
126
  properties: {},
60
127
  },
61
128
  },
62
129
  {
63
- name: "generate_prd",
64
- description: "Generate a PRD template based on project context.",
130
+ name: "commit_task",
131
+ description: "Commit changes and complete the task. Requires bullet points describing changes. Runs git add, commit, push and marks task as completed.",
65
132
  inputSchema: {
66
133
  type: "object",
67
134
  properties: {
68
- requirements: { type: "string" }
135
+ message: {
136
+ type: "string",
137
+ description: 'Bullet points describing changes (e.g., "- Added feature X\\n- Fixed bug Y")',
138
+ },
69
139
  },
140
+ required: ["message"],
70
141
  },
71
142
  },
72
143
  {
73
- name: "generate_tasks",
74
- description: "Generate tasks from a PRD.",
144
+ name: "resume_task",
145
+ description: "Resume a blocked or on-hold task. Restores task to active status and provides guidance on continuing work.",
75
146
  inputSchema: {
76
147
  type: "object",
77
148
  properties: {
78
- prdContent: { type: "string" }
149
+ status: {
150
+ type: "string",
151
+ description: "Status to resume to (setup, implementing, verifying, validating)",
152
+ enum: ["setup", "implementing", "verifying", "validating"],
153
+ },
79
154
  },
80
155
  },
81
156
  },
82
157
  {
83
- name: "run_checks",
84
- description: "Run project validations and enter VERIFICATION state.",
158
+ name: "block_task",
159
+ description: "Mark current task as blocked with a reason. Saves current status and finds next available task.",
85
160
  inputSchema: {
86
161
  type: "object",
87
- properties: {},
162
+ properties: {
163
+ reason: {
164
+ type: "string",
165
+ description: "Reason for blocking the task",
166
+ },
167
+ },
168
+ required: ["reason"],
88
169
  },
89
170
  },
171
+ // Retrospective
90
172
  {
91
- name: "submit_task",
92
- description: "Submit the current task and complete the workflow.",
173
+ name: "add_retrospective",
174
+ description: "Add a new error pattern to the retrospective. Helps prevent repeated mistakes by documenting solutions.",
93
175
  inputSchema: {
94
176
  type: "object",
95
- properties: {},
177
+ properties: {
178
+ category: {
179
+ type: "string",
180
+ description: "Error category (type_error, lint, runtime, build, test, etc.)",
181
+ },
182
+ pattern: {
183
+ type: "string",
184
+ description: "Error pattern to match in validation output",
185
+ },
186
+ solution: {
187
+ type: "string",
188
+ description: "Solution to the error",
189
+ },
190
+ criticality: {
191
+ type: "string",
192
+ description: "Criticality level (low, medium, high)",
193
+ enum: ["low", "medium", "high"],
194
+ },
195
+ },
196
+ required: ["category", "pattern", "solution"],
197
+ },
198
+ },
199
+ {
200
+ name: "list_retrospectives",
201
+ description: "List all retrospective entries. Can filter by category. Shows error patterns, solutions, and counts.",
202
+ inputSchema: {
203
+ type: "object",
204
+ properties: {
205
+ category: {
206
+ type: "string",
207
+ description: "Optional: Filter by category",
208
+ },
209
+ },
96
210
  },
97
211
  },
98
212
  ],
99
213
  };
100
214
  });
215
+ // Helper function to format command result for MCP
216
+ function formatCommandResult(result) {
217
+ const parts = [];
218
+ // Add output
219
+ if (result.output) {
220
+ parts.push(result.output);
221
+ }
222
+ // Add next steps
223
+ if (result.nextSteps) {
224
+ parts.push("\n\nNEXT STEPS:");
225
+ parts.push("─".repeat(60));
226
+ parts.push(result.nextSteps);
227
+ }
228
+ // Add AI guidance
229
+ if (result.aiGuidance) {
230
+ parts.push("\n\nAI GUIDANCE:");
231
+ parts.push("─".repeat(60));
232
+ parts.push(result.aiGuidance);
233
+ }
234
+ // Add context files
235
+ if (result.contextFiles && result.contextFiles.length > 0) {
236
+ parts.push("\n\nCONTEXT FILES:");
237
+ parts.push("─".repeat(60));
238
+ for (const file of result.contextFiles) {
239
+ parts.push(` ${file}`);
240
+ }
241
+ }
242
+ // Add warnings
243
+ if (result.warnings && result.warnings.length > 0) {
244
+ parts.push("\n\n⚠️ WARNINGS:");
245
+ parts.push("─".repeat(60));
246
+ for (const warning of result.warnings) {
247
+ parts.push(` ${warning}`);
248
+ }
249
+ }
250
+ // Add errors if failure
251
+ if (result.errors && result.errors.length > 0) {
252
+ parts.push("\n\n✗ ERRORS:");
253
+ parts.push("─".repeat(60));
254
+ for (const error of result.errors) {
255
+ parts.push(` ${error}`);
256
+ }
257
+ }
258
+ return {
259
+ content: [
260
+ {
261
+ type: "text",
262
+ text: parts.join("\n"),
263
+ },
264
+ ],
265
+ isError: result.success === false,
266
+ };
267
+ }
101
268
  // Tool Execution
102
269
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
103
270
  const { name, arguments: args } = request.params;
104
271
  try {
105
272
  switch (name) {
273
+ case "init": {
274
+ const schema = z.object({
275
+ projectName: z.string().optional(),
276
+ });
277
+ const { projectName } = schema.parse(args || {});
278
+ const cmd = new InitCommand(context);
279
+ const result = await cmd.execute(projectName);
280
+ return formatCommandResult(result);
281
+ }
282
+ case "get_status": {
283
+ const schema = z.object({
284
+ id: z.string().optional(),
285
+ });
286
+ const { id } = schema.parse(args || {});
287
+ const cmd = new StatusCommand(context);
288
+ const result = await cmd.execute(id);
289
+ return formatCommandResult(result);
290
+ }
291
+ case "find_next_task": {
292
+ const cmd = new NextCommand(context);
293
+ const result = await cmd.execute();
294
+ return formatCommandResult(result);
295
+ }
296
+ case "prd_create": {
297
+ const schema = z.object({
298
+ featureName: z.string(),
299
+ });
300
+ const { featureName } = schema.parse(args);
301
+ const cmd = new PrdCreateCommand(context);
302
+ const result = await cmd.execute(featureName);
303
+ return formatCommandResult(result);
304
+ }
305
+ case "prd_generate_arch": {
306
+ const schema = z.object({
307
+ prdFile: z.string(),
308
+ });
309
+ const { prdFile } = schema.parse(args);
310
+ const cmd = new PrdGenerateArchCommand(context);
311
+ const result = await cmd.execute(prdFile);
312
+ return formatCommandResult(result);
313
+ }
314
+ case "tasks_generate": {
315
+ const schema = z.object({
316
+ prdFile: z.string(),
317
+ });
318
+ const { prdFile } = schema.parse(args);
319
+ const cmd = new TasksGenerateCommand(context);
320
+ const result = await cmd.execute(prdFile);
321
+ return formatCommandResult(result);
322
+ }
106
323
  case "start_task": {
107
324
  const schema = z.object({
108
325
  taskId: z.string(),
109
- storyId: z.string(),
110
- slug: z.string(),
111
326
  });
112
- const { taskId, storyId, slug } = schema.parse(args);
113
- await stateMachine.startTask(taskId, storyId, slug);
114
- return {
115
- content: [
116
- {
117
- type: "text",
118
- text: `Task ${taskId} started on branch story/S${storyId}-${slug}. State is now PLANNING.`,
119
- },
120
- ],
121
- };
327
+ const { taskId } = schema.parse(args);
328
+ const cmd = new StartCommand(context);
329
+ const result = await cmd.execute(taskId);
330
+ return formatCommandResult(result);
122
331
  }
123
- case "approve_plan": {
124
- stateMachine.approvePlan();
125
- return {
126
- content: [
127
- {
128
- type: "text",
129
- text: "Plan approved. State is now EXECUTION. You may now write code.",
130
- },
131
- ],
132
- };
332
+ case "check_task": {
333
+ const cmd = new CheckCommand(context);
334
+ const result = await cmd.execute();
335
+ return formatCommandResult(result);
133
336
  }
134
- case "get_status": {
135
- return {
136
- content: [
137
- {
138
- type: "text",
139
- text: JSON.stringify({
140
- state: stateMachine.getState(),
141
- activeTask: stateMachine.getActiveTask(),
142
- }, null, 2),
143
- },
144
- ],
145
- };
337
+ case "commit_task": {
338
+ const schema = z.object({
339
+ message: z.string(),
340
+ });
341
+ const { message } = schema.parse(args);
342
+ const cmd = new CommitCommand(context);
343
+ const result = await cmd.execute(message);
344
+ return formatCommandResult(result);
146
345
  }
147
- case "generate_prd": {
148
- const template = `# Project Requirements Document
149
- ## 1. Objective
150
- [Describe the goal]
151
-
152
- ## 2. Scope
153
- - [ ] In Scope
154
- - [ ] Out of Scope
155
-
156
- ## 3. Technical Requirements
157
- - Language: [e.g., TypeScript]
158
- - Framework: [e.g., React]
159
-
160
- ## 4. User Stories
161
- - Story 1: [Description]
162
- `;
163
- return {
164
- content: [
165
- {
166
- type: "text",
167
- text: template,
168
- },
169
- ],
170
- };
346
+ case "resume_task": {
347
+ const schema = z.object({
348
+ status: z.string().optional(),
349
+ });
350
+ const { status } = schema.parse(args || {});
351
+ const cmd = new ResumeCommand(context);
352
+ const result = await cmd.execute(status);
353
+ return formatCommandResult(result);
171
354
  }
172
- case "generate_tasks": {
173
- // In a real implementation, this would parse the PRD.
174
- // For prototype, we return the schema structure.
175
- return {
176
- content: [
177
- {
178
- type: "text",
179
- text: "Please provide the tasks in the following JSON format matching the TaskSchema:\n" +
180
- JSON.stringify({
181
- id: "1.0",
182
- title: "Example Task",
183
- status: "todo",
184
- subtasks: [{ id: "1.1", title: "Subtask 1" }]
185
- }, null, 2)
186
- },
187
- ],
188
- };
355
+ case "block_task": {
356
+ const schema = z.object({
357
+ reason: z.string(),
358
+ });
359
+ const { reason } = schema.parse(args);
360
+ const cmd = new SkipCommand(context);
361
+ const result = await cmd.execute(reason);
362
+ return formatCommandResult(result);
189
363
  }
190
- case "run_checks": {
191
- stateMachine.startVerification();
192
- // TODO: Actually run the validation commands from config
193
- return {
194
- content: [{ type: "text", text: "Verification phase started. Running checks... [MOCK PASSED]" }],
195
- };
364
+ case "add_retrospective": {
365
+ const schema = z.object({
366
+ category: z.string(),
367
+ pattern: z.string(),
368
+ solution: z.string(),
369
+ criticality: z.string().optional().default("medium"),
370
+ });
371
+ const { category, pattern, solution, criticality } = schema.parse(args);
372
+ const cmd = new RetroAddCommand(context);
373
+ const result = await cmd.execute(category, pattern, solution, criticality);
374
+ return formatCommandResult(result);
196
375
  }
197
- case "submit_task": {
198
- stateMachine.completeTask();
199
- return {
200
- content: [{ type: "text", text: "Task submitted and completed. State is now IDLE." }],
201
- };
376
+ case "list_retrospectives": {
377
+ const schema = z.object({
378
+ category: z.string().optional(),
379
+ });
380
+ const { category } = schema.parse(args || {});
381
+ const cmd = new RetroListCommand(context);
382
+ const result = await cmd.execute(category);
383
+ return formatCommandResult(result);
202
384
  }
203
385
  default:
204
386
  throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
- "name": "@krr2020/taskflow-mcp-server",
3
- "version": "0.1.0-beta.1",
4
- "description": "MCP Server for Taskflow 2.0",
5
- "license": "MIT",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
- "type": "module",
10
- "main": "dist/index.js",
11
- "bin": {
12
- "taskflow-mcp": "./dist/index.js"
13
- },
14
- "dependencies": {
15
- "@modelcontextprotocol/sdk": "^0.6.0",
16
- "zod": "^3.22.4",
17
- "@krr2020/taskflow-core": "0.1.0-beta.1"
18
- },
19
- "devDependencies": {
20
- "typescript": "^5.3.3",
21
- "@types/node": "^20.11.0"
22
- },
23
- "scripts": {
24
- "build": "tsc",
25
- "start": "node dist/index.js"
26
- }
27
- }
2
+ "name": "@krr2020/taskflow-mcp-server",
3
+ "version": "0.1.0-beta.3",
4
+ "description": "MCP Server for Taskflow",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "type": "module",
10
+ "main": "dist/index.js",
11
+ "bin": {
12
+ "taskflow-mcp": "node dist/index.js"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "start": "node dist/index.js"
17
+ },
18
+ "dependencies": {
19
+ "@modelcontextprotocol/sdk": "1.25.1",
20
+ "@krr2020/taskflow-core": "0.1.0-beta.3",
21
+ "zod": "4.3.2"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "5.9.3",
25
+ "@types/node": "25.0.3"
26
+ }
27
+ }
@@ -0,0 +1,21 @@
1
+ # Rule: Generating a Product Requirements Document (PRD)
2
+
3
+ ## Goal
4
+
5
+ To guide an AI assistant in creating a detailed Product Requirements Document (PRD) in Markdown format, based on an initial user prompt. The PRD should be clear, actionable, and suitable for a junior developer to understand and implement the feature.
6
+
7
+ ## Process
8
+
9
+ 1. **Receive Initial Prompt:** The user provides a brief description or request for a new feature or functionality.
10
+ 2. **Ask Clarifying Questions:** Before writing the PRD, the AI *must* ask only the most essential clarifying questions needed to write a clear PRD. Limit questions to 3-5 critical gaps in understanding.
11
+ 3. **Generate PRD:** Based on the initial prompt and the user's answers, generate a PRD using the structure outlined below.
12
+ 4. **Save PRD:** Save the generated document as `prd-[feature-name].md` inside the `/tasks` directory.
13
+
14
+ ## Clarifying Questions (Guidelines)
15
+
16
+ Ask only the most critical questions needed to write a clear PRD.
17
+ * **Problem/Goal:** "What problem does this feature solve?"
18
+ * **Core Functionality:** "What are the key actions?"
19
+ * **Success Criteria:** "How will we know when this feature is successfully implemented?"
20
+
21
+ **Format:** Numbered list with options (A, B, C) for easy user response.
@@ -0,0 +1,21 @@
1
+ ## PRD Structure
2
+
3
+ The generated PRD should include:
4
+
5
+ 1. **Introduction/Overview**
6
+ 2. **Goals** (Specific, Measurable)
7
+ 3. **User Stories**
8
+ 4. **Functional Requirements** (Clear, concise, numbered)
9
+ 5. **Non-Goals (Out of Scope)**
10
+ 6. **Success Metrics**
11
+ 7. **Open Questions**
12
+
13
+ ## Target Audience
14
+
15
+ Assume the primary reader is a **junior developer**. Requirements should be explicit and unambiguous.
16
+
17
+ ## Output
18
+
19
+ * **Format:** Markdown (`.md`)
20
+ * **Location:** `/tasks/`
21
+ * **Filename:** `prd-[feature-name].md`