Labsco
zilliztech logo

Milvus

β˜… 233

from zilliztech

Search, Query and interact with data in your Milvus Vector Database.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredAdvanced setup

MCP Server for Milvus

The Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.

This repository contains a MCP server that provides access to Milvus vector database functionality.

MCP with Milvus

Supported Applications

This MCP server can be used with various LLM applications that support the Model Context Protocol:

  • Claude Desktop: Anthropic's desktop application for Claude
  • Cursor: AI-powered code editor with MCP support
  • Custom MCP clients: Any application implementing the MCP client specification

Verifying the Integration

To verify that Cursor has successfully integrated with your Milvus MCP server:

  1. Open Cursor Settings > MCP
  2. Check if "milvus", "milvus-sse", or "milvus-streamable-http" appear in the list (depending on the mode you have chosen)
  3. Confirm that the relevant tools are listed (e.g., milvus_list_collections, milvus_vector_search, etc.)
  4. If the server is enabled but shows an error, check the Troubleshooting section below

Available Tools

The server provides the following tools:

Search and Query Operations

  • milvus_text_search: Search for documents using full text search

    • Parameters:
      • collection_name: Name of collection to search
      • query_text: Text to search for
      • limit: The maximum number of results to return (default: 5)
      • output_fields: Fields to include in results
      • drop_ratio: Proportion of low-frequency terms to ignore (0.0-1.0) (default: 0.2)
  • milvus_vector_search: Perform vector similarity search on a collection

    • Parameters:
      • collection_name: Name of collection to search
      • vector: Query vector
      • vector_field: Field name for vector search (default: "vector")
      • limit: The maximum number of results to return (default: 5)
      • output_fields: Fields to include in results
      • filter_expr: Filter expression
      • metric_type: Distance metric (COSINE, L2, IP) (default: "COSINE")
      • radius: Optional lower bound for range search (default: None)
      • range_filter: Optional upper bound for range search (default: None)
  • milvus_hybrid_search: Perform hybrid search on a collection

    • Parameters:
      • collection_name: Name of collection to search
      • query_text: Text query for search
      • text_field: Field name for text search
      • vector: Vector of the text query
      • vector_field: Field name for vector search
      • limit: The maximum number of results to return (default: 5)
      • output_fields: Fields to include in results
      • filter_expr: Filter expression
      • sparse_radius: Optional lower bound for sparse range search (default: None)
      • sparse_range_filter: Optional upper bound for sparse range search (default: None)
      • dense_radius: Optional lower bound for dense range search (default: None)
      • dense_range_filter: Optional upper bound for dense range search (default: None)
  • milvus_text_similarity_search: Perform text similarity search on a collection

    Note: This tool is only supported in Milvus 2.6.0 and above. And you need to set the embedding function at the Milvus server. See Embedding Function for more details.

    • Parameters:
      • collection_name: Name of collection to search
      • query_text: Text query for similarity search
      • anns_field: Field name for text search
      • limit: The maximum number of results to return (default: 5)
      • output_fields: Fields to include in results
      • metric_type: Distance metric (COSINE, L2, IP) (default: "COSINE")
      • filter_expr: Optional filter expression
      • radius: Optional lower bound for range search (default: None)
      • range_filter: Optional upper bound for range search (default: None)
  • milvus_query: Query collection using filter expressions

    • Parameters:
      • collection_name: Name of collection to query
      • filter_expr: Filter expression (e.g. 'age > 20')
      • output_fields: Fields to include in results
      • limit: The maximum number of results to return (default: 10)

Collection Management

  • milvus_list_collections: List all collections in the database

  • milvus_create_collection: Create a new collection with quick setup or customized schema

    • Parameters:
      • collection_name: Name for the new collection
      • auto_id: whether to auto generate id, default to True
      • dimension: vector dimension, default to 768; for quick setup and will be ignored if field_schema is provided
      • primary_field_name: name of the primary field, default to "id"; for quick setup and will be ignored if field_schema is provided
      • vector_field_name: name of the vector field, default to "vector"; for quick setup and will be ignored if field_schema is provided
      • metric_type: metric type, default to "COSINE"; for quick setup and will be ignored if field_schema is provided
      • field_schema: List of field schema, each element is a dictionary with the following keys:
        • name: name of the field
        • type: type of the field
      • index_params: Optional list of index parameters, each element is a dictionary with the following keys:
        • field_name: name of the field to index
        • index_type: index type
        • **kwargs: other optional index parameters
      • other_kwargs: Additional keyword arguments for the collection creation
  • milvus_load_collection: Load a collection into memory for search and query

    • Parameters:
      • collection_name: Name of collection to load
      • replica_number: Number of replicas (default: 1)
  • milvus_release_collection: Release a collection from memory

    • Parameters:
      • collection_name: Name of collection to release
  • milvus_get_collection_info: Lists detailed information like schema, properties, collection ID, and other metadata of a specific collection.

    • Parameters:
      • collection_name: Name of the collection to get detailed information about

Data Operations

  • milvus_insert_data: Insert data into a collection

    • Parameters:
      • collection_name: Name of collection
      • data: Dictionary mapping field names to lists of values
  • milvus_delete_entities: Delete entities from a collection based on filter expression

    • Parameters:
      • collection_name: Name of collection
      • filter_expr: Filter expression to select entities to delete

Environment Variables

  • MILVUS_URI: Milvus server URI (can be set instead of --milvus-uri)
  • MILVUS_TOKEN: Optional authentication token
  • MILVUS_DB: Database name (defaults to "default")

Development

To run the server directly:

Copy & paste β€” that's it
uv run server.py --milvus-uri http://localhost:19530

Examples

Using Claude Desktop

Example 1: Listing Collections

Copy & paste β€” that's it
What are the collections I have in my Milvus DB?

Claude will then use MCP to check this information on your Milvus DB.

Copy & paste β€” that's it
I'll check what collections are available in your Milvus database.

Here are the collections in your Milvus database:

1. rag_demo
2. test
3. chat_messages
4. text_collection
5. image_collection
6. customized_setup
7. streaming_rag_demo

Example 2: Searching for Documents

Copy & paste β€” that's it
Find documents in my text_collection that mention "machine learning"

Claude will use the full-text search capabilities of Milvus to find relevant documents:

Copy & paste β€” that's it
I'll search for documents about machine learning in your text_collection.

> View result from milvus-text-search from milvus (local)

Here are the documents I found that mention machine learning:
[Results will appear here based on your actual data]

Using Cursor

Example: Creating a Collection

In Cursor, you can ask:

Copy & paste β€” that's it
Create a new collection called 'articles' in Milvus with fields for title (string), content (string), and a vector field (128 dimensions)

Cursor will use the MCP server to execute this operation:

Copy & paste β€” that's it
I'll create a new collection called 'articles' with the specified fields.

Collection 'articles' has been created successfully with the following schema:
- title: string
- content: string
- vector: float vector[128]