mcp-pymilvus-code-generate-helper

mcp-pymilvus-code-generate-helper

An MCP server that retrieves relevant code snippets and documents to assist in generating pymilvus code, converting between ORM and client, and translating Milvus code between programming languages.

Category
访问服务器

README

mcp-pymilvus-code-generate-helper

A Model Context Protocol server that retrieves relevant code snippets or documents to help generating pymilvus code.

Architecture

Example

Prerequisites

Before using this MCP server, ensure you have:

  • Python 3.10 or higher
  • A running Milvus instance (local or remote)
  • uv installed (recommended for running the server)

Usage

The recommended way to use this MCP server is to run it directly with uv without installation. This is how both Claude Desktop and Cursor are configured to use it in the examples below. The server now support both sse and stdio:

SSE

Running the Server

uv run src/mcp_pymilvus_code_generate_helper/sse_server.py
# mcp server will connect to local milvus server(http://localhost:19530) by default if no milvus_uri is provided
# to connect to a remote milvus server, you can specify the milvus_uri like this:
# uv run src/mcp_pymilvus_code_generate_helper/sse_server.py --milvus_uri http://<your-server-ip>:<your-server-port>

Usage with Cursor

  1. Go to Cursor > Preferences > Cursor Settings > MCP
  2. Click on the + Add New MCP Server button
  3. Fill out the form:
    • Name: pymilvus-code-generate-helper (or any name you prefer)
    • Type: Select sse
    • Server URL: http://localhost:23333/milvus-code-helper/sse (replace with your server's IP address)
  4. Click Save

You can also directly edit mcp.json as below:

{
  "mcpServers": {
    "pymilvus-code-generate-helper": {
      "url": "http://localhost:23333/milvus-code-helper/sse"
    }
  }
}

Usage with Claude Desktop

⚠️ Claude desktop is currently limited in its ability to connect to remote MCP servers

STDIO

Running the Server

uv run src/mcp_pymilvus_code_generate_helper/stdio_server.py
# mcp server will connect to local milvus server(http://localhost:19530) by default if no milvus_uri is provided
# to connect to a remote milvus server, you can specify the milvus_uri like this:
# uv run src/mcp_pymilvus_code_generate_helper/stdio_server.py --milvus_uri http://<your-server-ip>:<your-server-port>

Usage with Cursor

  1. Go to Cursor > Preferences > Cursor Settings > MCP
  2. Click on the + Add New MCP Server button
  3. Fill out the form:
    • Name: pymilvus-code-generate-helper (or any name you prefer)
    • Type: Select stdio
    • Command: /PATH/TO/uv --directory /path/to/mcp-pymilvus-code-generator run src/mcp_pymilvus_code_generate_helper/stdio_server.py
  4. Click Save

You can also directly edit mcp.json as below:

{
  "mcpServers": {
    "pymilvus-code-generate-helper": {
      "command": "/PATH/TO/uv",
      "args": [
        "--directory",
        "/path/to/mcp-pymilvus-code-generator",
        "run",
        "src/mcp_pymilvus_code_generate_helper/stdio_server.py",
        "--milvus_uri",
        "http://localhost:19530"
      ],
      "env": {
        "OPENAI_API_KEY": "YOUR OPENAI API KEY HERE"
      }
    }
  }
}

Usage with Claude Desktop

  1. Install Claude Desktop from https://claude.ai/download
  2. Open your Claude Desktop configuration:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  3. Add the following configuration:
{
  "mcpServers": {
    "pymilvus-code-generate-helper": {
      "command": "/PATH/TO/uv",
      "args": [
        "--directory",
        "/path/to/mcp-server-milvus/src/mcp_server_milvus",
        "run",
        "src/mcp_pymilvus_code_generate_helper/stdio_server.py",
        "--milvus_uri",
        "http://localhost:19530"
      ], 
      "env": {
        "OPENAI_API_KEY": "YOUR OPENAI API KEY HERE"
      }
    }
  }
}
  1. Restart Claude Desktop

⚠️ Note: Remember to set the OPENAI_API_KEY environment variable

User Rule

Here’s an additional instruction you can add for users to improve tool invocation accuracy in Cursor: To ensure more accurate tool invocation when using Cursor, you can set a User Rule as follows:

Go to Cursor > Preferences > Cursor Settings > Rules, and add the following to your User Rule. Here is an example user rule that has proven effective for your reference:

Always use tools in milvus code generation, convertion and translation tasks.
1.milvus code generation.
- Can you help me generate a sample pymilvus code to hybrid search?
Call milvus_pypmilvus_code_generate_helper

2.milvus client and orm code convertion.
- Can you help me translate the following orm code to create collection to pymilvus client?
- <code context> translate to orm
Call milvus_orm_client_code_convert_helper

3.milvus code translation between different programming language.
- Can you help me translate the following milvus code to java.
- <code context> translate to nodejs
Call milvus_code_translate_helper

If you meet the milvus code translation between different programming language task or convert between orm and milvus client, you must identify all API calls of the selected codes related to the Milvus SDK. The "query" argument should be a list of API call descriptions.

Here is the examples:
Example 1
Context:
```
from pymilvus import MilvusClient, DataType

CLUSTER_ENDPOINT = "http://localhost:19530"
TOKEN = "root:Milvus"

# 1. Set up a Milvus client
client = MilvusClient(
    uri=CLUSTER_ENDPOINT,
    token=TOKEN 
)

# 2. Create a collection in quick setup mode
client.create_collection(
    collection_name="quick_setup",
    dimension=5
)

res = client.get_load_state(
    collection_name="quick_setup"
)

print(res)
```
Parsed arguments of tool using:
["create_collection", "get_load_state"]

Example 2
Context:
```
from pymilvus import MilvusClient

client = MilvusClient(uri="http://localhost:19530", token="root:Milvus")

if not client.has_collection("my_collection"):
    client.create_collection(collection_name="my_collection", dimension=128)

client.insert(
    collection_name="my_collection",
    data=[{"vector": [0.1, 0.2, 0.3, 0.4, 0.5]}]
)

client.flush(["my_collection"])
```
Parsed arguments of tool using:
["has_collection", "create_collection", "insert", "flush"]

Feel free to adjust or add more rules as needed for your workflow.

Available Tools

The server provides the following tools:

  • milvus-pypmilvus-code-generate-helper: Find related pymilvus code/documents to help generating code from user input in natural language

    • Parameters:
      • query: User query for generating code
  • milvus-orm-client-code-convert-helper: Find related orm and pymilvus client code/documents to help converting orm code to pymilvus client (or vice versa)

    • Parameters:
      • query: A string of Milvus API names in list format from user query and code context to translate between orm and milvus client
  • milvus-code-translate-helper: Find related documents and code snippets in different programming languages for milvus code translation

  • Parameters:

    • query: A string of Milvus API names in list format to translate from one programming language to another (e.g., ['create_collection', 'insert', 'search'])
    • source_language: Source programming language (e.g., 'python', 'java', 'go', 'csharp', 'node', 'restful')
    • target_language: Target programming language (e.g., 'python', 'java', 'go', 'csharp', 'node', 'restful')

⚠️ Note: You don't need to specify the tool name or parameters in the query. Just interact as you normally would when coding with LLM: state your requirements and select the relevant code context. MCP will automatically select the appropriate tool based on the query content and prepare corresponding parameters.

Docker

You can also build and run milvus code helper MCP server with Docker

Build the Docker Image

docker build -t milvus-code-helper .

Run the Docker Container

docker run -p <YOUR_HOST_IP>:<YOUR_HOST_PORT>:23333 -e OPENAI_API_KEY -e MILVUS_URI=<YOUR_MILVUS_URI> -e MILVUS_TOKEN=<YOUR_MILVUS_TOKEN> milvus-code-helper

Contribution

Contributions are welcome! If you have ideas for improving the retrieve result, please submit a pull request or open an issue.

License

This project is licensed under the MIT License.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选