forked from cardosofelipe/fast-next-template
feat(backend): Implement MCP Client Infrastructure #55
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Create the core MCP client infrastructure that enables the backend to communicate with all MCP servers. This is the foundation for all Phase 2 MCP integrations.
Sub-Tasks
1. Project Setup
backend/app/services/mcp/directory structurepyproject.toml(mcp>=1.0.0)httpxfor HTTP transport__init__.pywith public exports2. Configuration System
backend/app/core/config/mcp_servers.yamlschemaMCPServerConfig)backend/app/core/config.py3. Server Registry (
registry.py)MCPServerRegistryclassregister(name, config)methodget(name)method with KeyError handlinglist_servers()methodget_capabilities(name)method (lazy-loaded)4. Connection Management (
connection.py)MCPConnectionclass wrapping MCP client5. MCPClientManager (
client_manager.py)MCPClientManagerclass as main facadeasync def connect(server_name: str) -> MCPClientasync def disconnect(server_name: str) -> Noneasync def disconnect_all() -> Noneasync def call_tool(server: str, tool: str, args: dict) -> ToolResultasync def list_tools(server: str) -> list[ToolInfo]async def health_check() -> dict[str, ServerHealth]get_mcp_client()dependency function6. Tool Call Routing (
routing.py)ToolRouterclass7. Error Handling (
exceptions.py)MCPErrorbase exceptionMCPConnectionErrorfor connection failuresMCPToolErrorfor tool execution failuresMCPTimeoutErrorfor timeoutsMCPServerNotFoundErrorfor unknown servers8. Logging & Observability
/api/v1/mcp/health9. API Endpoints (
api/routes/mcp.py)GET /api/v1/mcp/servers- list registered serversGET /api/v1/mcp/servers/{name}/tools- list server toolsGET /api/v1/mcp/health- health check all serversPOST /api/v1/mcp/call- direct tool call (admin only)10. Testing
tests/services/mcp/test_registry.pytests/services/mcp/test_connection.pytests/services/mcp/test_client_manager.pytests/services/mcp/test_routing.py11. Documentation
backend/docs/MCP_CLIENT.mdwith usage examplesTechnical Specifications
MCPClientManager Interface
Configuration Schema
Acceptance Criteria
Dependencies
Assignable To
backend-engineer agent