Baidu Vector Database MCP Server

Baidu Vector Database MCP Server

A server that provides access to Baidu Cloud Vector Database functionality through the Model Context Protocol, enabling LLM applications to perform vector searches and database operations via natural language.

Category
访问服务器

Tools

create_vector_index

Create a vector index on a vector type field in the Mochow instance. Args: table_name (str): Name of the table. index_name (str): Name of the index. field_name (str): Name of the vector field. index_type (str): Type of vector index. Supported values are "HNSW", "HNSWPQ", "HNSWSQ". metric_type (str): Distance metric. Supported values are "L2", "COSINE", "IP". params (Optional[dict[str, Any]]): Additional vector index parameters. Returns: str: A message indicating the success of index creation.

describe_index

Describe index details in the Mochow instance. Args: table_name (str): Name of the table. index_name (str): Name of the index to describe. Returns: str: A string containing the details of the index.

rebuild_vector_index

Rebuild the vector index in the Mochow instance. Args: table_name (str): Name of the table. index_name (str): Name of the vector index to rebuild. Returns: str: A message indicating the success of index rebuild initiation.

delete_table_rows

Delete rows with a filter expression in the Mochow instance. Args: table_name (str): Name of the table. filter_expr (str): Filter expression to select data to delete. Returns: str: A message indicating the success of data deletion.

drop_vector_index

Drop the vector index in the Mochow instance. Args: table_name (str): Name of the table. index_name (str): Name of the vector index to drop. Returns: str: A message indicating the success of index drop.

select_table_rows

Select rows with a filter expression in the Mochow instance. Args: table_name (str): Name of the table. filter_expr (str): Filter expression to select data. Defaults to None. limit (int): Maximum number of results. Defaults to 10. output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None. Returns: str: A string containing the selected rows.

vector_search

Perform vector similarity search combining vector similarity and scalar attribute filtering in the Mochow instance. Args: table_name (str): Name of the table to search. vector (list[float]): Search vector. vector_field (str): Target field containing vectors to search. Defaults to "vector". limit (int): Maximum number of results. Defaults to 10. output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None. filter_expr (Optional[str]): Filter expression for scalar attributes. Defaults to None. params: Additional vector search parameters Returns: str: A string containing the vector search results.

list_databases

List all databases in the Mochow instance. Returns: str: A string containing the names of all databases.

create_database

Create a database in the Mochow instance. Args: database_name (str): Name of the database. Returns: str: A message indicating the success of database creation.

use_database

Switch to a different database. Args: database_name (str): Name of the database to use. Returns: str: A message indicating the success of the database switch.

list_tables

List all tables in the current database. Returns: str: A string containing the names of all tables.

describe_table

Describe table details in the Mochow instance. Args: table_name (str): Name of the table to describe. Returns: str: A string containing the details of the table.

stats_table

Get the table statistics in the Mochow instance. Args: table_name (str): Name of the table to get statistics. Returns: str: A string containing the table statistics.

fulltext_search

Perform full text search combining BM25 similarity and scalar attribute filtering in the Mochow instance. Args: table_name (str): Name of the table to search. index_name (str): Name of the inverted index to perform full text search. search_text (str): Text to search. limit (int): Maximum number of results. Defaults to 10. output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None. Returns: str: A string containing the full text search results.

README

百度向量数据库MCP Server

本代码仓库包含一个 MCP 服务器,它提供对百度云向量数据库功能的访问。

前提条件

在使用百度云向量数据库MCP Server之前,请确保你具备以下条件:

  1. Python 3.10 或更高版本
  2. 已安装uv用于运行MCP Server

使用方式

使用百度云向量数据库MCP Server的推荐方式是通过uv运行,而无需进行安装。

克隆代码仓库,执行以下命令:

git clone https://github.com/baidu/mochow-mcp-server-python.git
cd mochow-mcp-server-python

随后,你可以直接通过uv运行,其中endpointapi-key根据实际需要修改:

uv run src/mochow_mcp_server/server.py 
uv run src/mochow_mcp_server/server.py --endpoint http://127.0.0.1:8287 --api-key mochow

或者,在src/mochow_mcp_server/目录中修改.env文件来设置环境变量,再使用以下命令运行服务器:

uv run src/mochow_mcp_server/server.py 

支持的应用程序

百度云向量数据库MCP Server可以与各种支持模型上下文协议的大语言模型应用程序配合使用:

  • Claude Desktop:Anthropic 公司为 Claude 开发的桌面应用程序

  • Cursor:支持 MCP 的人工智能代码编辑器

  • 自定义 MCP 客户端:任何实现 MCP 客户端规范的应用程序

在Claude Desktop中的使用方式

https://claude.ai下载 Claude Desktop。

打开 Claude Desktop 的配置文件,在 macOS 系统中,路径为~/Library/Application Support/Claude/claude_desktop_config.json

添加以下配置:

{
    "mcpServers": {
        "mochow": {
            "command": "/PATH/TO/uv",
            "args": [
                "--directory",
                "/path/to/mochow-mcp-server-python/src/mochow_mcp_server",
                "run",
                "server.py",
                "--endpoint",
                "http://127.0.0.1:8287",
                "--api-key",
                "mochow"
            ]
        }
    }
}

重启 Claude Desktop。

在 Cursor 中的使用方法

Cursor 也支持 MCP工具。你可以通过两种方式将百度MCP Server添加到Cursor中:

依次打开Cursor设置>功能>MCP,点击+添加新的MCP服务器按钮,在mcp.json中添加以下配置:

{
    "mcpServers": {
        "mochow": {
            "command": "/PATH/TO/uv",
            "args": [
                "--directory",
                "/path/to/mochow-mcp-server-python/src/mochow_mcp_server",
                "run",
                "server.py",
                "--endpoint",
                "http://127.0.0.1:8287",
                "--api-key",
                "mochow"
            ]
        }
    }
}

重启 Cursor 或重新加载窗口。

可用工具

百度云向量数据库MCP Server提供以下工具:

Database操作

  • list_databases: 列出数据库中所有的Database

  • create_database: 创建一个新的Database

    • 参数:
      • database_name: 待创建的Database名称
  • use_database: 切换到一个已存在的Database

    • 参数:
      • database_name: 待切换的Database名称

Table操作

  • list_tables: 列出数据库中所有的Table

  • describe_table: 获取指定Table的详细信息

    • 参数:
      • table_name: Table名称
  • stats_table: 获取指定Table的统计信息

    • 参数:
      • table_name: Table名称

数据操作

  • delete_table_rows: 使用过滤表达式删除数据

    • 参数:
      • table_name: Table名称
      • filter_expr: 过滤表达式
  • select_table_rows: 使用过滤表达式查询数据

    • 参数:
      • table_name: Table名称
      • filter_expr: 过滤表达式
      • limit: 查询结果的最大条数
      • output_fields: 查询结果中要返回的字段名

索引操作

  • create_vector_index: 在指定向量字段上创建向量索引

    • 参数:
      • table_name: Table名称
      • index_name: 向量索引名称
      • field_name: 向量字段名称
      • index_type: 向量索引类型
      • metric_type: 向量索引的距离度量
      • params: 向量索引的创建参数
  • rebuild_vector_index: 重新构建指定向量索引

    • 参数:
      • table_name: Table名称
      • index_name: 向量索引名称
  • drop_vector_index: 删除指定向量索引

    • 参数:
      • table_name: Table名称
      • index_name: 向量索引名称
  • describe_index: 获取指定索引的详情信息

    • 参数:
      • table_name: Table名称
      • index_name: 向量索引名称

检索操作

  • vector_search: 执行带标量过滤的向量相似性检索

    • 参数:
      • table_name: Table名称
      • vector: 向量
      • vector_field: 向量字段名称
      • limit: 相似性检索结果中返回最接近目标向量的记录数量
      • filter_expr: 过滤表达式
      • output_fields: 查询结果中要返回的字段名
  • fulltext_search: 执行全文检索

    • 参数:
      • table_name: Table名称
      • index_name: 向量索引名称
      • search_text: 全文检索的检索表达式
      • limit: 全文检索返回相关性最高的条目数
      • filter_expr: 过滤表达式
      • output_fields: 查询结果中要返回的字段名

环境变量

  • MOCHOW_ENDPOINT: 百度云向量数据库连接实例URI
  • MOCHOW_API_KEY: 百度云向量数据库实例API密钥

使用样例

使用Claude Desktop

Example 1: 列出数据库中所有的Database

How many databases do i have in the mochow db?

Claude将使用百度云向量数据库MCP Server提供的list_databases来获取数据库列表.

Let me check how many databases you have in the Mochow instance.

You have 2 databases in your Mochow instance:

1. book
2. test

Example 2: 查看指定表的schema信息

I want to get the detail of  table named book_segments in database book.

Claude将使用百度云向量数据库MCP Server提供的describe_table来获取表的详情信息.

I'll help you get the details of the "book_segments" table in the "book" database. Let me first switch to the "book" database and then describe the table.

Here's the information about the "book_segments" table in the "book" database:

Database: book
Table Name: book_segments
Creation Time: 2025-05-06 11:08:22
State: NORMAL

Schema:

id (STRING)
Primary Key: Yes
Partition Key: Yes
Not Null: Yes

bookName (STRING)
Not Null: Yes

author (STRING)
Not Null: No

page (UINT32)
Not Null: No

segment (TEXT)
Not Null: No

vector (FLOAT_VECTOR)
Not Null: Yes
Dimension: 1024

Indexes
book_name_filtering_idx (FILTERING_INDEX)
Field: bookName
Order: ASCEND
Structure Type: DEFAULT

vector_idx (HNSW)
Field: vector
Metric Type: L2
Auto Build: False
Parameters: (M: 16 efConstruction: 200)

推荐服务器

Baidu Map

Baidu Map

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

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

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

官方
精选
本地
TypeScript
VeyraX

VeyraX

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

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

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

官方
精选