ai*
This commit is contained in:
31
ai_mcp/views/ir_actions_server_views.xml
Normal file
31
ai_mcp/views/ir_actions_server_views.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="ir_actions_server_view_form_mcp" model="ir.ui.view">
|
||||
<field name="name">ir.actions.server.form.mcp</field>
|
||||
<field name="model">ir.actions.server</field>
|
||||
<field name="inherit_id" ref="ai.ir_actions_server_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<!-- add into the ai group so labels share the column with `use_in_ai` -->
|
||||
<xpath expr="//group[@name='use_in_ai']" position="inside">
|
||||
<label for="use_in_mcp" invisible="not use_in_ai"/>
|
||||
<div invisible="not use_in_ai">
|
||||
<field name="use_in_mcp"/>
|
||||
<label for="is_readonly" invisible="not use_in_mcp" class="mx-2"/>
|
||||
<field name="is_readonly" invisible="not use_in_mcp"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_actions_server_view_list_mcp" model="ir.ui.view">
|
||||
<field name="name">ir.actions.server.list.mcp</field>
|
||||
<field name="model">ir.actions.server</field>
|
||||
<field name="inherit_id" ref="base.view_server_action_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="usage" position="after">
|
||||
<field name="use_in_mcp"/>
|
||||
<field name="is_readonly" invisible="not use_in_mcp"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
63
ai_mcp/views/oauth_client_views.xml
Normal file
63
ai_mcp/views/oauth_client_views.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="oauth_client_view_form" model="ir.ui.view">
|
||||
<field name="name">oauth.client.form</field>
|
||||
<field name="model">oauth.client</field>
|
||||
<field name="arch" type="xml">
|
||||
<form delete="false">
|
||||
<sheet>
|
||||
<widget name="web_ribbon" title="Archived" bg_color="text-bg-danger" invisible="active"/>
|
||||
<div class="oe_title">
|
||||
<h1><field name="client_name" placeholder="e.g. Claude Desktop"/></h1>
|
||||
</div>
|
||||
<group>
|
||||
<field name="client_id"/>
|
||||
</group>
|
||||
<group string="Redirect URIs">
|
||||
<field name="redirect_uris" nolabel="1" colspan="2"
|
||||
placeholder="The redirect URIs one per line"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="oauth_client_view_list" model="ir.ui.view">
|
||||
<field name="name">oauth.client.list</field>
|
||||
<field name="model">oauth.client</field>
|
||||
<field name="arch" type="xml">
|
||||
<list delete="false" decoration-muted="not active">
|
||||
<field name="client_name"/>
|
||||
<field name="client_id"/>
|
||||
<field name="active"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="oauth_client_view_search" model="ir.ui.view">
|
||||
<field name="name">oauth.client.search</field>
|
||||
<field name="model">oauth.client</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="client_name"/>
|
||||
<field name="client_id"/>
|
||||
<filter name="inactive" string="Archived" domain="[('active', '=', False)]"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="oauth_client_action" model="ir.actions.act_window">
|
||||
<field name="name">OAuth Clients</field>
|
||||
<field name="res_model">oauth.client</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">Register a client</p>
|
||||
<p>
|
||||
A client registered here can generate access tokens through OAuth.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="oauth_client_menu" name="OAuth Clients"
|
||||
parent="base.menu_security" action="oauth_client_action" sequence="21"/>
|
||||
</odoo>
|
||||
86
ai_mcp/views/oauth_consent_templates.xml
Normal file
86
ai_mcp/views/oauth_consent_templates.xml
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- Standalone copy of web.login_layout rather than an inherit of it: the website module
|
||||
replaces web.login_layout's body with website.layout, which only renders when the endpoint
|
||||
declares `website=True` (it reads `website` out of the render values). A `primary` inherit
|
||||
would NOT escape that - a primary view is built from its parent's *combined* arch, so the
|
||||
website extension is baked into the copy too. The OAuth endpoints must stay
|
||||
website-agnostic, so this branches off web.frontend_layout directly. -->
|
||||
<template id="oauth_layout" name="OAuth Layout">
|
||||
<t t-set="head">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<t t-call-assets="web.assets_frontend" t-js="false"/>
|
||||
</t>
|
||||
<t t-call="web.layout" head="head" title="title" html_data="{'style': 'height: 100%;'}" body_classname.f="bg-100">
|
||||
<div class="container py-5">
|
||||
<div class="card border-0 mx-auto bg-100" style="max-width: 320px;">
|
||||
<div class="card-body">
|
||||
<div class="text-center pb-3 border-bottom mb-4">
|
||||
<img src="/web/binary/company_logo" alt="Logo" style="max-height:120px; max-width: 100%; width:auto"/>
|
||||
</div>
|
||||
<t t-out="0"/>
|
||||
<div class="text-center small mt-4 pt-3 border-top">
|
||||
<a href="https://www.odoo.com?utm_source=db&utm_medium=auth" target="_blank">Powered by <span>Odoo</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mx-auto" style="max-width: 320px;">
|
||||
<t t-out="footer_note"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="consent" name="OAuth Consent">
|
||||
<t t-set="title">Grant Access</t>
|
||||
<t t-set="footer_note">
|
||||
<p class="smaller text-muted text-break text-center mt-3 mb-0">
|
||||
You will be redirected to
|
||||
<span class="font-monospace" t-out="params['redirect_uri']"/>
|
||||
</p>
|
||||
</t>
|
||||
<t t-call="ai_mcp.oauth_layout" title="title" footer_note="footer_note">
|
||||
<h1 class="h4 text-center mb-4">Grant Access</h1>
|
||||
<p>
|
||||
<strong t-out="client_name"/> is requesting access to your Odoo
|
||||
account for
|
||||
<strong>MCP (Model Context Protocol)</strong>.
|
||||
</p>
|
||||
<form method="post" action="/oauth/authorize/submit_consent" target="_top" id="oauth_consent_form">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
||||
<t t-foreach="params.items()" t-as="param">
|
||||
<input type="hidden" t-att-name="param[0]" t-att-value="param[1]"/>
|
||||
</t>
|
||||
<div class="mt-4">
|
||||
<label class="form-label"><strong t-out="client_name"/> access expires after:</label>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<t t-foreach="durations" t-as="duration">
|
||||
<input type="radio" class="btn-check" name="duration"
|
||||
t-att-id="'oauth_duration_%s' % duration[0]"
|
||||
t-att-value="duration[0]"
|
||||
t-att-checked="'checked' if duration[0] == default_duration else None"/>
|
||||
<label class="btn btn-sm btn-outline-primary"
|
||||
t-att-for="'oauth_duration_%s' % duration[0]" t-out="duration[1]"/>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-grid gap-2 mt-4">
|
||||
<button type="submit" name="allow" value="true" class="btn btn-primary">Allow</button>
|
||||
<button type="submit" name="allow" value="false" class="btn btn-secondary">Deny</button>
|
||||
</div>
|
||||
</form>
|
||||
<div id="oauth_consent_spinner" class="position-fixed top-0 start-0 w-100 h-100 d-none align-items-center justify-content-center bg-white bg-opacity-75">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="visually-hidden">Authorizing...</span>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// Add a spinner to prevent users from clicking submit multiple times quickly which will show an error
|
||||
// "Unknown auth code" because the first request deleted the code already after it has been processed.
|
||||
document.getElementById("oauth_consent_form").addEventListener("submit", () => {
|
||||
document.getElementById("oauth_consent_spinner").classList.replace("d-none", "d-flex");
|
||||
});
|
||||
</script>
|
||||
</t>
|
||||
</template>
|
||||
</odoo>
|
||||
25
ai_mcp/views/res_config_settings_views.xml
Normal file
25
ai_mcp/views/res_config_settings_views.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.ai.mcp</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//block[@name='integration']" position="inside">
|
||||
<setting id="mcp_oauth" groups="base.group_system"
|
||||
string="MCP OAuth"
|
||||
help="Only the AI clients whose metadata URL (CIMD) is listed below can get OAuth tokens for your MCP server.">
|
||||
<field name="mcp_allowed_cimd_urls" class="o_mcp_allowed_cimd_urls" widget="text"
|
||||
placeholder="e.g. https://claude.ai/oauth/mcp-oauth-client-metadata"/>
|
||||
<div class="d-flex mt-2">
|
||||
<field name="mcp_enable_dcr" class="pe-2"/>
|
||||
<div>
|
||||
<label for="mcp_enable_dcr" string="Allow Dynamic Client Registration (DCR)"/>
|
||||
<div class="text-muted">Lets any MCP client register itself and request tokens.</div>
|
||||
</div>
|
||||
</div>
|
||||
</setting>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
63
ai_mcp/views/res_users_views.xml
Normal file
63
ai_mcp/views/res_users_views.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<odoo>
|
||||
<record id="view_users_form_mcp" model="ir.ui.view">
|
||||
<field name="name">res.users.form.inherit.mcp</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='api_keys']//span[hasclass('text-muted')]" position="replace">
|
||||
<span class="text-muted">
|
||||
Connect via RPC or MCP
|
||||
</span>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_users_form_simple_modif_mcp" model="ir.ui.view">
|
||||
<field name="name">res.users.preferences.form.inherit.mcp</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='api_keys']//span[hasclass('text-muted')]" position="replace">
|
||||
<span class="text-muted">
|
||||
Connect via RPC or MCP
|
||||
</span>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="form_res_users_key_show_mcp" model="ir.ui.view">
|
||||
<field name="name">API Key: show MCP</field>
|
||||
<field name="model">res.users.apikeys.show</field>
|
||||
<field name="inherit_id" ref="base.form_res_users_key_show"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@id='rpc_key_card']" position="attributes">
|
||||
<attribute name="invisible">scope == 'mcp'</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//div[@id='rpc_key_card']" position="after">
|
||||
<div id="mcp_key_card" class="card" invisible="scope != 'mcp'">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<strong>To connect via MCP, add these details to your AI Assistant's settings:</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<code>
|
||||
<p class="mb-1">
|
||||
<strong>Server URL: </strong>
|
||||
<field name="base_url" readonly="1" class="mb-0"/>/mcp
|
||||
</p>
|
||||
<p class="mb-1">
|
||||
<strong>Server Name: </strong>
|
||||
<span><Pick a name></span>
|
||||
</p>
|
||||
<p class="mb-1">
|
||||
<strong>Header: </strong>
|
||||
<span>Authorization: Bearer <field name="key" readonly="1" class="mb-0"/></span>
|
||||
</p>
|
||||
</code>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user