Skip to content

Research unified tool registration approach for MCP and REST API #143

Description

@coderabbitai

Background

Currently, adding a new tool to the MCP server requires registration in two separate places:

  1. blockscout_mcp_server/server.py - MCP tool registration with mcp.tool()
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions