feat: Add MCP Toolsmith agent template for intelligent MCP server discovery#6064
Open
Samir-atra wants to merge 1 commit intoaden-hive:mainfrom
Open
feat: Add MCP Toolsmith agent template for intelligent MCP server discovery#6064Samir-atra wants to merge 1 commit intoaden-hive:mainfrom
Samir-atra wants to merge 1 commit intoaden-hive:mainfrom
Conversation
…covery (aden-hive#4527) Implements a 9-node, 13-edge agent template that: - Scans projects to detect languages, frameworks, databases, and integrations - Discovers relevant MCP servers from the MCP Registry and web - Evaluates candidates by reading documentation and assessing maturity - Presents recommendations with tradeoffs for user approval (HITL) - Collects missing credentials securely via CredentialStore - Installs and configures approved servers, writing mcp_servers.json - Validates all connections end-to-end using MCPClient - Self-heals with max_node_visits=3 feedback loop for failed servers - Generates comprehensive reports with next steps Key features: - Bundled tools (read_file, write_file, web_search, validate_mcp_server, etc.) work without any MCP servers installed (bootstrapping problem solved) - 3 client-facing nodes for human interaction - Conditional routing based on credentials_needed and approval_status - Feedback loop from diagnose_fix -> validate_connections for self-healing - On_failure edges for graceful error handling This template demonstrates advanced framework patterns including: - Event loop nodes with client_facing=True - Conditional edge routing with condition_expr - max_node_visits for self-healing loops - Bundled tool execution without MCP dependencies - Credential integration with {{cred.key}} template resolution
PR Requirements WarningThis PR does not meet the contribution requirements. PR Author: @Samir-atra To fix:
Exception: To bypass this requirement, you can:
Micro-fix requirements (must meet ALL):
Why is this required? See #472 for details. |
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.
Description
Implements the MCP Toolsmith agent template for intelligent MCP server discovery, installation, and configuration as specified in issue #4527.
This agent analyzes software projects, discovers relevant MCP servers from the MCP Registry, evaluates candidates by reading documentation, generates correct configuration, collects credentials with human guidance, installs servers with explicit approval, validates connections end-to-end, and self-heals when something breaks.
Type of Change
Related Issues
Resolves #4527
Changes Made
Core Implementation
9-Node Graph with 13 Edges
project_scanner- Scans project files, detects stackdiscover_servers- Queries MCP Registry API and web searchevaluate_candidates- Reads READMEs, generates config templatesapproval_gate- Presents recommendations, HITL approval checkpointcollect_credentials- Collects missing credentials from userinstall_configure- Installs servers, writes mcp_servers.jsonvalidate_connections- Tests each server connectiondiagnose_fix- Self-healing feedback loop (max 3 retries)report_results- Final summary generationBundled Tools (8 tools)
read_file- Read project fileswrite_file- Write configuration fileslist_directory- List directory contentsexecute_command- Run shell commands (restricted allowlist)web_search- Search the web for MCP serversfetch_url- Fetch URLs for documentationstore_credential- Store credentials securelyvalidate_mcp_server- Test MCP server connectionsAdvanced Patterns Demonstrated
max_node_visits=3for self-healingcredentials_neededandapproval_statusclient_facing=True)Files Created
Edge Flow
Main Path:
Conditional Routing:
approval_gate → collect_credentials(if credentials needed)approval_gate → install_configure(if no credentials needed)approval_gate → report_results(if user rejected)Self-Healing Loop:
Testing
Unit Tests
All 15 structural tests pass:
cd /path/to/hive_fork uv run pytest examples/templates/mcp_toolsmith/tests/test_toolsmith.py -vTest Coverage:
diagnose_fixhasmax_node_visits=3project_scannerdiagnose_fixtovalidate_connectionsproject_scannerTest Results:
Lint Check
cd core uv run ruff check ../examples/templates/mcp_toolsmith/Only minor line length warnings in description strings (acceptable).
Manual Testing Performed
agent.validate()returns validagent.info()returns correct structureChecklist
Key Features
1. Solves the Bootstrapping Problem
The agent includes 8 bundled tools that work without any MCP servers configured. This allows it to:
2. Human-in-the-Loop (HITL) Design
Three nodes are marked
client_facing=True:3. Self-Healing Feedback Loop
When validation fails:
diagnose_fixanalyzes the error4. Security First
5. Demonstrates Framework Patterns
This template serves as a reference implementation for:
condition_expr{{cred.key}}template resolutionExample Usage
Architecture Diagram
Documentation
The
README.mdincludes:Performance Characteristics
Backward Compatibility
This change is fully backward compatible:
Future Enhancements
Potential improvements for future PRs:
Credits
Screenshots
N/A - This is a backend agent template with no UI changes.
Note to Reviewers:
This implementation demonstrates several advanced patterns that could serve as templates for future agent development:
Please pay special attention to the node system prompts in
nodes/__init__.pyas they contain detailed instructions for the LLM on how to execute each step.