feat(mcp): emit external_id in search_notes markdown output - #1103
Merged
Conversation
search_notes text output printed permalink/score/match but not the note's external_id, so a consumer reading the final (post-merge) markdown could not identify which notes are on the displayed page. This adds a per-result external_id line (like recent_activity), letting the hosted MCP layer deep-link each hit from the result the caller actually sees — the reliable key for all-projects search, where the displayed page is decided after the per-project API calls (#1423). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Joe P <joe@basicmemory.com>
Contributor
Author
|
@phernandez let me know if you don't want the entity external_id in the search results markdown, and i'll do something else. |
14 tasks
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.
Why
The hosted Basic Memory Cloud MCP layer decorates
search_notesresults with web-app deep-links. For all-projects search, the tool fans out one API call per project, then merges/sorts/slices before returning — so links recorded from those per-project API calls don't match the final displayed page (wrong cap, wrong ordering). To decorate from the final result the caller actually sees, the cloud layer needs a stable per-result identifier in that output.search_notestext output already printspermalink,score, andmatch, but notexternal_id. Permalink isn't usable as the key because all-projects search workspace-qualifies it (workspace/project/...), whileexternal_idis globally unique and unchanged by qualification.What
_format_search_markdownnow emits a- external_id: {uuid}line per result that has one — the same patternrecent_activityalready uses. Hits without anexternal_idrender no line.The
external_idfield itself already exists onSearchResult(added in #1101); this only surfaces it in the text output.How it was tested
tests/mcp/test_tool_search.py::test_format_search_markdown_with_results— extended: one result carries anexternal_id(asserts the line renders), one does not (asserts exactly oneexternal_id:line, no empty line).uv run pytest tests/mcp/test_tool_search.py -k format_search_markdown→ 2 passed. Lint clean.Companion
Consumed by basic-memory-cloud #1546, which parses these
external_ids from the final result to build per-result web-app links that match the displayed page for both single- and multi-project search. That PR pins itsbasic-memoryrev to this commit and must be re-pinned to the merged commit here.🤖 Generated with Claude Code