Repository navigation
Fixes 36435: Guide MCP clients through context-first memory discovery - #38011
Conversation
Preserve available provenance and surface conflicting approved claims without treating approval as truth. Keep retrieved memory text below user instructions and existing access and safety rules.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
Related to open-metadata#38205. Preserve the context-first workflow and existing retrieval policy.
|
Hi @harshach — synced this branch with |
…scovery-36435 # Conflicts: # openmetadata-mcp/src/test/java/org/openmetadata/mcp/McpContextDiscoveryGuidanceTest.java
Code Review ✅ Approved 🔴 High risk 2 closed / 2 findingsMemory-only searches now authorize anchored memories through matching-anchor access checks, potentially exposing saved guidance if anchor visibility is miscomputed. Adds context-first memory discovery guidance to MCP tools so assistants check Context Center memories before answering business questions, and makes memory-only searches check anchor access so non-owners can find anchored memories. Resolved the keyword-first lookup gap that missed anchored memories for non-owners, and the ✅ 2 closed✅ Bug: Keyword-first memory lookup misses anchored memories for non-owners
✅ Bug: company_context says fqn and query share scope; code says they differ
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Not backported to
|
…#38011) (#38709) * Fixes #36435: guide MCP clients through memory-first discovery * Clarify conflicting approved memory guidance Preserve available provenance and surface conflicting approved claims without treating approval as truth. Keep retrieved memory text below user instructions and existing access and safety rules. * Fixes #36435: Require anchored memory discovery before answering * Clarify company_context lookup scopes Related to #38205. Preserve the context-first workflow and existing retrieval policy. * trim memory guidance * Distinguish searchable and readable Company Context notes in MCP guidance * memory search checks anchors * resolve memory-only index --------- (cherry picked from commit c6d946b) Co-authored-by: Kia Yun <[email protected]> Co-authored-by: Vishnu Jain <[email protected]>
…schema, stale and slow ITs (#39394) * fix(sdk): remove fields cleared on a server-returned entity in update() #39164 pruned the no-snapshot baseline to the fields the caller sent, so a field nulled on an entity returned by create() or update() was never removed. Prune only hand-built partial entities, which carry no version or updatedAt. * test(ontology): create bot_entity in OntologyEntityDAOIT's scratch schema Approval rules read bot_entity since #38797. Without it the gate refused every write with "Approval rules are unavailable". * test(context-memory): align ContextMemoryAnchorIT with memory-only search #38011 lets a memory-only search return anchored memories a reader may read, but left one assertion on the old rule. The "all" assertions counted fuzzy-matched tables and queried the question, which "all" does not search; count memories only and carry the query in the display name. * fix(glossary): retry the pending-label drop of a bulk asset removal on deadlock The chunked DELETE on tag_usage commits on its own and is idempotent, so DeadlockRetry can rerun it. * test: tolerate slow runners in OntologyGovernanceIT and ConceptContextIT Retry a SPARQL request the single worker turns away with 429, and give the approval workflow the 5 minutes MetricResourceIT already allows. * test(informix): drop the clear() of per-source stored procedure state PerSourceState is owned by each source instance, so a second run starts empty and the object has no clear(). * chore(airflow-apis): refresh uv.lock for the ingestion mcp extra * test: honour the SPARQL Retry-After and explain the workflow wait The bounded worker answers saturation with 429 and Retry-After by design, so the client waits as told. The approval workflow starts only when the serial WorkflowEventConsumer reaches the create event, which lags under parallel load. * test: poll the SPARQL retry with Awaitility; guard untouched fields in update() Replace the sleep loop with Awaitility at the server's Retry-After interval. Add a test that a server-returned entity with one changed field emits no remove ops.
Describe your changes:
Fixes #36435
search_metadatanow says, in one sentence, to checkentityType='contextMemory'before answering a business question.find_contextsays it does not search memories. ThequeryFilterhelp no longer claims the filter overridesquery(it is ANDed with it).company_contexttext is shortened.all), hybrid and vector search keep the pinned-anchor rule.Type of change:
High-level design:
isMemoryOnlySearchdecides "memory index alone" on the resolved index name (a list of indexes never is). For those searches, both engines build the visibility filter withbuildListingVisibilityFilter+matchingListingAnchors, the existing Context Center listing code. NLQ uses the same path so its answer and fallback agree; a count overallkeeps the pinned rule so its totals match whatalllists.ADR:2026-11-12-context-center-authorizes-memory-anchors-before-paging(v3) andADR:2026-10-09-search-admits-memories-of-pinned-anchors(v4), plusADR:2026-11-17-mcp-discovers-memories-through-the-existing-keyword-search.Tests:
Use cases covered
contextMemory), and onall, where the unpinned memory stays hidden and a pinned one is found.Unit tests
ContextMemorySearchVisibilityTest,*MemoryListingAnchorsTest,*NlqRequestBuilderTest,SearchEntityTypeCountsTest,ContextMemoryVisibilityTestand related: 151 passed. MCPMcpContextDiscoveryGuidanceTest,SearchMetadataToolTest,CompanyContextToolTest,CreateEntityToolTest: 115 passed.Backend integration tests
ContextMemoryAnchorIT#aSearchPinnedToAnAnchor_agreesWithRestOnItsMemories.Pending:
ContextMemoryAnchorITnot run yet on0455b8601c6.Manual testing performed
On a local Collate build of
0455b8601c6, with a memory attached to glossary termecommerce.CustomerDatasaying to list customers fromCUSTOMER360_SAMPLE, and a non-owner reader:6b73c352a91). The same client gave the right table 0/6 with the main, original-PR and text-only descriptions.contextMemoryand by index name, and counts match hits (1/1). Onallandtable,contextMemoryit stays hidden, andallcounts matchallhits.UI screen recording:
Not applicable: backend and MCP description change.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.6b73c352a91againstREVIEW.md; its 🔴 (rawcontextMemoryindex name in counts) is fixed infa5bf33d561.

Confidence Score: 5/5
The PR appears safe to merge; no actionable defects were found in the changed guidance or tests.Summary
Adds context-first memory discovery guidance to four MCP tools without changing retrieval or permissions.
No actionable issues were found. Tests were not run during this review. The previous-review merge-base check failed, so the full PR changes were reviewed.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Business question] --> B[Search memories by keyword] B --> C[Discover relevant anchors and returned IDs] C --> D[Repeat memory search with anchor ID and keyword] D --> E[Read relevant approved memories and available sources] E --> F[Surface conflicting claims] F --> G[Search assets and answer]Reviews (8) · Last reviewed commit: "Merge branch 'main' into fix/mcp-context..." · Reviewed by Greptile