Skip to content

[MIG] ai_oca_mcp: Migration to 19.0 - #124

Open
dreispt wants to merge 23 commits into
OCA:19.0from
dreispt:19.0-mig-ai_oca_mcp
Open

dreispt wants to merge 23 commits into
OCA:19.0from
dreispt:19.0-mig-ai_oca_mcp

Conversation

@dreispt

@dreispt dreispt commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Migration of ai_oca_mcp to 19.0.

Included PRs / lineage

This branch builds on the full upstream module history rather than a plain copy:

19.0 changes

  • _sql_constraints → models.Constraint (mcp.server, mcp.server.key)
  • Per-method ormcache.clear_cache() removed upstream — expire_key() uses self.env.registry.clear_cache()
  • res.users.groups_id → group_ids in test data
  • auth="none" routes now run in a read-only transaction by default — added readonly=False since the MCP endpoint always writes (log records, key expiry)
  • test_url uses self.base_url() instead of hardcoded 127.0.0.1:8069
  • Manifest 19.0.1.0.0; regenerated README/description

Beyond the migration

Two commits go further than a straight port and can be split into follow-up PRs if preferred:

  • [IMP] ai_oca_mcp: revamp module documentation — rewrites the readme fragments to describe the actual protocol surface (JSON-RPC over HTTP POST, tools/list/tools/call, no SSE), the hashed-key/per-user auth model, key lifecycle, auditing, the tool-kind limitation, and where real capabilities come from (ai_tool_read / extension modules).
  • [IMP] ai_oca_mcp: expose server instructions in the initialize handshake — returns the MCP instructions field: an auto-generated capability summary (server purpose + exposed tool names/descriptions) plus optional per-server free text, so MCP clients can feed usage guidance to the model at handshake time.

Tests

16 ai_oca_mcp + 9 ai_tool tests pass against a 19.0 checkout (ai_oca_mcp tests issue real MCP-over-HTTP requests and exercise non-admin key access).

etobella and others added 18 commits October 7, 2026 15:46
Currently translated at 100.0% (43 of 43 strings)

Translation: ai-16.0/ai-16.0-ai_oca_mcp
Translate-URL: https://translation.odoo-community.org/projects/ai-16-0/ai-16-0-ai_oca_mcp/it/
Currently translated at 100.0% (43 of 43 strings)

Translation: ai-16.0/ai-16.0-ai_oca_mcp
Translate-URL: https://translation.odoo-community.org/projects/ai-16-0/ai-16-0-ai_oca_mcp/pt_BR/
Currently translated at 4.6% (2 of 43 strings)

Translation: ai-16.0/ai-16.0-ai_oca_mcp
Translate-URL: https://translation.odoo-community.org/projects/ai-16-0/ai-16-0-ai_oca_mcp/gl/
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.
cover exception in the execute method
it was wrongly set to True we do not notify client if list changed
@OCA-git-bot OCA-git-bot added mod:ai_oca_mcp Module ai_oca_mcp mod:ai_tool Module ai_tool series:19.0 labels Oct 7, 2026
@dreispt
dreispt force-pushed the 19.0-mig-ai_oca_mcp branch from 9b188e9 to 3e802f7 Compare October 7, 2026 16:35
@dreispt

dreispt commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

/ocabot migration ai_oca_mcp

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone Oct 7, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Oct 7, 2026
1 of 8 tasks
@dreispt
dreispt force-pushed the 19.0-mig-ai_oca_mcp branch from 3e802f7 to 32e2309 Compare October 7, 2026 16:48
@oca-cla-bot

oca-cla-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@dreispt
dreispt force-pushed the 19.0-mig-ai_oca_mcp branch from 32e2309 to 1802891 Compare October 7, 2026 16:52
nobuQuartile and others added 2 commits October 7, 2026 17:58
Building and dispatching a tool reads ir.model via model_id, which a
plain internal user (base.group_user) cannot access. Resolve the model
name with sudo() while keeping the actual tool execution under the
caller's own permissions, so non-admin MCP keys can list and call tools.

Add a regression test exercising a non-admin user through
_get_tool_definition and _execute_tool.

(cherry picked from commit 16beaa7)
'date' is not a JSON Schema type, so the declared output schema is not
valid for MCP clients validating against it. Declare the RFC 3339
format instead.

Assisted-by: Devin:SWE-2 High
Port ai_oca_mcp to 19.0, based on the 17.0 migration in OCA#85 and
the 18.0 migration in OCA#76.

- Replace _sql_constraints with models.Constraint.
- Declare the MCP endpoint readonly=False: auth="none" routes default
  to a read-only cursor in 19.0 and this endpoint always writes (log
  records, key expiry).
- res.users groups_id renamed to group_ids in tests.
- Replace per-method ormcache clear_cache() with
  env.registry.clear_cache() in tests.
- Restore the security/security.xml manifest entry lost while rebasing
  the 17.0 migration over the 16.0 fix commit.
- Non-admin key usage additionally requires the ai_tool fixes in the
  preceding commits: the ir.model metadata lookup cherry-picked from
  OCA#119, and an equivalent output-schema fix for _ai_get_date.

Assisted-by: Devin:SWE-2 High
@dreispt
dreispt force-pushed the 19.0-mig-ai_oca_mcp branch from 1802891 to da41802 Compare October 7, 2026 17:01
Rewrite the readme fragments to document the actual protocol surface
(JSON-RPC over HTTP POST, tools/list and tools/call, no SSE), the
hashed-key/per-user auth model, key lifecycle and audit logging, the
tool-kind limitation, where real capabilities come from (ai_tool_read
and other extension modules), and the admin vs internal-user access
rules. Update contributors.

Assisted-by: Devin:SWE-2 High
MCP's InitializeResult supports an optional instructions field that
spec-compliant clients pass to the model. Return an auto-generated
capability summary — the server's purpose and the exposed tools with
their descriptions — and append the optional instructions text
configured on mcp.server for extra context.

Assisted-by: Devin:SWE-2 High
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:ai_oca_mcp Module ai_oca_mcp mod:ai_tool Module ai_tool series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants