Background
Currently, adding a new tool to the MCP server requires registration in two separate places:
blockscout_mcp_server/server.py - MCP tool registration with mcp.tool()
blockscout_mcp_server/api/routes.py - REST API wrapper creation and route registration
This creates a 3-step process (MCP registration + REST wrapper creation + route registration) with significant maintenance burden and potential for inconsistency.
Proposed Approach
A unified registration function that handles both registrations:
register_unified_tool(mcp, tool_function, endpoint, tool_function_rest)
This would:
- Register the MCP tool with
mcp.tool(structured_output=False)(tool_function)
- Register the REST route with
_add_v1_tool_route(mcp, endpoint, tool_function_rest)
Research Needed
The current approach may not be ideal and requires further investigation:
- Analyze potential architectural improvements
- Consider edge cases and flexibility requirements
- Evaluate impact on existing codebase
- Design optimal API for unified registration
- Consider testing implications
- Review maintainability and developer experience
Related Discussion
Background
Currently, adding a new tool to the MCP server requires registration in two separate places:
blockscout_mcp_server/server.py- MCP tool registration withmcp.tool()blockscout_mcp_server/api/routes.py- REST API wrapper creation and route registrationThis creates a 3-step process (MCP registration + REST wrapper creation + route registration) with significant maintenance burden and potential for inconsistency.
Proposed Approach
A unified registration function that handles both registrations:
This would:
mcp.tool(structured_output=False)(tool_function)_add_v1_tool_route(mcp, endpoint, tool_function_rest)Research Needed
The current approach may not be ideal and requires further investigation:
Related Discussion