Skip to content

chore: Cherry-picked stale-MCP fix from upstream (abhigyanpatwari/GitNexus#297) #6

Description

@100yenadmin

Summary

Cherry-picked commit d4d0132 (fix(mcp): detect stale DB after re-indexing and reconnect) from upstream abhigyanpatwari/GitNexus into our fork's main branch.

Upstream PR: abhigyanpatwari#297
Upstream commit: abhigyanpatwari/GitNexus@d4d0132
Applied as: 38a4f90 on this fork's main

What the fix does

ensureInitialized() now reads meta.json on each tool call to compare indexedAt against the stored loadedAt timestamp. When gitnexus analyze rebuilds the index, the next query closes the stale LadybugDB pool entry and re-opens a fresh connection automatically.

Files changed:

  • src/mcp/local/local-backend.ts — staleness detection logic
  • test/integration/augmentation.test.ts — mock loadMeta
  • test/integration/local-backend-calltool.test.ts — mock loadMeta
  • test/unit/calltool-dispatch.test.ts — mock loadMeta

Why this matters for evaOS

After running gitnexus analyze to re-index a repo, the MCP server was serving stale results from the old DB connection until the process was restarted. This fix auto-reconnects on the next tool call.

Notes

The cherry-pick applied cleanly via path remapping (upstream uses a gitnexus/ prefix subdirectory, our fork has files at root). No conflicts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions