Skip to content

Odoo MCP: Query parameters in URI not properly handled, treated as model name #2744

@DieterReinert

Description

@DieterReinert

Bug Report: Odoo MCP Query Parameter Handling

Issue Description

The Odoo MCP server does not properly handle query parameters in resource URIs. When query parameters are included in the URI (e.g., ?limit=5&order=create_date desc), they are incorrectly treated as part of the model name, causing the request to fail.

Steps to Reproduce

  1. Use the fetch_mcp_resource function with an Odoo URI containing query parameters
  2. Example URI: odoo://search/helpdesk.ticket?limit=5&order=create_date desc
  3. The request fails with an error indicating the model doesn't exist

Actual Behavior

{
  "error": "<Fault warning -- UserError\n\nObject helpdesk.ticket?limit=5&order=create_date%20desc bestaat niet: ''>", 
  "model": "helpdesk.ticket?limit=5&order=create_date%20desc"
}

The error shows that the entire string including query parameters is being treated as the model name.

Expected Behavior

The MCP should:

  1. Parse the URI correctly, separating the base path from query parameters
  2. Use the base model name (helpdesk.ticket) for the Odoo search
  3. Apply the query parameters as search constraints (limit, order, filters, etc.)

Impact

This limitation significantly reduces the usefulness of the Odoo MCP because:

  • Users cannot limit results (leading to potentially large responses)
  • Users cannot sort results
  • Users cannot apply filters beyond the basic domain
  • The MCP becomes less efficient for practical use cases

Attempted Workaround

Currently, users must use the basic URI without parameters and handle filtering/limiting in client code, which is less efficient.

Recommendations for Improvement

1. Implement Query Parameter Parsing

The MCP should parse URIs to extract and handle common query parameters:

odoo://search/helpdesk.ticket?limit=5&order=create_date desc&domain=[('stage_id','!=','Solved')]

2. Support Standard Odoo Search Parameters

  • limit: Maximum number of records to return
  • offset: Number of records to skip
  • order: Sort order (e.g., create_date desc, name asc)
  • domain: Odoo domain filters in list format
  • fields: Specific fields to return (for performance)

3. Add Domain Builder Helpers

Consider supporting common filter patterns:

  • ?status=open[('stage_id.fold', '=', False)]
  • ?created_after=2025-01-01[('create_date', '>=', '2025-01-01')]
  • ?assigned_to=user_id[('user_id', '=', user_id)]

4. Enhanced Resource URIs

Examples of improved URI patterns:

odoo://search/helpdesk.ticket?limit=10&order=priority desc,create_date desc
odoo://search/res.partner?domain=[('is_company','=',True)]&fields=name,email,phone
odoo://count/sale.order?domain=[('state','in',['sale','done'])]

5. Error Handling Improvements

  • Provide clearer error messages when query parameters are malformed
  • Validate domain syntax before sending to Odoo
  • Return helpful suggestions for common mistakes

6. Documentation Enhancement

Update the MCP documentation to include:

  • Supported query parameters for each resource type
  • Domain syntax examples
  • Common use case patterns
  • Performance considerations

Technical Details

  • MCP Server: user-odoo
  • Resource Type: All search resources (search_helpdesk, search_partners, etc.)
  • Error Type: Model name parsing issue
  • Client: Claude with MCP support

Additional Context

This issue affects all search-based resources in the Odoo MCP and significantly limits the practical utility of the server for real-world use cases where filtered, limited, and sorted results are essential.

The current workaround of fetching all records and filtering client-side is inefficient and doesn't scale well for large datasets.

Example Error Log

Attempted URI: odoo://search/helpdesk.ticket?limit=5&order=create_date desc
Error: Object helpdesk.ticket?limit=5&order=create_date%20desc bestaat niet
Expected: Parse as model='helpdesk.ticket' with params={'limit': 5, 'order': 'create_date desc'}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions