Igor Lins e Silva
e200ce2c8a
fix: detect mtime changes in _get_client to prevent stale HNSW index ( #757 )
...
When external tools write to the palace database (CLI mining, scripts), the MCP server's cached ChromaDB collection becomes stale — its HNSW index doesn't know about new vectors. Develop already invalidates on inode changes (catches rebuilds) but not on mtime changes (misses in-place writes).
This PR:
- Adds st_mtime tracking alongside st_ino in _get_client; invalidates the cached client on either change.
- Adds the mempalace_reconnect MCP tool for explicit cache flush.
Original author: @jphein (#663 ). Original approval: @Ari4ka.
Skips test_missing_db_invalidates_cache on Windows (ChromaDB holds chroma.sqlite3 open).
2026-04-13 01:53:13 -03:00
shafdev
f4226047cb
fix: hash full content in tool_add_drawer drawer ID ( #716 )
...
* fix: hash full content in tool_add_drawer drawer ID
* style: apply ruff format
* style: fix ruff format for CI ruff 0.4.x
2026-04-13 01:40:46 -03:00
copilot-swe-agent[bot]
c478dfa173
fix: harden palace security checks
...
Agent-Logs-Url: https://github.com/MemPalace/mempalace/sessions/775f2fc4-3051-462e-8586-6d694b55da0d
Co-authored-by: igorls <4753812+igorls@users.noreply.github.com >
2026-04-12 22:19:58 -03:00
Ben Sigman
4621f85d7c
style: ruff format all Python files ( #675 )
2026-04-11 22:59:34 -07:00
Ben Sigman
20c8f8e57b
feat: new MCP tools — get/list/update drawer, hook settings, export ( resolves #635 ) ( #667 )
...
* feat: MCP reliability — inode detection, WAL rotation, metadata cache, search limits
Infrastructure hardening for the MCP server:
- Detect palace DB replacement via inode tracking (repair command support)
- WAL rotation to prevent unbounded WAL growth
- _fetch_all_metadata() + _get_cached_metadata() with 60s TTL for taxonomy/status
- _MAX_RESULTS cap (100) with limit clamping [1, _MAX_RESULTS]
- max_distance parameter for similarity threshold in search
- Handle all notifications/* methods, null arguments, method=None
- Remove duplicate _client_cache = None declarations
- searcher.py max_distance parameter passthrough
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
* feat: new MCP tools (get/list/update drawer, hook settings, memories filed), export, normalize
New MCP tools:
- mempalace_get_drawer: fetch single drawer by ID with full content
- mempalace_list_drawers: paginated listing with wing/room filter
- mempalace_update_drawer: update content/wing/room on existing drawers
- mempalace_hook_settings: get/set hook behavior (silent_save, desktop_toast)
- mempalace_memories_filed_away: check latest checkpoint status
Also includes:
- exporter.py: export palace as browsable markdown files
- normalize.py: tool_use/tool_result capture for richer transcript mining
- layers.py: updated for new tool integration
- config.py: hook settings properties (hook_silent_save, hook_desktop_toast)
Depends on PR 3 (reliability) for _MAX_RESULTS, _metadata_cache, WAL logging.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
* fix: normalize.py handles string messages and Read offset type mismatch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
* fix: params null guard, L2→cosine docs, empty tool_use_map key guard
- Handle explicit null in MCP params (request.get("params") or {})
- Fix search tool description: L2 → cosine distance (collection uses hnsw:space=cosine)
- Guard against empty string key in tool_use_map from malformed JSONL entries
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
* fix: rename ambiguous var 'l' to 'line' (E741 lint)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
* fix: address code review findings (5 issues)
1. min_similarity backwards-compat: convert similarity to distance scale
(1.0 - similarity) instead of passing raw value as max_distance
2. Restore structured error reporting (error + partial fields) in
tool_status, tool_list_wings, tool_list_rooms, tool_get_taxonomy
— reverts silent except:pass that dropped #647 security hardening
3. inode cache: remove falsy-zero short-circuit so missing DB file
triggers reconnect instead of reusing stale client
4. _fetch_all_metadata: check for empty batch before extending/advancing
offset to prevent infinite loop on concurrent deletion
5. KG initialization: only override path when --palace is explicit;
default runs use KnowledgeGraph's built-in default path
Co-authored-by: jphein <jphein@users.noreply.github.com >
---------
Co-authored-by: jp <jp@jphein.com >
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com >
Co-authored-by: jphein <jphein@users.noreply.github.com >
2026-04-11 21:25:04 -07:00
grtninja
154e8a78ec
fix: implement MCP ping health checks ( #600 )
2026-04-11 16:16:37 -07:00
bensig
b1adc047e6
fix: address Octocode review — move size check, add tests for all 3 fixes
...
- Move file size check before try block so IOError propagates cleanly
(not caught by the except OSError handler below it)
- Wrap os.path.getsize in its own try/except to preserve existing
test_normalize_io_error behavior on missing files
- Add test_normalize_rejects_large_file (mocked getsize)
- Add test_null_arguments_does_not_hang (#394 )
- Add test_cmd_repair_trailing_slash_does_not_recurse (#395 )
532 tests pass locally, 0 regressions.
2026-04-09 10:40:53 -07:00
virgil-at-biocompute
950d52baf2
fix: negotiate MCP protocol version instead of hardcoding
...
The initialize handler hardcoded protocolVersion "2024-11-05", which
causes newer MCP clients (e.g. Claude Code) to reject the connection
when they negotiate "2025-11-25" or later.
Echo the client's requested version if it is in the supported set,
otherwise fall back to the latest supported version. This keeps
backwards compatibility with older clients while allowing newer ones
to connect.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-04-08 22:57:32 -04:00
Igor Lins e Silva
af42a850f6
fix: split semicolon statements onto two lines for ruff E702
2026-04-08 15:11:55 -03:00
Igor Lins e Silva
bf88daa649
fix: address review — re-mine modified files, idempotent add_drawer, cleanup ChromaDB handles
2026-04-08 15:11:55 -03:00
Igor Lins e Silva
47696bef8c
fix: address Copilot review — derive MCP version, improve test isolation and portability
2026-04-08 04:41:03 -03:00
Igor Lins e Silva
5ac4947d02
fix: preserve CLI exit codes, log tracebacks, sanitize search errors, validate fixture
2026-04-07 18:26:39 -03:00
Igor Lins e Silva
96de23cd97
fix: CI failures — update workflow for uv migration, fix lint and format
...
- Switch CI install step from `pip install -r requirements.txt` to
`pip install -e ".[dev]"` since requirements.txt was removed
- Add noqa: E402 to intentionally-late imports in conftest.py
(HOME must be isolated before mempalace imports)
- Remove unused KnowledgeGraph import in test_knowledge_graph.py
- Apply ruff formatting to test files
2026-04-07 17:59:21 -03:00
Igor Lins e Silva
cd8b245fdc
fix: address Copilot review — remove unused imports, isolate HOME in tests, restore dev extra
2026-04-07 17:55:10 -03:00
Igor Lins e Silva
72c548b729
test: expand coverage from 20 to 92 tests, migrate to uv
...
- Migrate from setuptools to hatchling build backend
- Add dependency-groups (PEP 735) for dev tooling (pytest, ruff)
- Remove redundant requirements.txt in favor of uv.lock
- Fix __version__ mismatch (2.0.0 -> 3.0.0 to match pyproject.toml)
New test files:
- conftest.py: shared fixtures (isolated palace, KG, ChromaDB collection)
- test_knowledge_graph.py: 17 tests (entity CRUD, temporal queries, timeline)
- test_mcp_server.py: 25 tests (protocol dispatch, read/write/KG/diary tools)
- test_searcher.py: 7 tests (search_memories API, filters, error handling)
- test_dialect.py: 13 tests (AAAK compression, entity/emotion detection, zettel encoding)
All 92 tests pass on Python 3.13 with chromadb 0.6.3.
2026-04-07 17:55:10 -03:00