Skip to content

Apply context memory visibility rules on MCP entity reads - #32465

Merged
ShaileshParmar11 merged 9 commits into
mainfrom
fix/mcp-context-memory-visibility
Sep 5, 2026
Merged

ShaileshParmar11 merged 9 commits into
mainfrom
fix/mcp-context-memory-visibility

Conversation

@Vishnuujain

@Vishnuujain Vishnuujain commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Background

  • Every context memory carries its own sharing setting: private, shared with certain people, or open to everyone.
  • That setting is not a role or a policy, so the usual permission check does not look at it. The REST API checks it separately on each read.
  • The MCP tools that read an entity by name did not run that check.

What changed

  • These MCP tools now run the same check the REST API runs:
    • get_entity_details — plain read, include=[content], and the multi-entity form
    • company_context — reading one pill by name
    • patch_entity — its reply includes the entity, so the check runs before the write
  • The check now sits next to the fetch, in CommonUtils.readEntityForCaller(...). One call fetches and checks, so a read path cannot skip it.
  • The fetch now asks for owners. Without it the memory looks unowned, and its own owner would be turned away.
  • company_context by name answers for the person asking, instead of returning any shared pill. It also checks permissions against that pill, not just the entity type.
  • If the caller cannot be identified, they now see only memories open to everyone.

New helpers in ContextMemoryVisibility

  • enforceVisibility(entity, securityContext) — applies the rule for a memory, does nothing for other entity types, so callers need no type knowledge.
  • hasVisibilityRules(entityType) — whether a type has a sharing setting at all.
  • guardFields(entityType, fields) — adds the fields the check needs to a fetch.

Tests

  • openmetadata-mcp: 594/594. Context memory and AI context suites in openmetadata-service: 136/136.
  • One unit test per path, each confirmed failing without this change.
  • New McpContextMemoryVisibilityIT covers the owner, an admin, another user, and someone the memory is shared with. Not run locally (needs a running server), so CI is its first run.

Notes

@Vishnuujain
Vishnuujain requested a review from a team as a code owner September 2, 2026 10:14
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 11e09ea25c66b9675d4eac3a0c94d7d2c1f6e4cd in Playwright run 33901632120, attempt 1.

✅ 936 passed · ❌ 0 failed · 🟡 2 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 46m 26s

⏱️ Max setup 4m 27s · max shard execution 15m 36s · max shard-job elapsed before upload 19m 43s · reporting 7s

🌐 206.73 requests/attempt · 2.45 app boots/UI scenario · 5.02% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 206.73 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.45 per UI scenario (2417 boots / 988 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 133 0 0 0 0 0
✅ Shard chromium-02 108 0 0 0 0 0
🟡 Shard chromium-03 134 0 1 0 0 0
🟡 Shard chromium-04 125 0 1 0 0 0
✅ Shard chromium-05 157 0 0 0 0 0
✅ Shard chromium-06 121 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 2 flaky test(s) (passed on retry)
  • Pages/Entity.spec.ts › Tier Add, Update and Remove (shard chromium-03, 1 retry)
  • Features/ContextCenterDocument.spec.ts › documents view container is rendered (shard chromium-04, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

pmbrull
pmbrull previously approved these changes Sep 2, 2026
@Vishnuujain
Vishnuujain added this pull request to the merge queue Sep 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-09-02T22:40:16Z)

The entry left the queue before it was built, so no checks ran against it.

@Vishnuujain
Vishnuujain added this pull request to the merge queue Sep 3, 2026
@Vishnuujain
Vishnuujain removed this pull request from the merge queue due to a manual request Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-09-03T11:43:41Z)

The entry left the queue before it was built, so no checks ran against it.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-04T08:03:28Z)

Blocked the queue: playwright-summary

@gitar-bot

gitar-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Applies context memory visibility rules to MCP entity reads, ensuring the same permission checks run on direct entity access as the REST API enforces. The check now sits in CommonUtils.readEntityForCaller(...) for get_entity_details, company_context, and patch_entity, with new helpers in ContextMemoryVisibility to support the validation. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-05T06:41:42Z)

Blocked the queue: playwright-summary

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-05T13:16:11Z)

Blocked the queue: playwright-summary

@pmbrull

pmbrull commented Sep 8, 2026

Copy link
Copy Markdown
Member

picked to 2.0 here #32973

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants