-
Notifications
You must be signed in to change notification settings - Fork 67
Closed
Labels
Description
Resource URI Parsing Bug
Bug Description
Resource operations that include query parameters are failing with "Unknown operation" errors. This affects 2 out of 5 resource operations, making search and browse resources unusable through the MCP protocol.
Current Behavior
When accessing resources with query parameters:
odoo://res.partner/search?limit=2→ Error: "Unknown operation: search?limit=2"odoo://res.partner/browse?ids=10,11→ Error: "Unknown operation: browse?ids=10,11"
Expected Behavior
odoo://res.partner/search?limit=2should return 2 partner recordsodoo://res.partner/browse?ids=10,11should return partner records with IDs 10 and 11- All query parameters should be properly parsed and passed to the handler
Root Cause Analysis
The URI regex pattern in uri_schema.py correctly captures the query string:
URI_PATTERN = re.compile(r"^odoo://([^/]+)/([^/?]+)(?:/(\d+))?(?:\?(.*))?$")However, the resource handler doesn't properly separate the operation from the query parameters before processing.
Steps to Reproduce
- Start the MCP server
- Use an MCP client to access:
odoo://res.partner/search?limit=2 - Observe the error: "Unknown operation: search?limit=2"
Before Implementation
-
Examine Current Code
- Review
uri_schema.py- check if URI parsing is actually the issue - Check resource handler registration in
resources.py - Verify FastMCP decorator behavior
- Test actual resource calls vs MCP client calls
- Review
-
Validate Root Cause
- Confirm this is a parsing issue, not a FastMCP limitation
- Check if query parameters are being captured correctly
- Verify error messages match expected pattern
-
Test Current Behavior
- Test direct resource handler calls
- Test through MCP client protocol
- Compare working vs failing operations
Proposed Investigation & Fix
Step 1: Investigate Current Implementation
# PSEUDOCODE - Check actual implementation first!
# Look for where URI parsing happens and how operations are extractedStep 2: Potential Fix Locations
# PSEUDOCODE - Verify actual code structure first!
# If operation parsing is the issue:
if "?" in operation_string:
clean_operation = operation_string.split("?")[0]
query_params = parse_query_parameters(operation_string)Affected Components
mcp_server_odoo/uri_schema.py- URI parsing logic- Resource handler that processes the parsed URI
- Integration tests that should catch this issue
Test Cases
After fix, verify:
-
odoo://res.partner/search?limit=2returns exactly 2 records -
odoo://res.partner/search?domain=[["is_company","=",true]]filters correctly -
odoo://res.partner/search?fields=name,email&limit=5returns 5 records with only name and email -
odoo://res.partner/browse?ids=10,11,12returns 3 specific records -
odoo://res.partner/count?domain=[["customer_rank",">",0]]counts filtered records - Error handling works for invalid query parameters
Impact
- Severity: High - 40% of resource operations are broken
- Users Affected: All users trying to use resource URIs with parameters
- Workaround: Use tools instead of resources (e.g.,
search_recordstool)
Additional Context
- Working resources:
record/{id},count,fields(no query parameters) - Failing resources:
search,browse(require query parameters) - All functionality works correctly through tools, only resources are affected