Skip to content

[mcp] fix read_data_product under restrict_to_user_objects#36999

Open
mtabebe wants to merge 1 commit into
MaterializeInc:mainfrom
mtabebe:ma/rbac/read_data_products
Open

[mcp] fix read_data_product under restrict_to_user_objects#36999
mtabebe wants to merge 1 commit into
MaterializeInc:mainfrom
mtabebe:ma/rbac/read_data_products

Conversation

@mtabebe

@mtabebe mtabebe commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem:
The lookup query in read_data_product called
has_cluster_privilege, whose body references mz_catalog.mz_roles. Those resolved IDs propagate into the caller, so the user object restriction check fires on mz_roles and the tool fails.

Solution:
Rewrite the lookup to LEFT JOIN mz_show_my_cluster_privileges instead of calling the function.

Two supporting changes for that

  • Swap pg_has_role for mz_session_role_memberships() in the mz_show_my_*_privileges views (same pattern already on mz_show_my_object_privileges), so their bodies don't pull mz_roles in either.
  • Allow-list mz_show_my_cluster_privileges the restriction check gates on item identity, not body, so the body fix alone isn't enough.

Testing:
SLT regression pin in rbac_mcp_agent.slt for the new lookup query, and a test_mcp_agent_restricted MCP integration test that runs the agent endpoint with restrict_to_user_objects = true.

Problem:
The lookup query in `read_data_product` called
`has_cluster_privilege`, whose body references `mz_catalog.mz_roles`.
Those resolved IDs propagate into the caller, so the user object
restriction check fires on `mz_roles` and the tool fails.

Solution:
Rewrite the lookup to `LEFT JOIN mz_show_my_cluster_privileges`
instead of calling the function.

Two supporting changes for that
- Swap `pg_has_role` for `mz_session_role_memberships()` in the
`mz_show_my_*_privileges` views (same pattern already on
`mz_show_my_object_privileges`), so their bodies don't pull
`mz_roles` in either.
- Allow-list `mz_show_my_cluster_privileges` the restriction check
gates on item identity, not body, so the body fix alone isn't enough.

Testing:
SLT regression pin in `rbac_mcp_agent.slt` for the new lookup query,
and a `test_mcp_agent_restricted` MCP integration test that runs the
agent endpoint with `restrict_to_user_objects = true`.
@mtabebe mtabebe requested review from bobbyiliev and jubrad June 11, 2026 21:22
@mtabebe mtabebe marked this pull request as ready for review June 11, 2026 21:22
@mtabebe mtabebe requested a review from a team as a code owner June 11, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants