关于 mcp-tool-server-milvus
mcp-tool-server-milvus 将 MCP 客户端连接到 Milvus 向量数据库,用于插入和搜索文本。它会创建默认数据库和集合,并可通过环境变量配置名称。
主要功能
- 01插入单条文本
- 02批量插入文本
- 03搜索已存储文本
- 04配置数据库和集合名称
适用场景
- 01将文本存入 Milvus 集合
- 02按查询搜索文本记录
- 03为 MCP 工具设置默认集合
MCP 相关
通过 Streamable HTTP 向 MCP 客户端提供 insert、insert-multiple 和 search 三种工具。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
mcp-tool-server-milvus
一个 MCP 服务,提供用于向 Milvus 向量数据库插入数据和查询数据的工具。
默认情况下,服务会创建一个数据库和一个集合。插入和搜索工具会对默认数据库和集合进行操作。你可以使用以下环境变量配置数据库和集合:
MILVUS_DB:Milvus 数据库的名称。默认为mcp_db。如果数据库不存在,则会创建。MILVUS_COLLECTION:Milvus 集合的名称。默认为full_text_search。 如果集合不存在,则会创建。
运行 MCP 服务
使用 docker compose 启动服务
docker compose up -d
这会启动一个以 Milvus 为后端的 MCP 服务。服务将在 http://localhost:3000 上运行。
使用 MCP-Cli 与 MCP 服务交互
你也可以使用 mcp-cli 命令行工具与 MCP 服务交互。运行以下命令即可使用:
npx @wong2/mcp-cli --url http://localhost:3000/mcp
这会通过可流式传输的 HTTP 连接到 MCP 服务。它会提示你查看可用工具列表,并允许你使用 JSON 参数调用这些工具。例如:
$ npx @wong2/mcp-cli --url http://localhost:3000/mcp
✔ Connected, server capabilities: tools
? Pick a primitive ›
❯ tool(insert-multiple) - insert the texts into the collection
tool(insert) - insert the text into the collection
tool(search) - search the text in the collection
你可以使用光标浏览列表并选择所需的原语。随后,系统会提示你输入所选原语的参数。
- 对于
tool(insert-multiple),你可以输入字符串的 JSON 数组作为参数。不过,MCP-Cli 目前尚不支持此操作。你可以使用@modelcontextprotocol/sdk包中的simpleStreamableHttp示例与此工具 API 交互。 - 对于
tool(insert),你可以输入一个字符串作为参数,将单个文本字符串插入集合。 - 对于
tool(search),你可以输入一个字符串作为参数,在集合中搜索文本并返回匹配结果。
使用 simpleStreamableHttp 示例
你可以使用 MCP typescript-sdk 仓库中的简单流式 HTTP 客户端与 MCP 服务交互: https://github.com/modelcontextprotocol/typescript-sdk.git
使用方法如下:
git clone https://github.com/modelcontextprotocol/typescript-sdk.git
cd typescript-sdk
npm install
npx tsx src/examples/client/simpleStreamableHttp.ts
默认情况下,客户端会连接到 http://localhost:3000,你应该会看到以下输出:
MCP Interactive Client
=====================
Connecting to http://localhost:3000/mcp...
Transport created with session ID: 44dff10f-89bc-4965-b280-e1df3eb56a51
Connected to MCP server
Available commands:
connect [url] - Connect to MCP server (default: http://localhost:3000/mcp)
disconnect - Disconnect from server
terminate-session - Terminate the current session
reconnect - Reconnect to the server
list-tools - List available tools
call-tool <name> [args] - Call a tool with optional JSON arguments
greet [name] - Call the greet tool
multi-greet [name] - Call the multi-greet tool with notifications
start-notifications [interval] [count] - Start periodic notifications
list-prompts - List available prompts
get-prompt [name] [args] - Get a prompt with optional JSON arguments
list-resources - List available resources
help - Show this help
quit - Exit the program
>
接下来你将进入交互式提示模式。要连接到其他 MCP 服务,只需输入 connect [url] 并按回车键。
使用 list-tools 命令列出所有可用工具。共有 3 个可用工具:
> list-tools
Available tools:
- insert-multiple: insert the texts into the collection
- insert: insert the text into the collection
- search: search the text in the collection
使用 call-tool <name> 命令调用工具,并可选择提供 JSON 参数。例如,以下是调用 insert-multiple 工具将多条文本插入集合的方法:
> call-tool insert-multiple {"texts": ["call-tool <name> [args]: Call a tool with optional JSON arguments", "list-prompts: List available prompts"]}
Calling tool 'insert-multiple' with args: {
texts: [
'call-tool <name> [args]: Call a tool with optional JSON arguments',
'list-prompts: List available prompts'
]
}
Tool result:
2
数字 2 表示插入操作已向集合中插入两条记录。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。