Skip to content

Conversation

dylanbowman314
Copy link
Contributor

@dylanbowman314 dylanbowman314 commented Sep 30, 2025

Note

Adds hud init --from-mcp to scaffold a controller/environment template from an external MCP server and auto-generate tool stubs, plus introduces the from_mcp_template environment.

  • CLI:
    • hud init now supports --from-mcp <URL> to scaffold from an external MCP server.
    • Updates flow to fetch tools via MCP, then generate controller tool stubs; adjusts create_environment(...) to accept from_mcp and choose template/branch accordingly.
  • Scaffolding/Template:
    • Adds environments/from_mcp_template/ with Dockerfile, 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.
  • Codegen:
    • New utilities in hud/cli/init.py: _generate_tool_stubs(...) and analyze_external_mcp_server(...) to derive function signatures from tool schemas and append stubs to controller/tools.py.
  • Docs/UX:
    • Readmes for controller and template with usage/testing guidance; updated 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.

@dylanbowman314
Copy link
Contributor Author

Can test with hud init --from-mcp https://mcp.deepwiki.com/mcp. Not sure if we want to add any nice handling to try multiple paths (e.g. /, /mcp, /sse) to make the cli more accommodating here?

preset_normalized = "from-mcp"
env_folder = "from_mcp_template"
branch = "from-mcp-init"
else:
Copy link

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.

Fix in Cursor Fix in Web

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}")
Copy link

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.

Fix in Cursor Fix in Web

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:
Copy link

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.

Fix in Cursor Fix in Web

@mcp.tool
async def {tool.name}({params_str}) -> str:
"""{tool.description}"""
raise NotImplementedError("TODO: Implement {tool.name}")
Copy link
Contributor Author

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

Copy link
Contributor

promptless bot commented Sep 30, 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