Skip to main content
Glama
tuanle96

Odoo MCP Server

list_models

Read-onlyIdempotent

Retrieve a list of Odoo models filtered by name. Use this tool to explore available models in your Odoo instance.

Instructions

List Odoo models with optional name filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `list_models` tool is registered via @mcp.tool decorator on the `list_models` function. It is the MCP tool definition with description, annotations (READ_ONLY_TOOL), structured output, and the handler logic that queries Odoo models with optional name filtering.
    @mcp.tool(
        description="List Odoo models with optional name filtering",
        annotations=READ_ONLY_TOOL,
        structured_output=True,
    )
    def list_models(
        ctx: Context,
        query: Optional[str] = None,
        limit: int = 100,
    ) -> Dict[str, Any]:
        """
        List available Odoo model technical names and display names.
    
        Prefer this read-only tool over execute_method when discovering models.
        """
        odoo = ctx.request_context.lifespan_context.odoo
        try:
            limit = clamp_limit(limit, maximum=500)
            models = odoo.get_models()
            if "error" in models:
                return {"success": False, "error": models["error"]}
    
            model_names = models.get("model_names", [])
            models_details = models.get("models_details", {})
            if query:
                query_lower = query.lower()
                model_names = [
                    model_name
                    for model_name in model_names
                    if query_lower in model_name.lower()
                    or query_lower
                    in str(models_details.get(model_name, {}).get("name", "")).lower()
                ]
    
            records = [
                {
                    "model": model_name,
                    "name": models_details.get(model_name, {}).get("name", ""),
                }
                for model_name in model_names[:limit]
            ]
            return {"success": True, "count": len(records), "result": records}
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Tool annotations: READ_ONLY_TOOL (readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=True) and structured_output=True. Parameters: ctx (Context), query (Optional[str]), limit (int=100). Returns Dict[str, Any].
    description="List Odoo models with optional name filtering",
    annotations=READ_ONLY_TOOL,
    structured_output=True,
  • The `OdooClient.get_models()` method is the underlying helper that fetches model names and details from the Odoo instance. It is called by the `list_models` handler via `odoo.get_models()`.
    def get_models(self) -> dict[str, Any]:
        """
        Get a list of all available models in the system
    
        Returns:
            List of model names
    
        Examples:
            >>> client = OdooClient(url, db, username, password)
            >>> models = client.get_models()
            >>> print(len(models))
            125
            >>> print(models[:5])
            ['res.partner', 'res.users', 'res.company', 'res.groups', 'ir.model']
        """
        try:
            # First search for model IDs
            model_ids = self._execute("ir.model", "search", [])
    
            if not model_ids:
                return {
                    "model_names": [],
                    "models_details": {},
                    "error": "No models found",
                }
    
            # Then read the model data with only the most basic fields
            # that are guaranteed to exist in all Odoo versions
            result = self._execute("ir.model", "read", model_ids, ["model", "name"])
    
            # Extract and sort model names alphabetically
            models = sorted([rec["model"] for rec in result])
    
            # For more detailed information, include the full records
            models_info = {
                "model_names": models,
                "models_details": {
                    rec["model"]: {"name": rec.get("name", "")} for rec in result
                },
            }
    
            return models_info
        except Exception as e:
            print(f"Error retrieving models: {str(e)}", file=sys.stderr)
            return {"model_names": [], "models_details": {}, "error": str(e)}
  • In `_recommended_fit_gap_calls`, `list_models` is referenced as a recommended next tool call to suggest model discovery after a fit/gap classification.
    def _recommended_fit_gap_calls(
        requirement: str, classification: str
    ) -> list[dict[str, Any]]:
        calls = [
            {
                "tool": "list_models",
                "arguments": {
                    "query": requirement.split()[0] if requirement.split() else None
                },
            }
        ]
        if classification in {"studio", "custom_module", "unknown"}:
            calls.append(
                {
                    "tool": "inspect_model_relationships",
                    "arguments": {"model": "res.partner", "use_live_metadata": True},
                }
            )
        return calls
  • In `business_pack_report`, `list_models` is referenced as a recommended next call for unpacking expected model prefixes when models are missing.
        {"tool": "list_models", "arguments": {"query": model.split(".")[0]}}
        for model in expected_models[:3]
    ],
Behavior3/5

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

Annotations already declare readOnlyHint, destructiveHint, idempotentHint, and openWorldHint. The description adds no new behavioral insights beyond the parameter hint, which is already implied by annotations.

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

Conciseness4/5

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

Single sentence is concise and front-loaded with the main action. However, it could be slightly expanded without losing brevity.

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

Completeness2/5

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

The description is minimal; it does not clarify how the query filter works, whether limiting is supported, or that the output schema lists model names. With no annotations on parameters, the description feels incomplete for effective tool selection.

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

Parameters2/5

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

Schema description coverage is 0%. The description mentions 'optional name filtering' (query parameter) but does not explain filter syntax or the limit parameter, leaving ambiguity for the agent.

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 verb 'List' and resource 'Odoo models', with the optional name filtering to distinguish from related tools like get_model_fields or search_records.

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

Usage Guidelines3/5

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

No explicit guidance on when to use vs alternatives. The phrase 'optional name filtering' implies common use case but lacks exclusions or context for when not to use.

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/tuanle96/mcp-odoo'

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