Skip to content

Refactor: introduce ProjectResolver and unify project selection across MCP/API/CLI #493

Description

@phernandez

Refactor: introduce ProjectResolver and unify project selection across MCP/API/CLI

Why

Project resolution logic is scattered (default project, constrained env project, explicit parameters, discovery mode). This leads to inconsistent behavior and duplicated logic.

Scope

  • Create a single reusable ProjectResolver (pure logic / small class) that:
    • resolves the effective project given requested project + env constraints + config
    • supports discovery mode (optional)
    • returns a typed result (mode + project name/id + reason)
  • Use it in:
    • MCP project resolution (basic_memory/mcp/project_context.py and MCP tools)
    • API project routing (where applicable)
    • CLI commands that infer default project

Acceptance criteria

  • One canonical implementation of project resolution (no duplicated decision trees).
  • Existing behavior preserved (or changes explicitly documented).
  • MCP tool behavior remains fully covered.

Dependencies

  • Ideally after containers/config injection work, so resolver is used via injected config.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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