Back to MCP directory
publicPublicdnsLocal runtime

search_mcp_server

一个强大的MCP服务器,提供网页搜索和相似内容查找功能,专为Claude Desktop设计。

article

README

🚀 parquet_mcp_server

parquet_mcp_server 是一个强大的 MCP(模型控制协议)服务器,它提供了用于执行网络搜索和查找相似内容的工具。该服务器专为 Claude Desktop 设计,能为需要网络搜索功能以及根据搜索查询查找类似内容的应用程序和项目提供支持。

🚀 快速开始

parquet_mcp_server 是专为 Claude Desktop 设计的 MCP 服务器,可执行网络搜索并查找相似内容。下面将为您介绍如何安装、配置和使用该服务器。

✨ 主要特性

  • 网络搜索:执行网络搜索并抓取结果。
  • 相似性搜索:从之前的搜索中提取相关信息。

📦 安装指南

通过 Smithery 安装

要通过 Smithery 自动安装 Parquet MCP Server for Claude Desktop,可使用以下命令:

npx -y @smithery/cli install @DeepSpringAI/parquet_mcp_server --client claude

克隆此仓库

git clone ...
cd parquet_mcp_server

创建并激活虚拟环境

uv venv
.venv\Scripts\activate  # 在 Windows 上
source .venv/bin/activate  # 在 macOS/Linux 上

安装依赖项

安装项目所需的 Python 包:

pip install -r requirements.txt

📚 详细文档

配置

更新 config.py 文件,设置以下环境变量: | 属性 | 详情 | |------|------| | DB_HOST | 数据库主机地址(默认:localhost) | | DB_PORT | 数据库端口(默认:5432) | | DB_NAME | 数据库名称(默认:postgres) | | DB_USER | 数据库用户名(默认:postgres) | | DB_PASSWORD | 数据库密码 | | VECTOR_SIZE | 向量大小(默认:1024) |

使用

初始化数据库

运行以下 SQL 命令初始化 PostgreSQL 数据库:

CREATE EXTENSION IF NOT EXISTS pgvector;

插入数据

使用 insert_data.py 脚本将搜索结果插入到数据库中:

python insert_data.py --metadata "{'source': 'example.com', 'timestamp': '2023-10-01'}" --text "这是一个示例文本。"

搜索数据

使用 search_data.py 脚本根据向量相似性搜索数据库中的内容:

python search_data.py --query_embedding "0.5, 0.3, ..., 0.2" --threshold 0.7

测试

运行以下命令测试服务器:

uvicorn main:app --reload

访问 http://localhost:8000/docs 查看 API 文档。

故障排除

网络搜索失败

  • 检查互联网连接。
  • 确保目标网站允许被爬取。

数据库连接问题

  • 确保 PostgreSQL 服务正在运行。
  • 检查数据库凭据是否正确。
  • 查看 PostgreSQL 日志文件以获取更多信息。

向量相似性搜索性能差

  • 优化 PostgreSQL 查询。
  • 增加向量索引。
  • 减少结果限制或降低相似性阈值。

PostgreSQL 函数用于向量相似性搜索

要使用 PostgreSQL 执行向量相似性搜索,可以使用以下函数:

-- 创建用于向量相似性搜索的函数
CREATE OR REPLACE FUNCTION match_web_search(
  query_embedding vector(1024),  -- 调整向量大小
  match_threshold float,
  match_count int  -- 用户定义的结果数量限制
)
RETURNS TABLE (
  id bigint,
  metadata jsonb,
  text TEXT,  -- 返回完整文本内容
  date TIMESTAMP,  -- 使用 date 列代替 created_at
  similarity float
)
LANGUAGE plpgsql
AS $$
BEGIN
  RETURN QUERY
  SELECT
    web_search.id,
    web_search.metadata,
    web_search.text,  -- 返回完整的文本内容
    web_search.date,  -- 返回日期时间戳
    1 - (web_search.embedding <=> query_embedding) as similarity
  FROM web_search
  WHERE 1 - (web_search.embedding <=> query_embedding) > match_threshold
  ORDER BY web_search.date DESC,  -- 按日期降序排序(最新优先)
           web_search.embedding <=> query_embedding  -- 按相似性排序
  LIMIT match_count;  -- 根据用户指定限制结果数量
END;
$$;

此函数允许您在 PostgreSQL 数据库中执行向量相似性搜索,返回满足指定相似性阈值的结果,并根据用户输入限制结果数量。结果按日期和相似性进行排序。

PostgreSQL 表创建

CREATE TABLE web_search (
    id SERIAL PRIMARY KEY,
    text TEXT,
    metadata JSONB,
    embedding VECTOR(1024),

    -- 该字段会自动更新
    date TIMESTAMP DEFAULT NOW()
);

此表结构用于存储网络搜索结果,包括文本内容、元数据和向量表示。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client