Repository navigation
Conversation
Greptile SummaryThis PR aligns the SSE MCP
Confidence Score: 4/5Safe to merge; the core filtering and limit logic are correct and covered by the new regression test. The filtering change is straightforward and the test correctly verifies all three exclusion conditions (locked, rejected, invalidated) plus the overfetch multiplier. Two small gaps remain: the search_memories JSON Schema still doesn't expose minimum/maximum for limit, so MCP clients are unaware of the silent cap at 20; and score_map can accumulate a spurious None key from any vector result that lacks memory_id. Neither affects correctness in the normal case. The search_memories tool schema in mcp_sse.py (around line 263) deserves a second look to add minimum/maximum hints. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant SSE as mcp_sse.py
participant VDB as vector_db
participant MDB as memories_db
Client->>SSE: "search_memories(query, limit=N)"
SSE->>SSE: "fetch_limit = min(N*3, 60)"
SSE->>VDB: "find_similar_memories(uid, query, limit=fetch_limit)"
VDB-->>SSE: matches[0..fetch_limit]
SSE->>MDB: get_memories_by_ids(uid, memory_ids)
MDB-->>SSE: memories[0..fetch_limit]
SSE->>SSE: filter locked/rejected/invalidated
SSE->>SSE: sort by relevance_score desc
SSE->>SSE: slice results[:N]
SSE-->>Client: "{memories: results[0..N]}"
|
| score_map = {m['memory_id']: m.get('score', 0) for m in matches} | ||
| # Mirror the REST MCP path so SSE search never surfaces rejected, locked, | ||
| # or superseded facts, while fetching extra candidates before filtering. | ||
| score_map = {m.get('memory_id'): m.get('score', 0) for m in matches} |
There was a problem hiding this comment.
score_map can hold a None key from matches without memory_id. memory_ids correctly skips entries where m.get('memory_id') is falsy, but score_map is built from all matches, so any match missing memory_id inserts a {None: score} entry. Aligning score_map with the same filter guard used for memory_ids is more defensive.
| score_map = {m.get('memory_id'): m.get('score', 0) for m in matches} | |
| score_map = {m.get('memory_id'): m.get('score', 0) for m in matches if m.get('memory_id')} |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Addressed in the current head (3a8777f6d). score_map now uses the same guard as memory_ids:
score_map = {m.get('memory_id'): m.get('score', 0) for m in matches if m.get('memory_id')}The regression test also includes a match without memory_id before the locked/rejected/invalidated/visible matches, so this path is covered.
Revalidated on the Windows backend venv:
python -m pytest tests\unit\test_lock_bypass_fixes.py::TestMcpSseLockRedaction -q-> 3 passedpython -m black --line-length 120 --skip-string-normalization routers\mcp_sse.py tests\unit\test_lock_bypass_fixes.py --checkpython -m py_compile routers\mcp_sse.py tests\unit\test_lock_bypass_fixes.py
tianmind-studio
left a comment
There was a problem hiding this comment.
The current head includes the follow-up for the schema note: search_memories.limit now advertises minimum: 1 and maximum: 20, matching the parse_mcp_int bounds. I also updated the PR description so the review context reflects the latest commit.
…8439) ## Summary The MCP server already lets ChatGPT/Claude read the user's tasks (`get_action_items`), but not change them. This adds the write half, so an assistant connected to Omi can manage tasks instead of only observing them: create a follow-up it identified, mark one done, reschedule one, delete a stale one, and find a specific task by what it is about before acting on it. New MCP tools (with matching REST endpoints under `/v1/mcp/action-items`): - `create_action_item(description, due_at?, completed?)` - `complete_action_item(action_item_id, completed?)` (reopen by passing `completed=false`) - `update_action_item(action_item_id, description?, due_at?)` - `delete_action_item(action_item_id)` - `search_action_items(query, limit?)` (semantic, completes the `search_memories` / `search_conversations` pattern) This rounds out action items as a two-way surface, the same way memories already have create/edit/delete tools, and moves in the direction of #4862 (make Omi an easily integratable memory bank for ChatGPT/Claude). ## Design notes - Shared orchestration. Create/complete/update/delete/search all run through a single `utils/mcp_action_items.py` helper that both transports (REST `mcp.py` and SSE `mcp_sse.py`) call thinly. The two MCP paths have drifted before (for example the SSE/REST search alignment in #7788), so the write logic lives in one place rather than being duplicated. `utils` sits below `routers`, so neither router imports the other. - Idempotent create. Creation is content-idempotent on (uid, normalized description) using the existing `create_action_item` idempotency key, so a model client that retries a tool call after a transport hiccup updates the same task instead of creating duplicates. This mirrors the app's own create endpoint. - Searchable immediately. A newly created or re-described task is indexed into the action-item vector store, so it shows up in `search_action_items` (and the app's task search) the same way app-created tasks do. Vector writes are best-effort: the task is already persisted, so a vector failure only degrades ranking and never loses the task. - Paywall and ownership. Complete/update/delete fetch the item first (uid-scoped, so a foreign id can never resolve) and return 404 / MCP -32001 when missing and 402 / MCP -32002 when the item is locked behind a paid plan, matching how the memory writes behave. - New `action_items.write` OAuth scope, advertised in the server metadata. Writes are annotated (delete as destructive). Creation is rate limited (`action_items:write`, 120/hr) since it is the only unbounded-growth operation; the others act on existing tasks. - Due dates accept ISO 8601 or YYYY-MM-DD and are normalized to UTC, so due-date filtering never compares naive and aware datetimes. ## Out of scope MCP-created tasks are not pushed to external task managers (Apple Reminders / Todoist) or armed with a reminder notification. Those are client-side concerns today, and silently syncing AI-created tasks into a user's external tools felt like the wrong default for a first cut. Straightforward to add later if maintainers want it. ## Testing - New `tests/unit/test_mcp_action_item_writes.py` (33 tests), registered in `test.sh`. Covers the shared util (idempotency key, due-date parsing, create/complete/update/delete/search, vector-failure resilience, paywall and not-found guards) and both transports (REST status codes, MCP error codes, tool registration and scope). - `backend/test.sh` passes locally, and the existing MCP suites (data endpoints, search, profile) still pass. - `black --line-length 120 --skip-string-normalization` clean. `scripts/lint_async_blockers.py` reports no violations. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/8439?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Summary
search_memoriesexclude locked memories, matching the REST MCP path instead of returning truncated locked content.min(limit * 3, 60)before filtering, then return at most the requested limit.search_memories.limitschema bounds (minimum: 1,maximum: 20) so MCP clients see the same constraints enforced byparse_mcp_int.Context
Follow-up to #7763: Greptile noted that the merged SSE filter still diverged from REST for
is_lockedmemories and could return short result pages after filtering. A later review also noted that the MCP input schema should expose the samelimitbounds enforced in code; this PR now includes that metadata.Testing
python -m pytest tests\unit\test_lock_bypass_fixes.py::TestMcpSseLockRedaction -q-> 3 passed, 1 warningpython -m black --line-length 120 --skip-string-normalization routers\mcp_sse.py tests\unit\test_lock_bypass_fixes.py --checkpython -m py_compile routers\mcp_sse.py tests\unit\test_lock_bypass_fixes.pygit diff --check -- backend/routers/mcp_sse.py backend/tests/unit/test_lock_bypass_fixes.pyNote: running the full
test_lock_bypass_fixes.pyfile in this lightweight Windows environment still fails on pre-existing missing optional dependencies (av,langchain_core,anthropic,pytz) outside this changed path.