Skip to content

[16.0][FIX] ai_oca_mcp: grant internal users access to their own MCP keys#93

Draft
nobuQuartile wants to merge 1 commit into
OCA:16.0from
qrtl:16.0-fix-ai_oca_mcp
Draft

[16.0][FIX] ai_oca_mcp: grant internal users access to their own MCP keys#93
nobuQuartile wants to merge 1 commit into
OCA:16.0from
qrtl:16.0-fix-ai_oca_mcp

Conversation

@nobuQuartile

@nobuQuartile nobuQuartile commented Jul 15, 2026

Copy link
Copy Markdown

Problem

The MCP endpoint (controllers/mcp_controller.py) authenticates a request, then switches to the key's user_id via with_user before serving tools/list / tools/call:

server = request.env["mcp.server.key"].sudo().browse(server_id)
server = server.with_user(server.user_id.id)

But mcp.server and mcp.server.key were only accessible to base.group_system. When the key's user_id is a regular internal user, reading the key (self) and its server (self.server_id) after with_user raises an AccessError.

Fix

  • Grant base.group_user read access to mcp.server and mcp.server.key.
  • Add record rules so internal users only see their own keys (user_id = user.id) and the servers those keys belong to (key_ids.user_id = user.id).
  • Add permissive base.group_system rules ([(1, '=', 1)]) so administrators keep full visibility (admins are also group_user members).

Keys remain private: an internal user cannot see other users' keys.

Tests

Added test_internal_user_access covering both directions: an internal user can read the key/server it owns, and gets AccessError (and search exclusion) for records it has no key for.

@qrtl

@nobuQuartile
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
nobuQuartile force-pushed the 16.0-fix-ai_oca_mcp branch from 7efa771 to 9c22916 Compare July 21, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants