Skip to content

Conversation

ezyang
Copy link
Owner

@ezyang ezyang commented May 4, 2025

Stack from ghstack (oldest at bottom):

In codemcp/multi_entry.py there is a POC for how to have each of the SubTools as a dedicated top level MCP tool. Let's change codemcp/main.py so we apply this for all subtools.
We must worry about BC for the codemcp function in codemcp/main.py. We will remove the @mcp.tool decorator but leave the function so tests don't break (we will refactor the tests later.) Let's annotate @mcp.tool in each codemcp/tools/ file individually. In codemcp/tools/init_project.py there is a system_prompt which documents the tools. These should be moved into the docstring of each mcp.tool declaration. The non-tool system prompt should continue to emitted from InitProject tool.

65a2e52  (Base revision)
6ebb292  Add get_chat_id_from_context helper function
1d46ff5  Add Context import from mcp.server.fastmcp
7a84952  Remove @mcp.tool decorator but keep function for backward compatibility
804c644  Add imports for Context, mcp, and get_chat_id_from_context
a6bcd81  Add read_file to __all__
d15b9c9  Add read_file top-level MCP tool
f522500  Update imports and __all__ in write_file.py
7776dc8  Add write_file top-level MCP tool
f410f72  Update imports and __all__ in edit_file.py
cd5539c  Add edit_file top-level MCP tool
9e4d755  Update imports and __all__ in ls.py
5453bbe  Add ls top-level MCP tool
7749c32  Update imports and __all__ in user_prompt.py
187fd92  Add record_user_prompt top-level MCP tool
c434dd7  Update imports and __all__ in init_project.py
48ded01  Remove tool documentation from system_prompt since it's now in docstrings
84ffd44  Add initialize_project top-level MCP tool
4806639  Update imports and __all__ in think.py
8bc128b  Add think_tool top-level MCP tool
2de5b3e  Update imports and __all__ in grep.py
fafd43c  Add grep top-level MCP tool
eea2b5b  Update imports and __all__ in glob.py
be20f9d  Add glob_tool top-level MCP tool
00ae84a  Update imports and __all__ in chmod.py
05cfef6  Add chmod_tool top-level MCP tool
e3e2e9c  Update imports and __all__ in run_command.py
8c34db2  Add run_command_tool top-level MCP tool
b498258  Update imports and __all__ in rm.py
2e450af  Add rm_tool top-level MCP tool
1219e18  Update imports and __all__ in mv.py
5814b30  Add mv_tool top-level MCP tool
f8f4783  Update imports and __all__ in git_log.py
a8483a0  Add git_log_tool top-level MCP tool
21dc859  Update imports and __all__ in git_diff.py
83a09c6  Add git_diff_tool top-level MCP tool
e92b032  Update imports and __all__ in git_show.py
bb57af2  Add git_show_tool top-level MCP tool
6e7b6bf  Update imports and __all__ in git_blame.py
20eb2a5  Add git_blame_tool top-level MCP tool
HEAD     Auto-commit lint changes

codemcp-id: 292-refactor-make-each-subtool-a-top-level-mcp-tool

[ghstack-poisoned]
ezyang added a commit that referenced this pull request May 4, 2025
In codemcp/multi_entry.py there is a POC for how to have each of the SubTools as a dedicated top level MCP tool. Let's change codemcp/main.py so we apply this for all subtools.
We must worry about BC for the codemcp function in codemcp/main.py. We will remove the mcp.tool decorator but leave the function so tests don't break (we will refactor the tests later.) Let's annotate mcp.tool in each codemcp/tools/ file individually. In codemcp/tools/init_project.py there is a system_prompt which documents the tools. These should be moved into the docstring of each mcp.tool declaration. The non-tool system prompt should continue to emitted from InitProject tool.

```git-revs
65a2e52  (Base revision)
6ebb292  Add get_chat_id_from_context helper function
1d46ff5  Add Context import from mcp.server.fastmcp
7a84952  Remove mcp.tool decorator but keep function for backward compatibility
804c644  Add imports for Context, mcp, and get_chat_id_from_context
a6bcd81  Add read_file to __all__
d15b9c9  Add read_file top-level MCP tool
f522500  Update imports and __all__ in write_file.py
7776dc8  Add write_file top-level MCP tool
f410f72  Update imports and __all__ in edit_file.py
cd5539c  Add edit_file top-level MCP tool
9e4d755  Update imports and __all__ in ls.py
5453bbe  Add ls top-level MCP tool
7749c32  Update imports and __all__ in user_prompt.py
187fd92  Add record_user_prompt top-level MCP tool
c434dd7  Update imports and __all__ in init_project.py
48ded01  Remove tool documentation from system_prompt since it's now in docstrings
84ffd44  Add initialize_project top-level MCP tool
4806639  Update imports and __all__ in think.py
8bc128b  Add think_tool top-level MCP tool
2de5b3e  Update imports and __all__ in grep.py
fafd43c  Add grep top-level MCP tool
eea2b5b  Update imports and __all__ in glob.py
be20f9d  Add glob_tool top-level MCP tool
00ae84a  Update imports and __all__ in chmod.py
05cfef6  Add chmod_tool top-level MCP tool
e3e2e9c  Update imports and __all__ in run_command.py
8c34db2  Add run_command_tool top-level MCP tool
b498258  Update imports and __all__ in rm.py
2e450af  Add rm_tool top-level MCP tool
1219e18  Update imports and __all__ in mv.py
5814b30  Add mv_tool top-level MCP tool
f8f4783  Update imports and __all__ in git_log.py
a8483a0  Add git_log_tool top-level MCP tool
21dc859  Update imports and __all__ in git_diff.py
83a09c6  Add git_diff_tool top-level MCP tool
e92b032  Update imports and __all__ in git_show.py
bb57af2  Add git_show_tool top-level MCP tool
6e7b6bf  Update imports and __all__ in git_blame.py
20eb2a5  Add git_blame_tool top-level MCP tool
HEAD     Auto-commit lint changes
```

codemcp-id: 292-refactor-make-each-subtool-a-top-level-mcp-tool
ghstack-source-id: 91a150c
Pull-Request-resolved: #286
@ezyang ezyang mentioned this pull request May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant