Skip to content

Conversation

@leomonan
Copy link
Contributor

@leomonan leomonan commented May 15, 2025

Improve chroma_add_documents and fix type annotation issues

Summary

This PR addresses two main issues in the chroma-mcp implementation:

  1. Removes Optional type annotations that were causing parameter recognition problems in Cursor MCP
  2. Enhances chroma_add_documents function to properly validate document IDs

Changes

Type Annotation Fixes

  • Removed all Optional type annotations from parameters across the codebase
  • Parameters now use direct type hints with default values (e.g., Dict = None instead of Optional[Dict] = None)
  • This resolves issues where Cursor MCP would incorrectly treat parameters as undefined, particularly with metadata parameters

Document ID Validation Improvements

  • Added strict validation for the ids parameter in chroma_add_documents
  • Ensures that ids cannot be null or empty strings
  • This prevents the limitation where a collection could only store a single document when IDs weren't properly provided

Auto-generated IDs Removal

  • Removed code that automatically generated IDs
  • Forces explicit ID provision to ensure better document management and avoid unexpected behavior
  • Improves consistency with Chroma's expected usage patterns

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.

@leomonan leomonan changed the title Feat/improve chroma add documents Feat/fix chroma add documents May 15, 2025
@leomonan leomonan changed the title Feat/fix chroma add documents Fix chroma add documents and May 15, 2025
@leomonan leomonan changed the title Fix chroma add documents and Fix chroma add documents and fix Optional parameters undefined issue May 15, 2025
Copy link
Collaborator

@jairad26 jairad26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@jairad26
Copy link
Collaborator

closing in favor of #32

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 this pull request may close these issues.

2 participants