-
Notifications
You must be signed in to change notification settings - Fork 76
Fix/list collection return empty check test #33
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
Fix/list collection return empty check test #33
Conversation
…匹配,同时添加了对重复ID的检查和返回值的处理。
…tion: if the database is empty, return a specific marker ["NO_COLLECTIONS_FOUND"] to improve safety.
…tion_return_empty
|
Fix: Empty Collection List Handling This PR modifies the chroma_list_collections function to return a special marker value of ["NO_COLLECTIONS_FOUND"] instead of an empty list when no collections exist in the database. When the Chroma database is first initialized and empty, the previous implementation returned an empty list ([]). In practice, we discovered that AI clients do not correctly interpret this empty result, leading to confusion and repetitive API calls as they try to determine if there was an error or if the result truly means "no collections exist." By returning a special marker value (["NO_COLLECTIONS_FOUND"]) instead of an empty list, we provide a clear and explicit indication that: This improves the interaction between AI systems and the Chroma database, reducing unnecessary API calls and making the response more semantically meaningful to AI clients. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did a little more digging since it seems strange that all mcp servers wouldn’t be able to have optional parameters. i can understand that maybe Optional is not directly supported. It turns out you have to specify optional parameters verbosely, ie limit: int | None
see here
https://github.com/modelcontextprotocol/servers/blob/dc7e4286d6145640fb88c2dceaa109a6ecaeee1e/src/fetch/src/mcp_server_fetch/server.py#L66
then, you do not need to make edits to the limit and offset tests.
Thank you for your continued work on this! will definitely merge and release this when it’s done, just want to make sure it is in a good state
|
hi @leomonan just wanted to follow up on this, as i do want to give you the proper credit as a contributor for these changes. Instead of removing Optional entirely, if you could replace it with with | None as I described above we can merge this in. |
Sure, That sounds like a good idea. |
Please see discusion in:
#31
Summary
This PR addresses two main issues in the chroma-mcp implementation:
Changes
Type Annotation Fixes
Document ID Validation Improvements
Auto-generated IDs Removal
Motivation
When using chroma-mcp with Cursor, I encountered parameter recognition issues where the MCP framework would fail to properly process Optional-typed parameters. Additionally, the automatic ID generation was causing confusion and potential data loss when users weren't explicitly providing document identifiers.
These changes improve reliability and consistency across different environments while enforcing better practices for document management.
Testing
Tested in multiple Cursor environments to verify parameter recognition works correctly, and that the ID validation properly enforces the required constraints.