-
Notifications
You must be signed in to change notification settings - Fork 36
Draft: --from-mcp in hud init #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Can test with |
preset_normalized = "from-mcp" | ||
env_folder = "from_mcp_template" | ||
branch = "from-mcp-init" | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: MCP URL Handling and Branch Configuration Errors
The --from-mcp
flag introduces two issues during environment creation. Providing an empty string for the MCP URL causes a runtime error when attempting to connect to an invalid server. Additionally, the template download uses a hardcoded from-mcp-init
branch, which may not exist and causes download failures.
else: | ||
hud_console.warning(f"tools.py not found at {tools_file}") | ||
except Exception as e: | ||
hud_console.warning(f"Could not fetch tools: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: MCP Fetch Delays Environment Initialization
When initializing an environment with --from-mcp
, MCP server analysis and tool stub generation occur after the "Next steps" and success messages. This creates a confusing user experience and can leave the environment partially initialized without tool stubs if the MCP fetch fails, without clearly indicating the incomplete state.
env_folder = PRESET_MAP[preset_normalized] | ||
if env_folder is None: | ||
# Validate env_folder (already set above based on from_mcp flag) | ||
if not from_mcp and env_folder is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Empty String Handling Causes Validation Mismatch
The validation if not from_mcp and env_folder is None:
is logically inconsistent. When from_mcp
is an empty string, env_folder
is set based on from_mcp
, but not from_mcp
evaluates to True
, creating a mismatch with the earlier branching logic. This could lead to env_folder
not being validated as intended.
@mcp.tool | ||
async def {tool.name}({params_str}) -> str: | ||
"""{tool.description}""" | ||
raise NotImplementedError("TODO: Implement {tool.name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could make this nicer, if we want to return an MCPToolResult or something that just contains a NotImplemented message
📝 Documentation updates detected! New suggestion: Add documentation for hud init --from-mcp feature |
Note
Adds
hud init --from-mcp
to scaffold a controller/environment template from an external MCP server and auto-generate tool stubs, plus introduces thefrom_mcp_template
environment.hud init
now supports--from-mcp <URL>
to scaffold from an external MCP server.create_environment(...)
to acceptfrom_mcp
and choose template/branch accordingly.environments/from_mcp_template/
withDockerfile
,pyproject.toml
, controller package (controller/__init__.py
,__main__.py
,tools.py
), example.env.example
,tasks.json
,test_env.ipynb
,test_task.py
, and README instructions.hud/cli/init.py
:_generate_tool_stubs(...)
andanalyze_external_mcp_server(...)
to derive function signatures from tool schemas and append stubs tocontroller/tools.py
.hud/cli/__init__.py
init
help/examples to mention--from-mcp
.Written by Cursor Bugbot for commit 5d7de36. This will update automatically on new commits. Configure here.