-
Notifications
You must be signed in to change notification settings - Fork 24
[Bug]: Issue with the count #202
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
Comments
I was also seeing this behavior but was able to fix it sometimes by just manually telling my model to call it differently. Essentially .find is expecting a filter object with a property name of 'filter', and .count is expecting it with a property name of 'query'. My model was defaulting to using the 'filter' property name when using .count, and so the server logic didn't grab the filter object properly and just returned the result of .count with no filter object. I tried renaming the expected property name but my fix didn't work. Additional Info: I'm using a custom mcp client (backed by Azure openAI-provided gpt-4.1 model) |
I'm having the same issue. I'll see if I can override the tool spec |
I did try that but had no luck @Phenome - I'll be looking out for an update though! It also looks like collections.count is deprecated in favor of .countDocuments/.estimatedDocumentCount (although that API also uses 'query' so this issue would remain) - wondering if anyone has insight? |
Hmmm weird. The output of the tools generated by the mcp, for {
description: "Gets the number of documents in a MongoDB collection",
parameters: {
_type: undefined,
jsonSchema: {
type: "object",
properties: {
database: {
type: "string",
description: "Database name",
},
collection: {
type: "string",
description: "Collection name",
},
query: {
type: "object",
additionalProperties: {},
description: "The query filter to count documents. Matches the syntax of the filter argument of db.collection.count()",
},
},
required: [ "database", "collection" ],
additionalProperties: false,
$schema: "http://json-schema.org/draft-07/schema#",
},
validate: undefined,
},
} However, my modal is calling "count" with "filter" instead of "query". |
This might be the wrong track, but I tried this and no luck - trying to just coerce the filter to be pulled in to the execute args regardless of name:
So far what I have below is the only method that worked - manually setting the property name in the model system instructions: "For ALL COUNT CALLS, ALWAYS use the property name "query" (not "filter") to specify search criteria, regardless of standard MongoDB conventions." |
Thanks for raising this! We're looking into a potential solution with #254. |
App
Affected Models (if applicable)
Bug Description
Hello Team,
We've tried to use all the tools built. The
count
tool is not working as thefind
. With the tool of find, we are able to extract the information, but the count is always returning the complete number of records from the collection. Please verify this & share me if anyone else is facing the same issue.Note: Tried with all different kinds of prompting & the proof is that find is working well.
Thank You.
The text was updated successfully, but these errors were encountered: