@baitong-dev/todo-mcp 0.0.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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ /**
40
+ * Todo MCP Server v1.0
41
+ */
42
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
43
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
44
+ const fs = __importStar(require("fs"));
45
+ const path_1 = __importDefault(require("path"));
46
+ const zod_1 = __importDefault(require("zod"));
47
+ const todowrite_txt_1 = __importDefault(require("../todowrite.txt"));
48
+ const todoread_txt_1 = __importDefault(require("../todoread.txt"));
49
+ const mcp_helpers_1 = require("@baitong-dev/mcp-helpers");
50
+ const MCP_NAME = 'Todo MCP';
51
+ const MCP_VERSION = '0.0.1';
52
+ function getTodoDir() {
53
+ const dir = path_1.default.join(mcp_helpers_1.MCP_HOME_DIR, 'todos');
54
+ if (!fs.existsSync(dir)) {
55
+ fs.mkdirSync(dir, { recursive: true });
56
+ }
57
+ return dir;
58
+ }
59
+ const server = new mcp_js_1.McpServer({
60
+ name: MCP_NAME,
61
+ version: MCP_VERSION
62
+ }, {
63
+ capabilities: {
64
+ logging: {}
65
+ }
66
+ });
67
+ const todoInfo = zod_1.default
68
+ .object({
69
+ content: zod_1.default.string().describe('Brief description of the task'),
70
+ status: zod_1.default
71
+ .enum(['pending', 'in_progress', 'completed', 'cancelled'])
72
+ .describe('Current status of the task: pending, in_progress, completed, cancelled'),
73
+ priority: zod_1.default
74
+ .enum(['high', 'medium', 'low'])
75
+ .describe('Priority level of the task: high, medium, low')
76
+ })
77
+ .meta({ ref: 'Todo' });
78
+ /**
79
+ * Set the todo list for a session
80
+ * @param sessionId The session ID to update the todo list for
81
+ * @param todos The updated todo list
82
+ */
83
+ function setTodoList(sessionId, todos) {
84
+ const todoDir = getTodoDir();
85
+ fs.writeFileSync(path_1.default.join(todoDir, `todos-${sessionId}.json`), JSON.stringify(todos));
86
+ }
87
+ /**
88
+ * Get the todo list for a session
89
+ * @param sessionId The session ID to read the todo list for
90
+ * @returns The todo list for the session
91
+ */
92
+ function getTodoList(sessionId) {
93
+ const todoDir = getTodoDir();
94
+ const todos = fs.readFileSync(path_1.default.join(todoDir, `todos-${sessionId}.json`), 'utf-8');
95
+ return JSON.parse(todos);
96
+ }
97
+ server.registerTool('todowrite', {
98
+ description: todowrite_txt_1.default,
99
+ inputSchema: zod_1.default.object({
100
+ todos: zod_1.default.array(todoInfo).describe('The updated todo list'),
101
+ sessionId: zod_1.default
102
+ .string()
103
+ .describe('The session ID to update the todo list for, fixed filling: slot') // 固定填写 "slot"
104
+ })
105
+ }, async (args) => {
106
+ setTodoList(args.sessionId, args.todos);
107
+ const result = {
108
+ title: `${args.todos.filter(x => x.status !== 'completed').length} todos`,
109
+ todos: args.todos
110
+ };
111
+ return {
112
+ content: [{ type: 'text', text: JSON.stringify(result) }],
113
+ structuredContent: result
114
+ };
115
+ });
116
+ server.registerTool('todoread', {
117
+ description: todoread_txt_1.default,
118
+ inputSchema: zod_1.default.object({
119
+ sessionId: zod_1.default
120
+ .string()
121
+ .describe('The session ID to read the todo list for, fixed filling: slot') // 固定填写 "slot"
122
+ })
123
+ }, async (args) => {
124
+ const todos = getTodoList(args.sessionId);
125
+ const result = {
126
+ title: `${todos.filter(x => x.status !== 'completed').length} todos`,
127
+ todos
128
+ };
129
+ return {
130
+ content: [{ type: 'text', text: JSON.stringify(result) }],
131
+ structuredContent: result
132
+ };
133
+ });
134
+ // =============================================================================
135
+ // Start Server
136
+ // =============================================================================
137
+ const transport = new stdio_js_1.StdioServerTransport();
138
+ server.connect(transport);
139
+ console.error(`${MCP_NAME} Server v${MCP_VERSION} running`);
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@baitong-dev/todo-mcp",
3
+ "version": "0.0.1",
4
+ "main": "./dist/index.js",
5
+ "bin": {
6
+ "@baitong-dev/todo-mcp": "./dist/index.js"
7
+ },
8
+ "files": [
9
+ "dist",
10
+ "todoread.txt",
11
+ "todowrite.txt",
12
+ "README.md"
13
+ ],
14
+ "keywords": [
15
+ "mcp",
16
+ "todo"
17
+ ],
18
+ "description": "todo-mcp",
19
+ "dependencies": {
20
+ "@modelcontextprotocol/sdk": "^1.25.1",
21
+ "zod": "^4.3.4",
22
+ "@baitong-dev/mcp-helpers": "0.0.1"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org"
27
+ },
28
+ "scripts": {
29
+ "tsc": "tsc ./src/index.ts --declaration --module commonjs --target es2021 --esModuleInterop --outDir ./dist"
30
+ }
31
+ }
package/todoread.txt ADDED
@@ -0,0 +1,13 @@
1
+ Use this tool to read the current to-do list for the session. This tool should be used proactively and frequently to ensure that you are aware of
2
+ the status of the current task list. You should make use of this tool as often as possible, especially in the following situations:
3
+ - At the beginning of conversations to see what's pending
4
+ - Before starting new tasks to prioritize work
5
+ - When the user asks about previous tasks or plans
6
+ - Whenever you're uncertain about what to do next
7
+ - After completing tasks to update your understanding of remaining work
8
+ - After every few messages to ensure you're on track
9
+
10
+ Usage:
11
+ - Returns a list of todo items with their status, priority, and content
12
+ - Use this information to track progress and plan next steps
13
+ - If no todos exist yet, an empty list will be returned
package/todowrite.txt ADDED
@@ -0,0 +1,166 @@
1
+ Use this tool to create and manage a structured task list for your current session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
2
+ It also helps the user understand the progress of the task and overall progress of their requests.
3
+
4
+ ## When to Use This Tool
5
+ Use this tool proactively in these scenarios:
6
+
7
+ 1. Complex multistep tasks - When a task requires 3 or more distinct steps or actions
8
+ 2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
9
+ 3. User explicitly requests todo list - When the user directly asks you to use the todo list
10
+ 4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
11
+ 5. After receiving new instructions - Immediately capture user requirements as todos. Feel free to edit the todo list based on new information.
12
+ 6. After completing a task - Mark it complete and add any new follow-up tasks
13
+ 7. When you start working on a new task, mark the todo as in_progress. Ideally you should only have one todo as in_progress at a time. Complete existing tasks before starting new ones.
14
+
15
+ ## When NOT to Use This Tool
16
+
17
+ Skip using this tool when:
18
+ 1. There is only a single, straightforward task
19
+ 2. The task is trivial and tracking it provides no organizational benefit
20
+ 3. The task can be completed in less than 3 trivial steps
21
+ 4. The task is purely conversational or informational
22
+
23
+ NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
24
+
25
+ ## Examples of When to Use the Todo List
26
+
27
+ <example>
28
+ User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!
29
+ Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
30
+ *Creates todo list with the following items:*
31
+ 1. Create dark mode toggle component in Settings page
32
+ 2. Add dark mode state management (context/store)
33
+ 3. Implement CSS-in-JS styles for dark theme
34
+ 4. Update existing components to support theme switching
35
+ 5. Run tests and build process, addressing any failures or errors that occur
36
+ *Begins working on the first task*
37
+
38
+ <reasoning>
39
+ The assistant used the todo list because:
40
+ 1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
41
+ 2. The user explicitly requested tests and build be run afterward
42
+ 3. The assistant inferred that tests and build need to pass by adding "Ensure tests and build succeed" as the final task
43
+ </reasoning>
44
+ </example>
45
+
46
+ <example>
47
+ User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
48
+ Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
49
+ *Uses grep or search tools to locate all instances of getCwd in the codebase*
50
+ Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
51
+ *Creates todo list with specific items for each file that needs updating*
52
+
53
+ <reasoning>
54
+ The assistant used the todo list because:
55
+ 1. First, the assistant searched to understand the scope of the task
56
+ 2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
57
+ 3. The todo list helps ensure every instance is tracked and updated systematically
58
+ 4. This approach prevents missing any occurrences and maintains code consistency
59
+ </reasoning>
60
+ </example>
61
+
62
+
63
+ <example>
64
+ User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
65
+ Assistant: I'll help implement these features. First, let's add all the features to the todo list.
66
+ *Creates a todo list breaking down each feature into specific tasks based on the project architecture*
67
+ Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.
68
+
69
+ <reasoning>
70
+ The assistant used the todo list because:
71
+ 1. The user provided multiple complex features to implement in a comma separated list
72
+ 2. The todo list helps organize these large features into manageable tasks
73
+ 3. This approach allows for tracking progress across the entire implementation
74
+ </reasoning>
75
+ </example>
76
+
77
+ <example>
78
+ User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
79
+ Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
80
+ *Reviews component structure, render patterns, state management, and data fetching*
81
+ Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
82
+ *Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*
83
+ Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>
84
+
85
+ <reasoning>
86
+ The assistant used the todo list because:
87
+ 1. First, the assistant examined the codebase to identify specific performance issues
88
+ 2. Based on this analysis, it identified multiple optimization opportunities
89
+ 3. Performance optimization is a non-trivial task requiring multiple steps
90
+ 4. The todo list helps methodically track improvements across different components
91
+ 5. This systematic approach ensures all performance bottlenecks are addressed
92
+ </reasoning>
93
+ </example>
94
+
95
+ ## Examples of When NOT to Use the Todo List
96
+
97
+ <example>
98
+ User: How do I print 'Hello World' in Python?
99
+ Assistant: In Python, you can print "Hello World" with this simple code:
100
+
101
+ python
102
+ print("Hello World")
103
+
104
+ This will output the text "Hello World" to the console when executed.</assistant>
105
+
106
+ <reasoning>
107
+ The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.
108
+ </reasoning>
109
+ </example>
110
+
111
+ <example>
112
+ User: What does the git status command do?
113
+ Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.
114
+
115
+ <reasoning>
116
+ The assistant did not use the todo list because this is an informational request with no actual task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
117
+ </reasoning>
118
+ </example>
119
+
120
+ <example>
121
+ User: Can you add a comment to the calculateTotal function to explain what it does?
122
+ Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
123
+ * Uses the Edit tool to add a comment to the calculateTotal function *
124
+
125
+ <reasoning>
126
+ The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.
127
+ </reasoning>
128
+ </example>
129
+
130
+ <example>
131
+ User: Run npm install for me and tell me what happens.
132
+ Assistant: I'll run the npm install command for you.
133
+
134
+ *Executes: npm install*
135
+
136
+ The command completed successfully. Here's the output:
137
+ [Output of npm install command]
138
+
139
+ All dependencies have been installed according to your package.json file.
140
+
141
+ <reasoning>
142
+ The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.
143
+ </reasoning>
144
+ </example>
145
+
146
+ ## Task States and Management
147
+
148
+ 1. **Task States**: Use these states to track progress:
149
+ - pending: Task not yet started
150
+ - in_progress: Currently working on (limit to ONE task at a time)
151
+ - completed: Task finished successfully
152
+ - cancelled: Task no longer needed
153
+
154
+ 2. **Task Management**:
155
+ - Update task status in real-time as you work
156
+ - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
157
+ - Only have ONE task in_progress at any time
158
+ - Complete current tasks before starting new ones
159
+ - Cancel tasks that become irrelevant
160
+
161
+ 3. **Task Breakdown**:
162
+ - Create specific, actionable items
163
+ - Break complex tasks into smaller, manageable steps
164
+ - Use clear, descriptive task names
165
+
166
+ When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.