feat(mcp): add mempalace_sync_status tool and freshness hook - #1347
Open
rusel95 wants to merge 1 commit into
Open
feat(mcp): add mempalace_sync_status tool and freshness hook#1347rusel95 wants to merge 1 commit into
rusel95 wants to merge 1 commit into
Conversation
rusel95
force-pushed
the
feat/sync-mcp-tool-v2
branch
from
May 4, 2026 11:43
5ba3cb2 to
7a3db39
Compare
Adds a read-only MCP tool for AI agents to check whether palace memories are up to date, plus a stop hook that warns when stale files are detected. MCP tool mempalace_sync_status: - Scans all drawers in batches of 500 - Compares stored content_hash against current file content - Returns status: fresh | stale | missing | unknown | empty | error - Returns stale_files list and ready-to-run remine_commands - Returns status: unknown (not fresh) when all drawers lack content_hash - Optional directory param scopes check with path boundary enforcement - SESSION_ID sanitized to prevent path traversal in stamp file Hook mempal_freshness_hook.sh: - Checks freshness once per session (configurable CHECK_INTERVAL, default 3600s) - Uses sed instead of grep -P for macOS compatibility - Quotes CHECK_DIR to handle paths with spaces Docs: adds mempalace_sync_status to website/reference/mcp-tools.md, updates tool count from 29 to 30. Depends on: feat/content-hash-foundation (content_hash in drawer metadata) Relates to MemPalace#224.
rusel95
force-pushed
the
feat/sync-mcp-tool-v2
branch
from
May 4, 2026 11:54
7a3db39 to
9a15986
Compare
Author
✅ End-to-end testing completedRan the full freshness detection pipeline against real ChromaDB: mine files → edit/delete → call Tests verified (8 in
Full suite (including readme claims test for tool count 29→30): 0 regressions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 The problem
An AI agent searches the palace and gets results. Are those results current? Were the source files modified since the last mine? There is no way to know — the agent just has to trust that the memories are fresh.
This is a correctness risk. Stale memories can inject outdated or contradictory context into live reasoning.
✅ What this does
MCP tool:
mempalace_sync_statusA read-only tool that tells the agent exactly what is fresh, what is stale, and what to do about it:
No side effects. The agent can call this before trusting search results, then suggest re-mine commands to the user.
Hook:
mempal_freshness_hook.shStop hook that checks freshness once per session (configurable
CHECK_INTERVAL, default 3600s). Warns the agent when stale files are detected.🔒 Security
SESSION_IDsanitized viatr -cd A-Za-z0-9_-to prevent path traversal in stamp file/projectdoes not match/project_othersedinstead ofgrep -Pfor macOS compatibility$CHECK_DIRquoted to handle paths with spaces🧪 Tests
8 sync-specific tests + all 103 existing MCP server tests pass.
Depends on: #1343 (content_hash in drawer metadata — without it, tool returns
status: unknown)Relates to #224.