Skip to content

[Bug]: ObjectId query syntax in fails as a filter when querying in MCP tools with "unknown operator: $oid" error #211

Closed
@dovstern

Description

@dovstern

App

  • Cursor
  • Windsurf
  • VSCode
  • VSCode Insiders
  • Claude Desktop
  • Other

Affected Models (if applicable)

  • Claude 3.5 Sonnet
  • Claude 3.7 Sonnet
  • GPT-4a
  • o4-mini
  • Other

Bug Description

Title:
ObjectId query syntax fails in MCP tools with "unknown operator: $oid" error
Description:
Problem
When attempting to query documents using ObjectId references in MongoDB MCP tools, queries consistently fail with the error "unknown operator: $oid". This occurs when using standard MongoDB syntax for querying by ObjectId.
Steps to reproduce
Attempt to query a collection using the MCP MongoDB tools
Use a filter containing an ObjectId reference with standard syntax:
Apply to mcp.json
}
Observe the error: "Error running find: unknown operator: $oid"
Failed queries
The following query patterns all produce the same error:
{"_id": {"$oid": "..."}}
{"userId": {"$oid": ""..."}}
{"_id": {"$eq": {"$oid": ""..."}}}
Using the string format without $oid operator does not retrieve documents:
{"_id": ""..."}
Expected behavior
The MCP tools should properly translate the ObjectId query syntax to the appropriate MongoDB query, allowing users to query documents by their ObjectId fields using standard MongoDB syntax.
Environment
MCP tools in Cursor/AI assistance environment
Querying a MongoDB database with collections containing ObjectId fields
Impact
This issue significantly impacts the ability to query documents by their IDs, which is a fundamental operation when working with MongoDB.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions