Skip to content

MemPalace MCP sidecar integration — wire palace tools into Legion sessions #28

Description

@Esity

Summary

MemPalace (96.6% R@5 recall, MIT, no API key required) can run as an MCP sidecar alongside Legion, giving Legion agents access to verbatim drawer storage, temporal knowledge graph, agent diaries, and BM25 hybrid search — all without changes to Legion core. This issue tracks the integration wiring.

What MemPalace Provides via MCP (29 tools)

Read:

  • mempalace_status — palace overview, drawer counts, AAAK dialect spec
  • mempalace_search — hybrid semantic+BM25 search, optional wing/room filter
  • mempalace_list_wings / mempalace_list_rooms / mempalace_get_taxonomy
  • mempalace_kg_query — temporal KG query (entity facts with as_of support)
  • mempalace_kg_traverse — walk entity relationships
  • tool_diary_read — read agent diary chronologically

Write:

  • mempalace_add_drawer — file verbatim content into a wing/room
  • mempalace_delete_drawer — remove by ID
  • tool_diary_write — append to agent diary

Maintenance:

  • mempalace_reconnect — force cache invalidation after external writes

Current Blockers

  1. ChromaDB is local-only — works for single-node/dev workstations, not clustered Legion deployments. MemPalace v4 PostgreSQL backend (#665 in their repo) resolves this.
  2. No RBAC/PHI classification — raw content goes to ~/.mempalace, no Vault integration. Not suitable for Optum/UHC PHI data as-is.
  3. Python dependency — MemPalace is a Python package; Legion is Ruby. MCP stdio transport bridges this cleanly but adds a process dependency.

Integration Steps (Dev/Local Only Until v4 Postgres Backend)

# 1. Install
pip install mempalace

# 2. Initialize a palace for Legion
mempalace init ~/.mempalace/legion-palace

# 3. Mine existing project context (optional)
mempalace mine /path/to/legion/codebase

# 4. Add to Legion's MCP config
{
  "name": "mempalace",
  "command": "mempalace-mcp",
  "args": ["--palace", "~/.mempalace/legion-palace"],
  "transport": "stdio"
}

What to Validate

  • Confirm MCP stdio transport works with Legion's MCP client
  • Confirm mempalace_status wake-up call latency (<100ms target)
  • Test mempalace_search alongside Apollo.query for the same query — compare result quality
  • Test mempalace_add_drawer from within a Legion session
  • Evaluate whether dual-write (Apollo + MemPalace) is practical or creates divergence

Long-term Path

Once MemPalace's PostgreSQL backend lands (v4), evaluate:

  • Pointing MemPalace at Legion's existing Postgres instance
  • Using MemPalace as the verbatim layer and Apollo as the governed index layer
  • Replacing the MCP sidecar with a native Legion absorber that writes to both stores

References

Metadata

Metadata

Assignees

No one assigned

    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