fix: honour --palace flag in mcp_server - #264
Conversation
PR Review: fix: honour --palace flag in mcp_serverExecutive Summary
Affected Areas: Business Impact: Users passing Flow Changes: Module init order changes from Ratings
PR Health
High Priority Issues🐛 #1: KnowledgeGraph path silently changes for existing users (default case)Location: The current default KG path is This happens because _config = MempalaceConfig()
-_kg = KnowledgeGraph(db_path=os.path.join(_config.palace_path, "knowledge_graph.sqlite3"))
+if _args.palace:
+ _kg = KnowledgeGraph(db_path=os.path.join(_config.palace_path, "knowledge_graph.sqlite3"))
+else:
+ _kg = KnowledgeGraph()This preserves the default Medium Priority Issues🎨 #2: Docstring install example makes
|
|
Thanks for the review. Addressing the feedback: #1 (KG path regression) — Fixed. The #2 (docstring) — Fixed. #3 (env var pattern) — Intentional, not changing. The #4 (tests) — Deferring. The suggested test manipulates |
Parse --palace before initialising module-level singletons so that both ChromaDB and KnowledgeGraph use the correct palace directory. When --palace is provided the user is requesting an isolated palace; KG must co-locate with ChromaDB under that path, not fall back to the global default (~/.mempalace/knowledge_graph.sqlite3).
d2bf701 to
3d68c41
Compare
|
Thanks for the review. Reverting #1 based on the following reasoning. The README states: "All commands accept The migration concern doesn't apply here. Users who never pass The purpose of |
|
Hey @showaykerker, thanks for the contribution and the discussion! (I'm heping with the PRs..) Re: the revert of #1 — I traced the code path and the default-case regression is real:
Your design argument is valid — Could you restore that conditional fix? if _args.palace:
_kg = KnowledgeGraph(db_path=os.path.join(_config.palace_path, "knowledge_graph.sqlite3"))
else:
_kg = KnowledgeGraph()Everything else in the PR looks good. |
When --palace is not explicitly provided, fall back to KnowledgeGraph() which uses DEFAULT_KG_PATH (~/.mempalace/knowledge_graph.sqlite3), preserving backward compatibility for existing users.
|
You're right — the regression is real. Fixed: now only gets the palace-derived path when |
|
Apologies for the pushback — I traced deeper and the regression you flagged is real. Here's the full breakdown:
Commit 2 (the conditional) is the right call. Existing users keep their KG data; One caveat worth acknowledging: the original design has Chroma at |
Port upstream PR MemPalace#264 (commit 3d68c41 by Hsu Hsiuwei), adapted for the PostgreSQL backend. Parses --palace before instantiating MempalaceConfig and, when present, exports MEMPALACE_PALACE_PATH so the config property picks it up. The upstream commit also co-locates knowledge_graph.sqlite3 under the palace directory; that half is dropped here — the KG lives in Postgres via db.py, there is no separate sqlite file to relocate. Uses parse_known_args so any extra flags passed through by Claude Code or MCP wrappers don't abort startup. Co-authored-by: Hsu Hsiuwei <ZackHsu@itri.org.tw> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Refresh the Sync status paragraph after auditing the 39-commit window 71736a3..fcc9ce8. Records what was ported from that window (--palace flag, pytest-cov coverage) and what was skipped (Claude Code plugin / marketplace ecosystem, ChromaDB-specific fixes, KG co-location half of PR MemPalace#264).
Problem
The
--palaceCLI argument was documented and accepted but silently ignored. BothMempalaceConfigandKnowledgeGraphwere initialised at module import time beforesys.argvwas ever parsed, so passing--palace /some/pathhad no effect and the server always fell back to~/.mempalace/palace.This meant users who registered the MCP server with:
would always get the default palace, not their custom one.
Fix
--palacewithargparsebefore any config is loaded (moved to module level)MEMPALACE_PALACE_PATHenv var when the flag is present — this slots into the existing priority chain (env var > config file > default) inMempalaceConfigknowledge_graph.sqlite3inside the palace directory so a single--palaceflag controls both the ChromaDB collection and the KG (previously the KG was always written to~/.mempalace/knowledge_graph.sqlite3regardless)Test