Skip to main content
Glama
seletz

MCP Odoo Shell

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)}"
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: the tool provides 'full access to Odoo models and environment', maintains 'persistent state between calls', and includes a warning that code 'can modify data' and should be used 'with appropriate caution'. This covers safety, statefulness, and permissions adequately.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the core purpose, followed by details on environment access, parameter/return notes, and warnings. Each sentence adds value (e.g., state persistence, safety warning), with no redundant information, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (executing arbitrary code in a database environment), no annotations, and no output schema, the description is largely complete: it covers purpose, behavior, parameters, and risks. However, it lacks details on error handling or output format specifics, which could be useful for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, so the description must compensate. It adds meaningful semantics: the 'code' parameter is 'Python code to execute in the Odoo context', and it notes the 'env' variable is available. This clarifies the parameter's purpose and context beyond the bare schema, though it could detail code format or examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Execute Python code') and resource ('in an Odoo shell environment'), distinguishing it from siblings like list_odoo_models (listing) and reset_odoo_shell (resetting). It specifies the environment has 'full access to Odoo models and environment', making the purpose explicit and distinct.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: for executing Python code in Odoo with ORM access. It mentions persistent state between calls, which implies usage for sequential operations. However, it doesn't explicitly state when NOT to use it or name alternatives (e.g., using other tools for non-code tasks), though the sibling tools suggest different purposes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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