mcp-server-qdrant
智能体 RAG(Tavily + Context7 + Qdrant)
功能说明
一个由智能体自行构建的知识库——这是智能体可以调用的多种上下文工程来源之一。
RAG(检索增强生成)是指为模型提供相关文档以支撑其回答。通常的做法是预先将文档加载到向量存储中。智能体 RAG 则反过来: 智能体自行构建知识库,自行决定哪些内容值得保留,并在工作过程中存储它们。
本示例使用官方的 Qdrant MCP 服务器。Qdrant 是一个向量数据库,该服务器暴露了两个工具:一个用于存储文本片段,另一个用于查找与查询最相关的已存储文本。它完全本地运行——QDRANT_LOCAL_PATH 将所有数据保存在磁盘上,无需额外运行数据库,并且使用本地模型进行文本嵌入,因此无需额外的 API 密钥。
智能体使用了三个 MCP 服务器:
服务器 | 传输方式 | 用途 |
Tavily ( | 通过 | 实时网络搜索,限定为 |
Context7 ( | 可流式 HTTP | 库、框架、SDK 和 API 的当前文档 |
Qdrant ( | 通过 | 智能体写入和读取的本地向量存储 |
脚本将 RAG 的两个环节作为两个独立的智能体运行:
存储——一个拥有 Tavily 搜索、Context7 和 Qdrant 的智能体。它从网络上研究 Nvidia 的最新信息,通过 Context7 查找当前的 OpenAI Agents SDK 文档,并将两者的关键事实存储起来。
检索——第二个智能体仅拥有 Qdrant,没有网络搜索,也没有 Context7。它所说的任何内容,都是从第一个智能体存储的内容中回忆出来的。
Related MCP server: Qdrant MCP Server
为什么使用 Context7
模型的训练数据有截止日期,因此它对快速迭代的库的记忆是过时的,并且会自信地编造出不再存在的 API。Context7 是一个托管的 MCP 服务器,它索引库文档并按需提供最新版本。两个工具:
resolve-library-id——将包名或产品名("openai-agents"、"next.js")转换为 Context7 库 ID。query-docs——获取该库的最新文档和代码示例,并限定在你的问题范围内。
智能体的指令会将任何与库相关的问题路由到 Context7,而不是路由到记忆或通用网络搜索——先解析 ID,再查询文档。由于它是一个纯 HTTP 端点,无需安装任何东西;它通过 MCPServerStreamableHttp 而不是 MCPServerStdio 进行连接:
context7_params = {"url": "https://mcp.context7.com/mcp", "timeout": 60}
async with MCPServerStreamableHttp(params=context7_params, client_session_timeout_seconds=60) as docs_server:
...这里涉及两个超时,它们的作用不同。参数中的 timeout 是 HTTP 请求超时;client_session_timeout_seconds 是 MCP 会话读取超时,默认只有 5 秒——这个值太低,慢速的文档获取会失败,因此这里将其提高到 60 秒。
设置
Node 22+(Tavily 通过
npx运行;Qdrant 通过uvx运行,而uv已经提供了uvx;Context7 无需安装任何东西):Windows(PowerShell):
winget install OpenJS.NodeJS.LTSMac:
brew install nodeLinux / 其他系统:通过包管理器或从 nodejs.org 安装
在 tavily.com 获取免费的 Tavily API 密钥(每月 1000 次搜索,无需信用卡;密钥以
tvly-开头)。可选: 在 context7.com 获取免费的 Context7 API 密钥。Context7 支持匿名使用——密钥仅用于提高速率限制。
将
.env.example复制为.env并填写:OPENAI_API_KEY=sk-... TAVILY_API_KEY=tvly-... CONTEXT7_API_KEY= # optional, leave blank to run anonymously安装依赖:
uv sync运行:
uv run main.py
注意事项
首次运行会暂停一次,有时会持续一段时间:首次存储或搜索会下载 Qdrant 的小型本地嵌入模型。这就是为什么 Qdrant 服务器的客户端超时设置为 120 秒而不是 60 秒。
向量存储位于
memory/qdrant/(集合knowledge),相对于你的工作目录创建——请从项目文件夹运行。删除它以清空知识库。再次运行脚本时,步骤 1 会向已有内容追加,而不是替换。
如果设置了
CONTEXT7_API_KEY,它会作为Authorization: Bearer ...头发送;如果未设置,则完全省略该头,匿名使用服务器。检索智能体被特意只保留 Qdrant。如果也给它 Context7,会模糊演示效果——你将无法判断答案来自知识库还是来自新的文档查询。
Context7 是一个远程服务器,因此与其他两个不同,它依赖于
mcp.context7.com的网络可达性,而不是本地进程。追踪信息位于 platform.openai.com/traces。
Windows,路径包含空格: 如果
npx启动失败,请改用{"command": "powershell", "args": ["/c", "npx", ...]}。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceProvides semantic memory capabilities using Qdrant vector database with configurable embedding providers, allowing storage and retrieval of information using vector similarity.2Apache 2.0
- Alicense-qualityBmaintenanceEnables semantic search and document management using a local Qdrant vector database with OpenAI embeddings. Supports natural language queries, metadata filtering, and collection management for AI-powered document retrieval.16436MIT
- Alicense-qualityDmaintenanceEnables storing and retrieving information using semantic search with Qdrant vector database. Acts as a memory layer for LLMs to persistently store and semantically search through information and metadata.Apache 2.0
- Flicense-qualityDmaintenanceEnables interaction with Qdrant vector database for storing, searching, and managing vectors with automatic text embedding.1
Related MCP Connectors
Persistent memory for AI agents. Search, store, and recall across sessions.
Long-term memory for AI assistants. Hybrid retrieval, query expansion, auto-topics.
Universal memory for AI agents and tools. Save, organize and search context anywhere.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jiteshzope/Agentic-RAG-with-MCPs'
If you have feedback or need assistance with the MCP directory API, please join our Discord server