[16.0][FIX] ai_oca_mcp: grant internal users access to their own MCP keys#93
Draft
nobuQuartile wants to merge 1 commit into
Draft
[16.0][FIX] ai_oca_mcp: grant internal users access to their own MCP keys#93nobuQuartile wants to merge 1 commit into
nobuQuartile wants to merge 1 commit into
Conversation
nobuQuartile
marked this pull request as draft
July 15, 2026 00:30
The MCP endpoint switches to the key's user_id via with_user before serving tools/list and tools/call. mcp.server and mcp.server.key were only accessible to base.group_system, so a non-admin key user hit an AccessError while reading its own key and server. Grant base.group_user read access to both models and add record rules limiting internal users to their own keys (and the servers those keys belong to), while keeping full visibility for administrators.
nobuQuartile
force-pushed
the
16.0-fix-ai_oca_mcp
branch
from
July 21, 2026 00:48
7efa771 to
9c22916
Compare
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.
Problem
The MCP endpoint (
controllers/mcp_controller.py) authenticates a request, then switches to the key'suser_idviawith_userbefore servingtools/list/tools/call:But
mcp.serverandmcp.server.keywere only accessible tobase.group_system. When the key'suser_idis a regular internal user, reading the key (self) and its server (self.server_id) afterwith_userraises anAccessError.Fix
base.group_userread access tomcp.serverandmcp.server.key.user_id = user.id) and the servers those keys belong to (key_ids.user_id = user.id).base.group_systemrules ([(1, '=', 1)]) so administrators keep full visibility (admins are alsogroup_usermembers).Keys remain private: an internal user cannot see other users' keys.
Tests
Added
test_internal_user_accesscovering both directions: an internal user can read the key/server it owns, and getsAccessError(and search exclusion) for records it has no key for.@qrtl