Skip to content

feat(mcp): Bidirectional MCP Client Adapter (Dynamic Tool Discovery) #11

Description

@sdageltc

Summary & Motivation

letitloop currently includes a built-in MCP server (orchestrator/mcp_server.py), allowing external AI assistants (like Claude Desktop, Antigravity, Cursor, and Windsurf) to control letitloop as a macro-task engine.

The next evolution is Bidirectional MCP Support: enabling letitloop contracts to act as MCP clients that dynamically discover, mount, and execute tools provided by external MCP servers (e.g., PostgreSQL MCP, GitHub MCP, Puppeteer Browser MCP, Slack MCP).


Proposed Architecture

  1. MCPClientManager (orchestrator/mcp_client.py):
    • Manages stdio and SSE transport connections to external MCP servers declared in a .letitloop/mcp.json config.
    • Discovers available tools (tools/list) and translates them into tool definitions for worker adapters.
  2. Contract Tool Binding:
    • Contracts can specify required_mcp_servers: ["postgres", "github"] in their contract metadata.
    • The worker adapter receives access only to the tools exposed by declared servers.

Acceptance Criteria

  • Can connect to standard stdio MCP servers using JSON-RPC 2.0.
  • Passes discovered MCP tools to worker adapters.
  • Isolates MCP server processes and terminates them cleanly on task completion.
  • Tested with mock MCP servers in tests/test_mcp_client.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureCore control loop and system architectureenhancementNew feature or requesthelp wantedExtra attention is neededintegrationsWorker adapters, LLM providers, and external tools

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions