Skip to content

Refactor: add composition roots (api/container.py, mcp/container.py, cli/container.py) #492

@phernandez

Description

@phernandez

Refactor: add composition roots (api/container.py, mcp/container.py, cli/container.py)

Why

Basic Memory has three entrypoints (API / MCP / CLI). Today, composition and runtime concerns (cloud/local/test, auth, transports) leak deep into modules. Composition roots make wiring explicit and reduce coupling.

Scope

  • Add containers:
    • basic_memory/api/container.py
    • basic_memory/mcp/container.py
    • basic_memory/cli/container.py
  • Containers own:
    • reading ConfigManager + environment variables
    • selecting runtime mode (cloud/local/test)
    • providing factories (httpx clients, repositories, services)

Acceptance criteria

  • Entrypoints (API/MCP/CLI) call their container builders.
  • Downstream modules no longer read ConfigManager directly for runtime selection.
  • Tests pass.

Dependencies

  • Foundational: enables the other refactors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions