MCP 文档搜索服务器是一个轻量级的 MCP 服务器,其主要功能是从流行的 AI 库(如 LangChain、LlamaIndex 和 OpenAI)中搜索并检索相关文档内容。该服务器作为语言模型(LLM)和外部文档源之间的桥梁,允许 LLM 动态查询并获取最新的文档内容。
git clone https://github.com/your-repository.git
python -m venv env
source env/bin/activate # 在 Windows 上使用 `env\Scripts\activate`
pip install serper BeautifulSoup4
创建 .env
文件并添加以下内容:
SERPER_API_KEY=your_api_key_here
get_docs
工具:参数包括查询字符串和文档过滤条件。MCP 协议是一个开放标准,用于构建安全的双向连接,将数据源与 AI 工具连接起来。以下是协议的核心要素:
MCP 的目标是标准化语言模型与外部工具之间的通信,并减少定制化集成的工作量。其愿景是促进模块化服务生态系统的发展,类似于插件架构。
config.json
{
"inspectorEnabled": true,
"InspectableProcesses": [
{
"ProcessName": "uv",
"PortNumber": 0
}
]
}
{
\"tool\": {
\"name\": \"get_docs\",
\"description\": \"从指定文档库中搜索相关内容\",
\"parameters\": {
\"type\": \"object\",
\"properties\": {
\"query\": {
\"type\": \"string\",
\"description\": \"搜索查询字符串\"
},
\"filter\": {
\"type\": \"string\",
\"description\": \"文档过滤条件\"
}
}
}
}
}
使用 Node.js 和 Inspector 工具进行实时调试:
npx @modelcontextprotocol/inspector uv run main.py