Skip to content

feat: multi-repo MCP with global registry (Phase 2.5)#16

Merged
carlos-alm merged 1 commit intomainfrom
feat/multi-repo-mcp
Feb 22, 2026
Merged

feat: multi-repo MCP with global registry (Phase 2.5)#16
carlos-alm merged 1 commit intomainfrom
feat/multi-repo-mcp

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Add global registry at ~/.codegraph/registry.json so AI agents can query multiple codebases from one MCP session
  • New src/registry.js module with atomic-write CRUD operations (load/save/register/unregister/list/resolve)
  • Add optional repo param to all 11 existing MCP tools + new list_repos tool (12th)
  • Add codegraph registry list|add|remove CLI commands
  • Auto-register projects after codegraph build (non-fatal on failure)
  • Export all registry functions from programmatic API (src/index.js)
  • 26 new tests (18 registry unit, 4 MCP unit, 4 CLI integration)
  • Update ROADMAP.md and README.md to mark Phase 2.5 complete

Test plan

  • npx vitest run tests/unit/registry.test.js — 18 tests pass
  • npx vitest run tests/unit/mcp.test.js — 22 tests pass (4 new)
  • npx vitest run tests/integration/cli.test.js — 18 tests pass (4 new)
  • npm test — full suite 322 tests pass
  • npm run lint — clean

🤖 Generated with Claude Code

Add a global registry at ~/.codegraph/registry.json so AI agents can
query multiple codebases from a single MCP session. Projects are
auto-registered on build; an optional `repo` param on every MCP tool
lets agents switch context.

- New src/registry.js with CRUD operations (load/save/register/
  unregister/list/resolve) and atomic writes
- Add optional `repo` param to all 11 existing MCP tools
- Add 12th MCP tool `list_repos` to enumerate registered repos
- Add `codegraph registry list|add|remove` CLI commands
- Auto-register projects after `codegraph build` (non-fatal)
- Export registry functions from programmatic API
- 18 unit tests for registry, 4 new MCP tests, 4 CLI integration tests
- Update ROADMAP.md and README.md to mark Phase 2.5 complete
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 22, 2026

Greptile Summary

This PR implements Phase 2.5 of the roadmap, adding multi-repo support to the MCP server via a global registry at ~/.codegraph/registry.json.

Key Changes

  • New src/registry.js module with atomic-write CRUD operations (load, save, register, unregister, list, resolve)
  • Optional repo parameter added to all 11 existing MCP tools to target registered repositories
  • New list_repos MCP tool (12th tool) to enumerate registered repositories
  • CLI commands codegraph registry list|add|remove for manual registry management
  • Auto-registration after codegraph build (non-fatal on failure)
  • Programmatic API exports all registry functions from src/index.js
  • Comprehensive test coverage with 26 new tests (18 registry unit, 4 MCP unit, 4 CLI integration)

Implementation Quality

The implementation follows established patterns in the codebase:

  • Atomic writes using temp file + rename to prevent corruption
  • Graceful error handling with appropriate fallbacks
  • Backward compatibility (omitting repo param uses local DB)
  • Proper isolation in tests (temp directories, mocked HOME)
  • Consistent with CLAUDE.md architecture documentation

All tests reported passing in the PR description (322 total). The code is clean, well-structured, and ready for production use.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects thorough implementation with comprehensive test coverage (26 new tests), atomic file operations, graceful error handling, backward compatibility, and alignment with project architecture. No logic errors, security issues, or breaking changes identified.
  • No files require special attention

Important Files Changed

Filename Overview
src/registry.js New module for global repo registry with atomic writes, CRUD operations, and graceful error handling
src/mcp.js Added optional repo param to all 11 tools + new list_repos tool with proper registry resolution
src/cli.js Added `registry list
src/builder.js Added non-fatal auto-registration after successful build with debug logging on failure
tests/unit/registry.test.js Comprehensive 18-test suite covering all registry CRUD operations, edge cases, and error handling
tests/unit/mcp.test.js Added 4 tests for repo param validation, registry resolution, and error handling

Sequence Diagram

sequenceDiagram
    participant AI as AI Agent
    participant MCP as MCP Server
    participant REG as Registry Module
    participant FS as File System
    participant DB as SQLite DBs

    Note over AI,DB: Multi-Repo Query Flow

    AI->>MCP: list_repos()
    MCP->>REG: listRepos()
    REG->>FS: Read ~/.codegraph/registry.json
    FS-->>REG: Registry data
    REG-->>MCP: List of repos
    MCP-->>AI: Available repositories

    AI->>MCP: query_function(name, repo="my-project")
    MCP->>REG: resolveRepoDbPath("my-project")
    REG->>FS: Check registry.json
    REG->>FS: Verify DB exists
    alt DB found
        FS-->>REG: DB path
        REG-->>MCP: Resolved path
        MCP->>DB: Query my-project DB
        DB-->>MCP: Results
        MCP-->>AI: Function data
    else DB not found
        REG-->>MCP: undefined
        MCP-->>AI: Error: repo not found
    end

    Note over AI,DB: Auto-Registration on Build

    participant CLI as CLI
    participant BLD as Builder

    CLI->>BLD: codegraph build
    BLD->>FS: Build graph.db
    BLD->>REG: registerRepo(rootDir)
    REG->>FS: Atomic write to registry.json
    REG-->>BLD: Registration complete
    BLD-->>CLI: Build complete
Loading

Last reviewed commit: 54ea9f6

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@carlos-alm carlos-alm merged commit 43a79ee into main Feb 22, 2026
14 checks passed
@carlos-alm carlos-alm deleted the feat/multi-repo-mcp branch February 22, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant