feat(tools): add codebase_search and github_codebase_search tools#2474
Open
DhruvBhatia0 wants to merge 3 commits intoOpenHands:mainfrom
Open
feat(tools): add codebase_search and github_codebase_search tools#2474DhruvBhatia0 wants to merge 3 commits intoOpenHands:mainfrom
DhruvBhatia0 wants to merge 3 commits intoOpenHands:mainfrom
Conversation
Register Morph's WarpGrep as native OpenHands tools backed by the @morphllm/morphmcp MCP server. Users add Tool(name="codebase_search") to their agent like any other tool — the MCP plumbing is internal. - Two separate tool registrations sharing one MCP server process - edit_file from the MCP server is filtered out (FileEditorTool exists) - Clear ValueError with dashboard link when MORPH_API_KEY is missing - Pre-install @morphllm/morphmcp in Docker image for fast cold starts - README section + example at examples/01_standalone_sdk/45_codebase_search.py Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Thanks for the PR. Why a tool wrapping an mcp? Can we not just use the mcp directly? |
- Fix resolver signatures to match registry calling convention (conv_state=, **params) instead of (params: dict, conv_state: object) - Fix race condition: hold lock for entire MCP server start in _get_morph_search_tools - Add atexit handler to close cached MCP clients on process exit - Use (api_key, api_url, timeout_ms) tuple as cache key instead of just api_key - Add TYPE_CHECKING import for ConversationState - Use lazy %s logger formatting instead of f-string - Add docstring note explaining callable resolver pattern - Exclude 45_codebase_search.py from CI example tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
ah good point, i can make this change, |
Replace the MCP-based approach (which wrapped @morphllm/morphmcp) with direct calls to @morphllm/morphsdk via a Node.js bridge script. - Native ToolDefinition subclasses with proper Action/Observation schemas - bridge.js calls WarpGrepClient.execute() and searchGitHub() directly - No more MCP server process, shared client cache, or atexit cleanup - Clear error messages for missing Node.js, missing SDK, missing API key - Dockerfile installs @morphllm/morphsdk instead of @morphllm/morphmcp Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
If this is just an MCP server, which we already support, why do we need a new tool instead of using the MCP directly (i.e., passing it to the agent)? Moreover, we already have tools that allow the agent to explore the codebase. Why would this tool be better? Is there a related issue for this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@morphllm/morphmcpMCP serverTool(name="codebase_search")to their agent like any other tool — MCP plumbing is internalcodebase_search+github_codebase_search) sharing one MCP server processedit_filefrom the MCP server is filtered out to avoid conflict withFileEditorToolValueErrorwith dashboard link whenMORPH_API_KEYis missing@morphllm/morphmcpin Docker image for fast cold startsUsage
Requires
MORPH_API_KEYenv var (or passed viaTool(name="codebase_search", params={"api_key": "sk-..."})) and Node.js 18+.Test plan
list_registered_tools()MORPH_API_KEYraisesValueErrorwith instructions + dashboard linkfrom openhands.tools import register_codebase_search_toolsworksMORPH_API_KEYset against a real repo@morphllm/morphmcppre-installed🤖 Generated with Claude Code