parquet_mcp_服务器
](https://smithery.ai/server/@DeepSpringAI/parquet_mcp_server)
一个强大的MCP(模型控制协议)服务器,提供执行网络搜索和查找类似内容的工具。此服务器旨在与Claude Desktop配合使用,并提供两个主要功能:
- 网页搜索:执行网络搜索并抓取结果
- 相似性搜索:从以前的搜索中提取相关信息
此服务器特别适用于:
- 需要网络搜索功能的应用程序
- 需要根据搜索查询查找类似内容的项目
安装
通过Smithery安装
通过以下方式自动安装Claude Desktop的Parquet MCP服务器 史密瑟里:
npx -y @smithery/cli install @DeepSpringAI/parquet_mcp_server --client claude克隆此存储库
git clone ...
cd parquet_mcp_server创建并激活虚拟环境
uv venv
.venv\Scripts\activate # On Windows
source .venv/bin/activate # On macOS/Linux安装软件包
uv pip install -e .环境
创建一个 .env 包含以下变量的文件:
EMBEDDING_URL=http://sample-url.com/api/embed # URL for the embedding service
OLLAMA_URL=http://sample-url.com/ # URL for Ollama server
EMBEDDING_MODEL=sample-model # Model to use for generating embeddings
SEARCHAPI_API_KEY=your_searchapi_api_key
FIRECRAWL_API_KEY=your_firecrawl_api_key
VOYAGE_API_KEY=your_voyage_api_key
AZURE_OPENAI_ENDPOINT=http://sample-url.com/azure_openai
AZURE_OPENAI_API_KEY=your_azure_openai_api_key使用Claude Desktop
将此添加到您的Claude Desktop配置文件中(claude_desktop_config.json):
{
"mcpServers": {
"parquet-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/home/${USER}/workspace/parquet_mcp_server/src/parquet_mcp_server",
"run",
"main.py"
]
}
}
}可用工具
服务器提供两个主要工具:
- 搜索网页:执行网络搜索并抓取结果
- 所需参数: - queries:搜索查询列表 - 可选参数: - page_number:搜索结果的页码(默认为1)
- 从搜索中提取信息:从以前的搜索中提取相关信息
- 所需参数: - queries:要合并的搜索查询列表
示例提示
以下是一些可以与代理一起使用的示例提示:
对于网络搜索:
"Please perform a web search for 'macbook' and 'laptop' and scrape the results from page 1"从搜索中提取信息:
"Please extract relevant information from the previous searches for 'macbook'"测试MCP服务器
该项目包括一个全面的测试套件 src/tests 目录。您可以使用以下命令运行所有测试:
python src/tests/run_tests.py或者运行单独的测试:
# Test Web Search
python src/tests/test_search_web.py
# Test Extract Info from Search
python src/tests/test_extract_info_from_search.py您还可以直接使用客户端测试服务器:
from parquet_mcp_server.client import (
perform_search_and_scrape, # New web search function
find_similar_chunks # New extract info function
)
# Perform a web search
perform_search_and_scrape(["macbook", "laptop"], page_number=1)
# Extract information from the search results
find_similar_chunks(["macbook"])故障排除
- 如果您遇到SSL验证错误,请确保您的SSL设置
.env文件正确 - 如果未生成嵌入,请检查:
- Ollama服务器正在运行且可访问 - 指定的型号在Ollama服务器上可用 - 文本列存在于您的输入Parquet文件中
- 如果DuckDB转换失败,请检查:
- 输入Parquet文件存在并且可读 - 您在输出目录中具有写入权限 - Parquet文件未损坏
- 如果PostgreSQL转换失败,请检查:
- PostgreSQL连接设置 .env 文件正确 - PostgreSQL服务器正在运行且可访问 - 您具有创建/修改表所需的权限 - pgvector扩展已安装在您的数据库中
PostgreSQL向量相似性搜索函数
要在PostgreSQL中执行向量相似性搜索,可以使用以下函数:
-- Create the function for vector similarity search
CREATE OR REPLACE FUNCTION match_web_search(
query_embedding vector(1024), -- Adjusted vector size
match_threshold float,
match_count int -- User-defined limit for number of results
)
RETURNS TABLE (
id bigint,
metadata jsonb,
text TEXT, -- Added text column to the result
date TIMESTAMP, -- Using the date column instead of created_at
similarity float
)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT
web_search.id,
web_search.metadata,
web_search.text, -- Returning the full text of the chunk
web_search.date, -- Returning the date timestamp
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, -- Sort by date in descending order (newest first)
web_search.embedding query_embedding -- Sort by similarity
LIMIT match_count; -- Limit the results to the match_count specified by the user
END;
$$;此函数允许您对存储在PostgreSQL数据库中的向量嵌入执行相似性搜索,返回符合指定相似性阈值的结果,并根据用户输入限制结果数量。结果按日期和相似性排序。
Postgres表创建
CREATE TABLE web_search (
id SERIAL PRIMARY KEY,
text TEXT,
metadata JSONB,
embedding VECTOR(1024),
-- This will be auto-updated
date TIMESTAMP DEFAULT NOW()
);