Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 of 11 tasks
dovstern opened this issue May 6, 2025 · 1 comment · May be fixed by #218
Open
2 of 11 tasks
Assignees

Comments

@dovstern
Copy link

dovstern commented May 6, 2025

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.

@nirinchev nirinchev linked a pull request May 7, 2025 that will close this issue
@nirinchev nirinchev self-assigned this May 7, 2025
@nirinchev
Copy link
Collaborator

Thanks for reporting this - I was able to reproduce and hope to have a fix in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants