Skip to main content
Glama
seletz
by seletz

execute_odoo_code

Execute Python code directly in an Odoo environment to access models, modify data, and perform database operations with persistent state between calls.

Instructions

Execute Python code in an Odoo shell environment with full access to Odoo models and environment. This tool provides direct access to the Odoo ORM and all loaded modules through the shell environment. The ``env`` variable is available for accessing models, and all standard Odoo shell features are accessible. :param code: Python code to execute in the Odoo context :type code: str :return: The output from executing the code :rtype: str .. note:: The shell maintains persistent state between calls, so variables defined in one execution will be available in subsequent calls. .. warning:: Code executed through this tool has full access to the Odoo database and can modify data. Use with appropriate caution.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • The main handler function for the 'execute_odoo_code' MCP tool. It is decorated with @mcp.tool() which handles registration and schema inference from the signature and docstring. The function executes the provided Python code in the persistent Odoo shell environment via the shell manager.
    @mcp.tool() def execute_odoo_code(code: str) -> str: """ Execute Python code in an Odoo shell environment with full access to Odoo models and environment. This tool provides direct access to the Odoo ORM and all loaded modules through the shell environment. The ``env`` variable is available for accessing models, and all standard Odoo shell features are accessible. :param code: Python code to execute in the Odoo context :type code: str :return: The output from executing the code :rtype: str .. note:: The shell maintains persistent state between calls, so variables defined in one execution will be available in subsequent calls. .. warning:: Code executed through this tool has full access to the Odoo database and can modify data. Use with appropriate caution. """ try: shell = get_shell_manager() result = shell.execute_code(code) return result except Exception as e: return f"Error executing Odoo code: {str(e)}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/seletz/mcp-odoo-shell'

If you have feedback or need assistance with the MCP directory API, please join our Discord server