hanzo-mcp 0.9.0__py3-none-any.whl → 0.9.1__py3-none-any.whl

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.

Potentially problematic release.


This version of hanzo-mcp might be problematic. Click here for more details.

Files changed (135) hide show
  1. hanzo_mcp/__init__.py +1 -1
  2. hanzo_mcp/analytics/posthog_analytics.py +14 -1
  3. hanzo_mcp/cli.py +108 -4
  4. hanzo_mcp/server.py +11 -0
  5. hanzo_mcp/tools/__init__.py +3 -16
  6. hanzo_mcp/tools/agent/__init__.py +5 -0
  7. hanzo_mcp/tools/agent/agent.py +5 -0
  8. hanzo_mcp/tools/agent/agent_tool.py +3 -17
  9. hanzo_mcp/tools/agent/agent_tool_v1_deprecated.py +623 -0
  10. hanzo_mcp/tools/agent/clarification_tool.py +7 -1
  11. hanzo_mcp/tools/agent/claude_desktop_auth.py +16 -6
  12. hanzo_mcp/tools/agent/cli_agent_base.py +5 -0
  13. hanzo_mcp/tools/agent/cli_tools.py +26 -0
  14. hanzo_mcp/tools/agent/code_auth_tool.py +5 -0
  15. hanzo_mcp/tools/agent/critic_tool.py +7 -1
  16. hanzo_mcp/tools/agent/iching_tool.py +5 -0
  17. hanzo_mcp/tools/agent/network_tool.py +5 -0
  18. hanzo_mcp/tools/agent/review_tool.py +7 -1
  19. hanzo_mcp/tools/agent/swarm_alias.py +5 -0
  20. hanzo_mcp/tools/agent/swarm_tool.py +701 -0
  21. hanzo_mcp/tools/agent/swarm_tool_v1_deprecated.py +554 -0
  22. hanzo_mcp/tools/agent/unified_cli_tools.py +5 -0
  23. hanzo_mcp/tools/common/auto_timeout.py +234 -0
  24. hanzo_mcp/tools/common/base.py +4 -0
  25. hanzo_mcp/tools/common/batch_tool.py +5 -0
  26. hanzo_mcp/tools/common/config_tool.py +5 -0
  27. hanzo_mcp/tools/common/critic_tool.py +5 -0
  28. hanzo_mcp/tools/common/paginated_base.py +4 -0
  29. hanzo_mcp/tools/common/permissions.py +38 -12
  30. hanzo_mcp/tools/common/personality.py +673 -980
  31. hanzo_mcp/tools/common/stats.py +5 -0
  32. hanzo_mcp/tools/common/thinking_tool.py +5 -0
  33. hanzo_mcp/tools/common/timeout_parser.py +103 -0
  34. hanzo_mcp/tools/common/tool_disable.py +5 -0
  35. hanzo_mcp/tools/common/tool_enable.py +5 -0
  36. hanzo_mcp/tools/common/tool_list.py +5 -0
  37. hanzo_mcp/tools/config/config_tool.py +5 -0
  38. hanzo_mcp/tools/config/mode_tool.py +5 -0
  39. hanzo_mcp/tools/database/graph.py +5 -0
  40. hanzo_mcp/tools/database/graph_add.py +5 -0
  41. hanzo_mcp/tools/database/graph_query.py +5 -0
  42. hanzo_mcp/tools/database/graph_remove.py +5 -0
  43. hanzo_mcp/tools/database/graph_search.py +5 -0
  44. hanzo_mcp/tools/database/graph_stats.py +5 -0
  45. hanzo_mcp/tools/database/sql.py +5 -0
  46. hanzo_mcp/tools/database/sql_query.py +2 -0
  47. hanzo_mcp/tools/database/sql_search.py +5 -0
  48. hanzo_mcp/tools/database/sql_stats.py +5 -0
  49. hanzo_mcp/tools/editor/neovim_command.py +5 -0
  50. hanzo_mcp/tools/editor/neovim_edit.py +7 -2
  51. hanzo_mcp/tools/editor/neovim_session.py +5 -0
  52. hanzo_mcp/tools/filesystem/__init__.py +23 -26
  53. hanzo_mcp/tools/filesystem/ast_tool.py +2 -3
  54. hanzo_mcp/tools/filesystem/base.py +0 -16
  55. hanzo_mcp/tools/filesystem/batch_search.py +825 -0
  56. hanzo_mcp/tools/filesystem/content_replace.py +5 -3
  57. hanzo_mcp/tools/filesystem/diff.py +5 -0
  58. hanzo_mcp/tools/filesystem/directory_tree.py +34 -281
  59. hanzo_mcp/tools/filesystem/directory_tree_paginated.py +345 -0
  60. hanzo_mcp/tools/filesystem/edit.py +5 -4
  61. hanzo_mcp/tools/filesystem/find.py +177 -311
  62. hanzo_mcp/tools/filesystem/find_files.py +370 -0
  63. hanzo_mcp/tools/filesystem/git_search.py +5 -3
  64. hanzo_mcp/tools/filesystem/grep.py +454 -0
  65. hanzo_mcp/tools/filesystem/multi_edit.py +5 -4
  66. hanzo_mcp/tools/filesystem/read.py +11 -8
  67. hanzo_mcp/tools/filesystem/rules_tool.py +5 -3
  68. hanzo_mcp/tools/filesystem/search_tool.py +728 -0
  69. hanzo_mcp/tools/filesystem/symbols_tool.py +510 -0
  70. hanzo_mcp/tools/filesystem/tree.py +273 -0
  71. hanzo_mcp/tools/filesystem/watch.py +6 -1
  72. hanzo_mcp/tools/filesystem/write.py +12 -6
  73. hanzo_mcp/tools/jupyter/jupyter.py +30 -2
  74. hanzo_mcp/tools/jupyter/notebook_edit.py +298 -0
  75. hanzo_mcp/tools/jupyter/notebook_read.py +148 -0
  76. hanzo_mcp/tools/llm/consensus_tool.py +8 -6
  77. hanzo_mcp/tools/llm/llm_manage.py +5 -0
  78. hanzo_mcp/tools/llm/llm_tool.py +2 -0
  79. hanzo_mcp/tools/llm/llm_unified.py +5 -0
  80. hanzo_mcp/tools/llm/provider_tools.py +5 -0
  81. hanzo_mcp/tools/lsp/lsp_tool.py +475 -622
  82. hanzo_mcp/tools/mcp/mcp_add.py +7 -2
  83. hanzo_mcp/tools/mcp/mcp_remove.py +15 -2
  84. hanzo_mcp/tools/mcp/mcp_stats.py +5 -0
  85. hanzo_mcp/tools/mcp/mcp_tool.py +5 -0
  86. hanzo_mcp/tools/memory/knowledge_tools.py +14 -0
  87. hanzo_mcp/tools/memory/memory_tools.py +17 -0
  88. hanzo_mcp/tools/search/find_tool.py +5 -3
  89. hanzo_mcp/tools/search/unified_search.py +3 -1
  90. hanzo_mcp/tools/shell/__init__.py +2 -14
  91. hanzo_mcp/tools/shell/base_process.py +4 -2
  92. hanzo_mcp/tools/shell/bash_tool.py +2 -0
  93. hanzo_mcp/tools/shell/command_executor.py +7 -7
  94. hanzo_mcp/tools/shell/logs.py +5 -0
  95. hanzo_mcp/tools/shell/npx.py +5 -0
  96. hanzo_mcp/tools/shell/npx_background.py +5 -0
  97. hanzo_mcp/tools/shell/npx_tool.py +5 -0
  98. hanzo_mcp/tools/shell/open.py +5 -0
  99. hanzo_mcp/tools/shell/pkill.py +5 -0
  100. hanzo_mcp/tools/shell/process_tool.py +5 -0
  101. hanzo_mcp/tools/shell/processes.py +5 -0
  102. hanzo_mcp/tools/shell/run_background.py +5 -0
  103. hanzo_mcp/tools/shell/run_command.py +2 -0
  104. hanzo_mcp/tools/shell/run_command_windows.py +5 -0
  105. hanzo_mcp/tools/shell/streaming_command.py +5 -0
  106. hanzo_mcp/tools/shell/uvx.py +5 -0
  107. hanzo_mcp/tools/shell/uvx_background.py +5 -0
  108. hanzo_mcp/tools/shell/uvx_tool.py +5 -0
  109. hanzo_mcp/tools/shell/zsh_tool.py +3 -0
  110. hanzo_mcp/tools/todo/todo.py +5 -0
  111. hanzo_mcp/tools/todo/todo_read.py +142 -0
  112. hanzo_mcp/tools/todo/todo_write.py +367 -0
  113. hanzo_mcp/tools/vector/__init__.py +42 -95
  114. hanzo_mcp/tools/vector/index_tool.py +5 -0
  115. hanzo_mcp/tools/vector/vector.py +5 -0
  116. hanzo_mcp/tools/vector/vector_index.py +5 -0
  117. hanzo_mcp/tools/vector/vector_search.py +5 -0
  118. {hanzo_mcp-0.9.0.dist-info → hanzo_mcp-0.9.1.dist-info}/METADATA +1 -1
  119. hanzo_mcp-0.9.1.dist-info/RECORD +195 -0
  120. hanzo_mcp/tools/common/path_utils.py +0 -34
  121. hanzo_mcp/tools/compiler/__init__.py +0 -8
  122. hanzo_mcp/tools/compiler/sandboxed_compiler.py +0 -681
  123. hanzo_mcp/tools/environment/__init__.py +0 -8
  124. hanzo_mcp/tools/environment/environment_detector.py +0 -594
  125. hanzo_mcp/tools/filesystem/search.py +0 -1160
  126. hanzo_mcp/tools/framework/__init__.py +0 -8
  127. hanzo_mcp/tools/framework/framework_modes.py +0 -714
  128. hanzo_mcp/tools/memory/conversation_memory.py +0 -636
  129. hanzo_mcp/tools/shell/run_tool.py +0 -56
  130. hanzo_mcp/tools/vector/node_tool.py +0 -538
  131. hanzo_mcp/tools/vector/unified_vector.py +0 -384
  132. hanzo_mcp-0.9.0.dist-info/RECORD +0 -191
  133. {hanzo_mcp-0.9.0.dist-info → hanzo_mcp-0.9.1.dist-info}/WHEEL +0 -0
  134. {hanzo_mcp-0.9.0.dist-info → hanzo_mcp-0.9.1.dist-info}/entry_points.txt +0 -0
  135. {hanzo_mcp-0.9.0.dist-info → hanzo_mcp-0.9.1.dist-info}/top_level.txt +0 -0
@@ -9,6 +9,7 @@ from pathlib import Path
9
9
  from mcp.server import FastMCP
10
10
  from mcp.server.fastmcp import Context as MCPContext
11
11
 
12
+ from hanzo_mcp.tools.common.auto_timeout import auto_timeout
12
13
  from hanzo_mcp.tools.shell.base_process import BaseScriptTool
13
14
 
14
15
 
@@ -31,6 +32,7 @@ class ZshTool(BaseScriptTool):
31
32
  ) -> str:
32
33
  return await tool_self.run(ctx, command=command, cwd=cwd, env=env, timeout=timeout)
33
34
 
35
+ @auto_timeout("zsh")
34
36
  async def call(self, ctx: MCPContext, **params) -> str:
35
37
  """Call the tool with arguments."""
36
38
  return await self.run(
@@ -171,6 +173,7 @@ class ShellTool(BaseScriptTool):
171
173
  ) -> str:
172
174
  return await tool_self.run(ctx, command=command, cwd=cwd, env=env, timeout=timeout)
173
175
 
176
+ @auto_timeout("shell")
174
177
  async def call(self, ctx: MCPContext, **params) -> str:
175
178
  """Call the tool with arguments."""
176
179
  return await self.run(
@@ -16,6 +16,8 @@ from datetime import datetime
16
16
  from pydantic import Field
17
17
  from mcp.server.fastmcp import Context as MCPContext
18
18
 
19
+ from hanzo_mcp.tools.common.auto_timeout import auto_timeout
20
+
19
21
  from hanzo_mcp.tools.todo.base import TodoBaseTool
20
22
 
21
23
  # Parameter types
@@ -104,6 +106,9 @@ todo --filter in_progress
104
106
  """
105
107
 
106
108
  @override
109
+ @auto_timeout("todo")
110
+
111
+
107
112
  async def call(
108
113
  self,
109
114
  ctx: MCPContext,
@@ -0,0 +1,142 @@
1
+ """TodoRead tool implementation.
2
+
3
+ This module provides the TodoRead tool for reading the current todo list for a session.
4
+ """
5
+
6
+ import json
7
+ from typing import Unpack, Annotated, TypedDict, final, override
8
+
9
+ from pydantic import Field
10
+ from mcp.server import FastMCP
11
+
12
+ from hanzo_mcp.tools.common.auto_timeout import auto_timeout
13
+ from mcp.server.fastmcp import Context as MCPContext
14
+
15
+ from hanzo_mcp.tools.todo.base import TodoStorage, TodoBaseTool
16
+
17
+ SessionId = Annotated[
18
+ str | int | float,
19
+ Field(description="Unique identifier for the Claude Desktop session (generate using timestamp command)"),
20
+ ]
21
+
22
+
23
+ class TodoReadToolParams(TypedDict):
24
+ """Parameters for the TodoReadTool.
25
+
26
+ Attributes:
27
+ session_id: Unique identifier for the Claude Desktop session (generate using timestamp command)
28
+ """
29
+
30
+ session_id: SessionId
31
+
32
+
33
+ @final
34
+ class TodoReadTool(TodoBaseTool):
35
+ """Tool for reading the current todo list for a session."""
36
+
37
+ @property
38
+ @override
39
+ def name(self) -> str:
40
+ """Get the tool name.
41
+
42
+ Returns:
43
+ Tool name
44
+ """
45
+ return "todo_read"
46
+
47
+ @property
48
+ @override
49
+ def description(self) -> str:
50
+ """Get the tool description.
51
+
52
+ Returns:
53
+ Tool description
54
+ """
55
+ return """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
56
+ the status of the current task list. You should make use of this tool as often as possible, especially in the following situations:
57
+ - At the beginning of conversations to see what's pending
58
+ - Before starting new tasks to prioritize work
59
+ - When the user asks about previous tasks or plans
60
+ - Whenever you're uncertain about what to do next
61
+ - After completing tasks to update your understanding of remaining work
62
+ - After every few messages to ensure you're on track
63
+
64
+ Usage:
65
+ - This tool requires a session_id parameter to identify the Claude Desktop conversation
66
+ - Returns a list of todo items with their status, priority, and content
67
+ - Use this information to track progress and plan next steps
68
+ - If no todos exist yet for the session, an empty list will be returned"""
69
+
70
+ @override
71
+ @auto_timeout("todo_read")
72
+
73
+
74
+ async def call(
75
+ self,
76
+ ctx: MCPContext,
77
+ **params: Unpack[TodoReadToolParams],
78
+ ) -> str:
79
+ """Execute the tool with the given parameters.
80
+
81
+ Args:
82
+ ctx: MCP context
83
+ **params: Tool parameters
84
+
85
+ Returns:
86
+ Tool result
87
+ """
88
+ tool_ctx = self.create_tool_context(ctx)
89
+ self.set_tool_context_info(tool_ctx)
90
+
91
+ # Extract parameters
92
+ session_id = params.get("session_id")
93
+
94
+ # Validate required parameters for direct calls (not through MCP framework)
95
+ if session_id is None:
96
+ await tool_ctx.error("Parameter 'session_id' is required but was None")
97
+ return "Error: Parameter 'session_id' is required but was None"
98
+
99
+ session_id = str(session_id)
100
+
101
+ # Validate session ID
102
+ is_valid, error_msg = self.validate_session_id(session_id)
103
+ if not is_valid:
104
+ await tool_ctx.error(f"Invalid session_id: {error_msg}")
105
+ return f"Error: Invalid session_id: {error_msg}"
106
+
107
+ await tool_ctx.info(f"Reading todos for session: {session_id}")
108
+
109
+ try:
110
+ # Get todos from storage
111
+ todos = TodoStorage.get_todos(session_id)
112
+
113
+ # Log status
114
+ if todos:
115
+ await tool_ctx.info(f"Found {len(todos)} todos for session {session_id}")
116
+ else:
117
+ await tool_ctx.info(f"No todos found for session {session_id} (returning empty list)")
118
+
119
+ # Return todos as JSON string
120
+ result = json.dumps(todos, indent=2)
121
+
122
+ return result
123
+
124
+ except Exception as e:
125
+ await tool_ctx.error(f"Error reading todos: {str(e)}")
126
+ return f"Error reading todos: {str(e)}"
127
+
128
+ @override
129
+ def register(self, mcp_server: FastMCP) -> None:
130
+ """Register this todo read tool with the MCP server.
131
+
132
+ Creates a wrapper function with explicitly defined parameters that match
133
+ the tool's parameter schema and registers it with the MCP server.
134
+
135
+ Args:
136
+ mcp_server: The FastMCP server instance
137
+ """
138
+ tool_self = self # Create a reference to self for use in the closure
139
+
140
+ @mcp_server.tool(name=self.name, description=self.description)
141
+ async def todo_read(session_id: SessionId, ctx: MCPContext) -> str:
142
+ return await tool_self.call(ctx, session_id=session_id)
@@ -0,0 +1,367 @@
1
+ """TodoWrite tool implementation.
2
+
3
+ This module provides the TodoWrite tool for creating and managing a structured task list for a session.
4
+ """
5
+
6
+ from typing import Unpack, Literal, Annotated, TypedDict, final, override
7
+
8
+ from pydantic import Field
9
+ from mcp.server import FastMCP
10
+
11
+ from hanzo_mcp.tools.common.auto_timeout import auto_timeout
12
+ from mcp.server.fastmcp import Context as MCPContext
13
+
14
+ from hanzo_mcp.tools.todo.base import TodoStorage, TodoBaseTool
15
+
16
+
17
+ class TodoItem(TypedDict):
18
+ """A single todo item."""
19
+
20
+ content: Annotated[
21
+ str,
22
+ Field(
23
+ description="Description of the task to be completed",
24
+ min_length=1,
25
+ ),
26
+ ]
27
+ status: Annotated[
28
+ Literal["pending", "in_progress", "completed"],
29
+ Field(description="Current status of the task"),
30
+ ]
31
+ priority: Annotated[
32
+ Literal["high", "medium", "low"],
33
+ Field(description="Priority level of the task"),
34
+ ]
35
+ id: Annotated[
36
+ str,
37
+ Field(description="Unique identifier for the task", min_length=3),
38
+ ]
39
+
40
+
41
+ SessionId = Annotated[
42
+ str | int | float,
43
+ Field(
44
+ description="Unique identifier for the Claude Desktop session (generate using timestamp command)",
45
+ ),
46
+ ]
47
+
48
+ Todos = Annotated[
49
+ list[TodoItem],
50
+ Field(
51
+ description="The complete todo list to store for this session",
52
+ min_length=1,
53
+ ),
54
+ ]
55
+
56
+
57
+ class TodoWriteToolParams(TypedDict):
58
+ """Parameters for the TodoWriteTool.
59
+
60
+ Attributes:
61
+ session_id: Unique identifier for the Claude Desktop session (generate using timestamp command)
62
+ todos: The complete todo list to store for this session
63
+ """
64
+
65
+ session_id: SessionId
66
+ todos: Todos
67
+
68
+
69
+ @final
70
+ class TodoWriteTool(TodoBaseTool):
71
+ """Tool for creating and managing a structured task list for a session."""
72
+
73
+ @property
74
+ @override
75
+ def name(self) -> str:
76
+ """Get the tool name.
77
+
78
+ Returns:
79
+ Tool name
80
+ """
81
+ return "todo_write"
82
+
83
+ @property
84
+ @override
85
+ def description(self) -> str:
86
+ """Get the tool description.
87
+
88
+ Returns:
89
+ Tool description
90
+ """
91
+ return """Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
92
+ It also helps the user understand the progress of the task and overall progress of their requests.
93
+
94
+ ## When to Use This Tool
95
+ Use this tool proactively in these scenarios:
96
+
97
+ 1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
98
+ 2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
99
+ 3. User explicitly requests todo list - When the user directly asks you to use the todo list
100
+ 4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
101
+ 5. After receiving new instructions - Immediately capture user requirements as todos. Feel free to edit the todo list based on new information.
102
+ 6. After completing a task - Mark it complete and add any new follow-up tasks
103
+ 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.
104
+
105
+ ## When NOT to Use This Tool
106
+
107
+ Skip using this tool when:
108
+ 1. There is only a single, straightforward task
109
+ 2. The task is trivial and tracking it provides no organizational benefit
110
+ 3. The task can be completed in less than 3 trivial steps
111
+ 4. The task is purely conversational or informational
112
+
113
+ NOTE that you should use 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.
114
+
115
+ ## Examples of When to Use the Todo List
116
+
117
+ <example>
118
+ 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!
119
+ Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
120
+ *Creates todo list with the following items:*
121
+ 1. Create dark mode toggle component in Settings page
122
+ 2. Add dark mode state management (context/store)
123
+ 3. Implement CSS-in-JS styles for dark theme
124
+ 4. Update existing components to support theme switching
125
+ 5. Run tests and build process, addressing any failures or errors that occur
126
+ *Begins working on the first task*
127
+
128
+ <reasoning>
129
+ The assistant used the todo list because:
130
+ 1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
131
+ 2. The user explicitly requested tests and build be run afterward
132
+ 3. The assistant inferred that tests and build need to pass by adding \"Ensure tests and build succeed\" as the final task
133
+ </reasoning>
134
+ </example>
135
+
136
+ <example>
137
+ User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
138
+ Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
139
+ *Uses grep or search tools to locate all instances of getCwd in the codebase*
140
+ Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
141
+ *Creates todo list with specific items for each file that needs updating*
142
+
143
+ <reasoning>
144
+ The assistant used the todo list because:
145
+ 1. First, the assistant searched to understand the scope of the task
146
+ 2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
147
+ 3. The todo list helps ensure every instance is tracked and updated systematically
148
+ 4. This approach prevents missing any occurrences and maintains code consistency
149
+ </reasoning>
150
+ </example>
151
+
152
+
153
+ <example>
154
+ User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
155
+ Assistant: I'll help implement these features. First, let's add all the features to the todo list.
156
+ *Creates a todo list breaking down each feature into specific tasks based on the project architecture*
157
+ 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.
158
+
159
+ <reasoning>
160
+ The assistant used the todo list because:
161
+ 1. The user provided multiple complex features to implement in a comma separated list
162
+ 2. The todo list helps organize these large features into manageable tasks
163
+ 3. This approach allows for tracking progress across the entire implementation
164
+ </reasoning>
165
+ </example>
166
+
167
+ <example>
168
+ User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
169
+ Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
170
+ *Reviews component structure, render patterns, state management, and data fetching*
171
+ Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
172
+ *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*
173
+ Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>
174
+
175
+ <reasoning>
176
+ The assistant used the todo list because:
177
+ 1. First, the assistant examined the codebase to identify specific performance issues
178
+ 2. Based on this analysis, it identified multiple optimization opportunities
179
+ 3. Performance optimization is a non-trivial task requiring multiple steps
180
+ 4. The todo list helps methodically track improvements across different components
181
+ 5. This systematic approach ensures all performance bottlenecks are addressed
182
+ </reasoning>
183
+ </example>
184
+
185
+ ## Examples of When NOT to Use the Todo List
186
+
187
+ <example>
188
+ User: How do I print 'Hello World' in Python?
189
+ Assistant: In Python, you can print \"Hello World\" with this simple code:
190
+
191
+ python
192
+ print(\"Hello World\")
193
+
194
+ This will output the text \"Hello World\" to the console when executed.</assistant>
195
+
196
+ <reasoning>
197
+ 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.
198
+ </reasoning>
199
+ </example>
200
+
201
+ <example>
202
+ User: What does the git status command do?
203
+ 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.
204
+
205
+ <reasoning>
206
+ The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
207
+ </reasoning>
208
+ </example>
209
+
210
+ <example>
211
+ User: Can you add a comment to the calculateTotal function to explain what it does?
212
+ Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
213
+ * Uses the Edit tool to add a comment to the calculateTotal function *
214
+
215
+ <reasoning>
216
+ 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.
217
+ </reasoning>
218
+ </example>
219
+
220
+ <example>
221
+ User: Run npm install for me and tell me what happens.
222
+ Assistant: I'll run the npm install command for you.
223
+
224
+ *Executes: npm install*
225
+
226
+ The command completed successfully. Here's the output:
227
+ [Output of npm install command]
228
+
229
+ All dependencies have been installed according to your package.json file.
230
+
231
+ <reasoning>
232
+ 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.
233
+ </reasoning>
234
+ </example>
235
+
236
+ ## Task States and Management
237
+
238
+ 1. **Task States**: Use these states to track progress:
239
+ - pending: Task not yet started
240
+ - in_progress: Currently working on (limit to ONE task at a time)
241
+ - completed: Task finished successfully
242
+ - cancelled: Task no longer needed
243
+
244
+ 2. **Task Management**:
245
+ - Update task status in real-time as you work
246
+ - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
247
+ - Only have ONE task in_progress at any time
248
+ - Complete current tasks before starting new ones
249
+ - Cancel tasks that become irrelevant
250
+
251
+ 3. **Task Breakdown**:
252
+ - Create specific, actionable items
253
+ - Break complex tasks into smaller, manageable steps
254
+ - Use clear, descriptive task names
255
+
256
+ When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully."""
257
+
258
+ @override
259
+ @auto_timeout("todo_write")
260
+
261
+
262
+ async def call(
263
+ self,
264
+ ctx: MCPContext,
265
+ **params: Unpack[TodoWriteToolParams],
266
+ ) -> str:
267
+ """Execute the tool with the given parameters.
268
+
269
+ Args:
270
+ ctx: MCP context
271
+ **params: Tool parameters
272
+
273
+ Returns:
274
+ Tool result
275
+ """
276
+ tool_ctx = self.create_tool_context(ctx)
277
+ self.set_tool_context_info(tool_ctx)
278
+
279
+ # Extract parameters
280
+ session_id = params.get("session_id")
281
+ todos = params.get("todos")
282
+
283
+ # Validate required parameters for direct calls (not through MCP framework)
284
+ if session_id is None:
285
+ await tool_ctx.error("Parameter 'session_id' is required but was None")
286
+ return "Error: Parameter 'session_id' is required but was None"
287
+
288
+ if todos is None:
289
+ await tool_ctx.error("Parameter 'todos' is required but was None")
290
+ return "Error: Parameter 'todos' is required but was None"
291
+
292
+ session_id = str(session_id)
293
+
294
+ # Validate session ID
295
+ is_valid, error_msg = self.validate_session_id(session_id)
296
+ if not is_valid:
297
+ await tool_ctx.error(f"Invalid session_id: {error_msg}")
298
+ return f"Error: Invalid session_id: {error_msg}"
299
+
300
+ # Normalize todos list (auto-generate missing fields)
301
+ todos = self.normalize_todos_list(todos)
302
+
303
+ # Validate todos list
304
+ is_valid, error_msg = self.validate_todos_list(todos)
305
+ if not is_valid:
306
+ await tool_ctx.error(f"Invalid todos: {error_msg}")
307
+ return f"Error: Invalid todos: {error_msg}"
308
+
309
+ await tool_ctx.info(f"Writing {len(todos)} todos for session: {session_id}")
310
+
311
+ try:
312
+ # Store todos in memory
313
+ TodoStorage.set_todos(session_id, todos)
314
+
315
+ # Log storage stats
316
+ session_count = TodoStorage.get_session_count()
317
+ await tool_ctx.info(f"Successfully stored todos. Total active sessions: {session_count}")
318
+
319
+ # Provide feedback about the todos
320
+ if todos:
321
+ status_counts = {}
322
+ priority_counts = {}
323
+
324
+ for todo in todos:
325
+ status = todo.get("status", "unknown")
326
+ priority = todo.get("priority", "unknown")
327
+
328
+ status_counts[status] = status_counts.get(status, 0) + 1
329
+ priority_counts[priority] = priority_counts.get(priority, 0) + 1
330
+
331
+ # Create summary
332
+ summary_parts = []
333
+ if status_counts:
334
+ status_summary = ", ".join([f"{count} {status}" for status, count in status_counts.items()])
335
+ summary_parts.append(f"Status: {status_summary}")
336
+
337
+ if priority_counts:
338
+ priority_summary = ", ".join([f"{count} {priority}" for priority, count in priority_counts.items()])
339
+ summary_parts.append(f"Priority: {priority_summary}")
340
+
341
+ summary = f"Successfully stored {len(todos)} todos for session {session_id}.\n" + "; ".join(
342
+ summary_parts
343
+ )
344
+
345
+ return summary
346
+ else:
347
+ return f"Successfully cleared todos for session {session_id} (stored empty list)."
348
+
349
+ except Exception as e:
350
+ await tool_ctx.error(f"Error storing todos: {str(e)}")
351
+ return f"Error storing todos: {str(e)}"
352
+
353
+ @override
354
+ def register(self, mcp_server: FastMCP) -> None:
355
+ """Register this todo write tool with the MCP server.
356
+
357
+ Creates a wrapper function with explicitly defined parameters that match
358
+ the tool's parameter schema and registers it with the MCP server.
359
+
360
+ Args:
361
+ mcp_server: The FastMCP server instance
362
+ """
363
+ tool_self = self # Create a reference to self for use in the closure
364
+
365
+ @mcp_server.tool(name=self.name, description=self.description)
366
+ async def todo_write(session_id: SessionId, todos: Todos, ctx: MCPContext) -> str:
367
+ return await tool_self.call(ctx, session_id=session_id, todos=todos)