mcp-server-ollama-deep-researcher
这是一个 LangChain Ollama Deep Researcher 的模型上下文协议 (MCP) 服务器适配器。它将深度研究能力作为 MCP 工具提供,这些工具可以在模型上下文协议生态系统中使用,从而允许 AI 助手通过 Ollama(本地)对主题进行深入研究。
Tools
research
Research a topic using web search and LLM synthesis
get_status
Get the current status of any ongoing research
configure
Configure the research parameters (max loops, LLM model, search API)
README
MCP服务器:Ollama深度研究者
这是LangChain Ollama深度研究者的Model Context Protocol (MCP)服务器适配版本。它提供深度研究能力作为MCP工具,可以在模型上下文协议生态系统中使用,允许AI助手使用本地LLM通过Ollama对主题进行深入研究。
核心功能
该服务器通过MCP工具和资源提供研究能力,使用由Ollama托管的任何LLM。
研究过程
给定一个主题,它将:
- 生成一个网络搜索查询
- 通过Tavily或Perplexity API收集网络搜索结果
- 总结搜索结果
- 反思总结以检查知识差距
- 生成新的搜索查询以解决差距
- 通过多个研究周期迭代改进摘要
- 提供包含所有使用来源的最终markdown摘要
前提条件
- Node.js(用于运行MCP服务器)
- 从 https://nodejs.org/ 下载并安装
- 确保Node.js已添加到您的系统PATH
- Python 3.10或更高版本
- 能够运行您选择的Ollama模型的计算资源(CPU/GPU)
- 至少8GB的RAM用于运行更大的语言模型
- 必需的API密钥:
- Tavily API密钥(在 https://tavily.com 获取)
- Perplexity API密钥(在 https://perplexity.ai 获取)
- LangSmith API密钥(在 https://smith.langchain.com 获取),用于跟踪和监控
确保您可以从终端/命令提示符运行Node.js和npm。您可以使用以下命令验证您的安装:
node --version
npm --version
python --version
如果这些命令失败,您可能需要:
- 安装后重新启动终端/计算机
- 将Node.js添加到您的系统PATH:
- Windows:编辑系统环境变量 → 环境变量 → Path → 添加Node.js安装目录
- macOS/Linux:通常由安装程序处理
安装
选项1:标准安装
-
为您的平台下载并安装Ollama
-
克隆此存储库并安装依赖项:
git clone https://github.com/Cam10001110101/mcp-server-ollama-deep-researcher
cd mcp-server-ollama-deep-researcher
npm install
- 安装Python依赖项:
首先,安装uv(推荐用于更好的性能和依赖项解析):
# Windows
pip install uv
# macOS/Linux
pip3 install uv
然后使用pyproject.toml安装项目依赖项:
uv pip install .
注意:这将以可编辑模式安装项目,并包含pyproject.toml中指定的所有依赖项。如果您更喜欢pip:
pip install . # Windows
pip3 install . # macOS/Linux
- 构建TypeScript代码:
npm run build
- 从Ollama拉取本地LLM:
ollama pull deepseek-r1:8b
选项2:Docker安装
您还可以使用Docker运行MCP服务器,这简化了设置过程。
-
为您的平台下载并安装Docker
-
克隆此存储库:
git clone https://github.com/Cam10001110101/mcp-server-ollama-deep-researcher
cd mcp-server-ollama-deep-researcher
- 创建一个包含您的API密钥的
.env文件(您可以从.env.example复制):
cp .env.example .env
# 使用您的API密钥编辑.env文件
- 使helper脚本可执行:
chmod +x run-docker.sh
- 构建并运行Docker容器:
./run-docker.sh start
- 确保Ollama在您的主机上运行:
ollama pull deepseek-r1:8b # 或您喜欢的模型
ollama serve
helper脚本提供几个命令:
对于macOS/Linux(使用run-docker.sh):
./run-docker.sh start- 构建并启动Docker容器./run-docker.sh stop- 停止Docker容器./run-docker.sh restart- 重新启动Docker容器./run-docker.sh logs- 显示Docker容器的日志./run-docker.sh status- 检查Docker容器的状态./run-docker.sh help- 显示帮助消息
对于Windows(使用run-docker.bat):
run-docker.bat start- 构建并启动Docker容器run-docker.bat stop- 停止Docker容器run-docker.bat restart- 重新启动Docker容器run-docker.bat logs- 显示Docker容器的日志run-docker.bat status- 检查Docker容器的状态run-docker.bat help- 显示帮助消息
注意:Docker容器配置为连接到在您的主机上运行的Ollama。如果您也想在容器中运行Ollama,请取消注释docker-compose.yml文件中的Ollama服务。
客户端配置
将服务器添加到您的MCP客户端配置:
对于Claude桌面应用程序:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
对于Cline(VS Code扩展):
- Windows:
%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json - macOS:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json - Linux:
~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
选项1:标准安装配置
{
"mcpServers": {
"ollama-deep-researcher": {
"command": "node",
"args": ["path/to/mcp-server-ollama-deep-researcher/build/index.js"],
"env": {
"LANGSMITH_TRACING": "true",
"LANGSMITH_ENDPOINT": "https://api.smith.langchain.com",
"LANGSMITH_API_KEY": "your-langsmith-key",
"LANGSMITH_PROJECT": "ollama-deep-researcher-mcp-server",
"TAVILY_API_KEY": "your-tavily-key", // Include tvly- prefix
"PERPLEXITY_API_KEY": "your-perplexity-key",
"PYTHONPATH": "path/to/mcp-server-ollama-deep-researcher/src"
}
}
}
}
注意:将路径替换为您的系统的绝对路径:
- Windows:使用
C:\\Users\\username\\path\\to\\mcp-server-ollama-deep-researcher - macOS/Linux:使用
/Users/username/path/to/mcp-server-ollama-deep-researcher
对于macOS/Linux,您可能还想添加:
"PYTHONUNBUFFERED": "1"
选项2:Docker安装配置
如果您正在使用Docker容器,您可以配置MCP客户端以连接到正在运行的容器:
{
"mcpServers": {
"ollama-deep-researcher": {
"command": "docker",
"args": ["exec", "-i", "ollama-deep-researcher-mcp", "node", "build/index.js"],
"env": {}
}
}
}
此配置假定Docker容器正在运行。环境变量已在Docker容器中设置,因此您无需在MCP客户端配置中指定它们。
跟踪和监控
该服务器与LangSmith集成,用于对研究过程进行全面的跟踪和监控:
-
操作跟踪:
- 跟踪所有LLM交互
- 监控网络搜索操作
- 跟踪研究工作流程步骤
-
性能监控:
- 每个操作的响应时间
- 成功/失败率
- 资源利用率
-
调试和优化:
- 用于故障排除的详细跟踪
- 性能瓶颈识别
- 查询优化见解
在 https://smith.langchain.com 上,在您配置的项目名称下访问所有跟踪。
MCP资源
研究结果会自动存储为MCP资源,从而实现:
-
持久访问
- 可通过
research://{topic}URI访问结果 - 自动存储已完成的研究
- 具有元数据的JSON格式内容
- 可通过
-
资源面板集成
- 研究结果显示在MCP客户端的资源面板中
- 轻松访问过去的研究主题
- 每个结果的时间戳和描述
-
上下文管理
- 在对话中高效重用研究
- 通过资源引用减少token使用量
- 选择性地包含研究上下文
可用工具
配置
- maxLoops:研究迭代次数(1-5)
- llmModel:要使用的Ollama模型(例如,“deepseek-r1:1.5b”,“llama3.2”)
- searchApi:要使用的搜索API(“perplexity”或“tavily”)
配置研究参数。
{
"name": "configure",
"arguments": {
"maxLoops": 3,
"llmModel": "deepseek-r1:1.5b",
"searchApi": "tavily"
}
}
研究
使用网络搜索和LLM合成研究任何主题。
{
"name": "research",
"arguments": {
"topic": "Austin LangChain, aimug.org"
}
}
获取状态
获取正在进行的研究的当前状态。
{
"name": "get_status",
"arguments": {
"_dummy": "dummy"
}
}
提示
使用默认搜索API、模型和最大迭代次数(循环)
提示示例:“research AI-First Applications”
更改默认配置并开始研究
语法:configure with <searchapi> and <model> then research <topic>
提示示例:“Configure with perplexity and deepseek-r1:8b then research AI-First Applications”
Ollama研究工作流程
研究过程的灵感来自IterDRAG。这种方法将查询分解为子查询,检索每个子查询的文档,回答子查询,然后通过检索第二个子查询的文档来构建答案。
该过程如下:
- 给定用户提供的主题,使用本地LLM(通过Ollama)生成网络搜索查询
- 使用搜索引擎(配置为Tavily)查找相关来源
- 使用LLM总结来自与用户提供的研究主题相关的网络搜索的发现
- 然后,它使用LLM反思摘要,识别知识差距
- 它生成一个新的搜索查询以解决知识差距
- 该过程重复进行,摘要通过来自网络搜索的新信息进行迭代更新
- 它将重复进行研究
- 运行可配置的迭代次数
输出
输出是一个markdown文件,其中包含研究摘要,并引用研究过程中使用的所有来源。
研究期间收集的所有来源都将被保留,并可以在最终输出中引用:
系统集成概述
graph TD
subgraph "Claude Desktop App"
A[Claude Assistant] --> B[Task Planning]
B --> C[Tool Selection]
C --> D[Resource Selection]
D --> E[Prompt Templates]
end
subgraph "MCP Client Layer"
F[Tool Registry] --> G[Protocol Handler]
G --> H[Server Manager]
I[Resource Manager] --> G
J[Prompt Manager] --> G
end
subgraph "MCP Server"
K[Tools API] --> L[Research Controller]
L --> M[Configuration Manager]
L --> N[State Manager]
O[Resource API] --> L
P[Prompt API] --> L
end
subgraph "External Services"
Q[Ollama] --> L
R[Search APIs] --> L
end
%% Feature Support Flow
C -->|"use_mcp_tool"| F
D -->|"access_resource"| I
E -->|"use_prompt"| J
H -->|"Execute"| K
H -->|"Read"| O
H -->|"Get"| P
%% Status Flow
L -->|"Results"| H
H -->|"Response"| C
%% Feature Support Notes
classDef support fill:#e1f3d8,stroke:#333
classDef partial fill:#fff3cd,stroke:#333
%% Full Support Features
A:::support
F:::support
I:::support
J:::support
故障排除
以下是您可能遇到的一些常见问题的解决方案:
Ollama连接问题
- 确保Ollama正在运行:在您的终端中执行
ollama list - 尝试通过关闭应用程序(系统托盘/菜单栏)并在终端中执行
ollama serve来在终端模式下运行ollama - 检查是否可以在
localhost:11434、0.0.0.0:11434或127.0.0.1:11434访问Ollama
API密钥问题
- 验证您的API密钥是否在配置文件中正确设置
- 验证您的路径参数是否指向此存储库中index.js的实际位置
- 确保API密钥周围没有额外的空格或引号
- 检查您的API密钥是否具有足够的信用/权限
MCP服务器问题
- 使用MCP Inspector进行调试:
npx @modelcontextprotocol/inspector node path/to/server/index.js --model llama3.2 --max-loops 3 --search-api tavily
Docker问题
-
如果您在使用Docker容器时遇到问题:
- 检查容器是否正在运行:
docker ps - 查看容器日志:
docker logs ollama-deep-researcher-mcp - 确保您的
.env文件包含有效的API密钥 - 验证Ollama是否在您的主机上运行并且可以从容器访问
- 如果使用host.docker.internal不起作用,请尝试在OLLAMA_BASE_URL环境变量中使用您的主机的IP地址
- 对于容器之间的网络问题,请确保它们位于同一Docker网络上
- 检查容器是否正在运行:
-
如果您在容器中运行Ollama:
- 取消注释docker-compose.yml文件中的Ollama服务
- 确保Ollama容器已分配足够的资源
- 在Ollama容器中拉取模型:
docker exec -it ollama ollama pull deepseek-r1:8b
构建问题
- 如果
npm run build失败并显示“'node' is not recognized”:- 确保Node.js已正确安装
- 将Node.js添加到您的系统PATH:
- Windows:编辑系统环境变量 → 环境变量 → Path → 添加Node.js安装目录
- macOS/Linux:通常由安装程序处理
- 重新启动您的终端/计算机
- 尝试运行
node --version以验证安装
Python问题
Windows:
- 确保Python在您的PATH中
- 尝试使用
python代替python3 - 检查是否安装了pip:
python -m pip --version
macOS/Linux:
- 使用
python3代替python - 检查是否安装了pip:
python3 -m pip --version - 您可能需要安装pip:
sudo apt install python3-pip(Ubuntu/Debian) 或brew install python3(macOS)
错误处理
服务器为以下情况提供清晰的错误消息:
- 缺少或无效的API密钥
- 配置问题
- 搜索API问题
- LLM处理错误
需要改进的地方
- 更紧密地重新集成和验证langgraph,以实现更多有趣的用例。
架构
有关服务器架构和实现的详细信息,请参见 .context/index.md。
Glama.ai徽章
<a href="https://glama.ai/mcp/servers/r25SSxqOci"> <img width="380" height="200" src="https://glama.ai/mcp/servers/r25SSxqOci/badge" /> </a>
示例提示和输出记录
提示
Configure with perplexity and deepseek-r1:8b then research AI-First Applications
配置输出
{
"searchApi": "perplexity",
"llmModel": "deepseek-r1:8b",
"maxLoops": 3
}
Ollama研究者输出
Research configuration updated:
Max Loops: 3
LLM Model: deepseek-r1:8b
Search API: perplexity
### Complete Research Results
**Updated Summary: AI-First Applications in Healthcare: Focus on PathAI**
1. **Design Principles**:
- PathAI exemplifies a data-driven approach by leveraging extensive datasets to train advanced AI models like PLUTO.
- Collaboration is central to their success, integrating technology into clinical workflows through partnerships with institutions such as Cleveland Clinic.
2. **Industry Transformations**:
- In healthcare, PathAI has significantly impacted diagnostic accuracy and efficiency. Their foundation model, PLUTO, demonstrates superior performance in various pathology tasks, outperforming existing models while reducing costs.
- Collaborations with leading institutions have facilitated the creation of digital pathology data networks, enhancing research and clinical care.
3. **Scalability and Performance**:
- PathAI's PLUTO model offers enhanced efficiency and compactness, significantly reducing training and inference costs.
- This innovation underscores their commitment to scalable and effective solutions in healthcare.
4. **Growth and Impact**:
- PathAI's growth strategy includes strategic partnerships and collaborations, such as their partnership with Cleveland Clinic and acquisition by Quest Diagnostics.
- These moves accelerate AI and digital pathology adoption, particularly in cancer diagnosis.
This summary highlights PathAI's contributions to healthcare through innovative technology and strategic collaborations, emphasizing their role in driving advancements and improving patient outcomes.
## Sources
### Perplexity Search 1
1. https://intelifaz.com/insights/ai-first-software-design
2. https://www.uxdesigninstitute.com/blog/how-to-design-for-ai-first-products/
3. https://vux.world/ai-design-principles/
4. https://www.leanware.co/insights/ai-first-apps
5. https://adamfard.com/blog/ai-ux-design-framework
6. https://www.sgh.com/insight/artificial-intelligence-best-practices/
7. https://www.index.dev/blog/generative-ai-application-design-principles
8. https://onstrategyhq.com/resources/ai-guiding-principles/
9. https://orangematter.solarwinds.com/2024/04/29/introducing-ai-by-design-principles-for-responsible-ai/
10. https://principles.design/examples/10-principles-for-design-in-the-age-of-ai
### Perplexity Search 2
1. https://cloud.google.com/transform/101-real-world-generative-ai-use-cases-from-industry-leaders
2. https://www.cloudera.com/resources/the-art-of-the-possible/ai-first-benefits-5-real-world-outcomes.html
3. https://builtin.com/artificial-intelligence/examples-ai-in-industry
4. https://www.uxforai.com/p/the-rise-of-ai-first-products
5. https://www.1051theblaze.com/ai-first-mobile-apps/
6. https://www.techtarget.com/searchenterpriseai/tip/The-history-of-artificial-intelligence-Complete-AI-timeline
7. https://gitnation.com/contents/demystifying-ai-first-building-applications-for-the-future
8. https://fptsoftware.com/resource-center/blogs/the-ai-first-future-challenges-and-opportunities
9. https://online.maryville.edu/blog/history-of-ai/
10. https://www.audience.io/blog/artificial-intelligence-first-party-data-the-future-of-data
### Perplexity Search 3
1. https://monday.com/blog/rnd/technical-specification/
2. https://softwaremind.com/blog/8-steps-for-successful-software-implementation/
3. https://www.infotech.com/research/ss/build-your-enterprise-application-implementation-playbook
4. https://interactiveimmersive.io/blog/touchdesigner-lessons/04-technical-implementation-design/
5. https://www.indeed.com/career-advice/finding-a-job/technical-requirements
6. https://www.techtarget.com/searchcustomerexperience/definition/implementation
7. https://theobogroup.com/what-to-know-about-technical-implementations/
8. https://www.ntietz.com/blog/whats-behind-just-implementation/
9. https://public.cyber.mil/stigs/
### Perplexity Search 4
1. https://www.ittbiomed.com/transforming-pathology-with-ai/
2. https://www.pathai.com/resources/pathai-commences-new-year-with-strong-foundation-for-growth-following-key-2023-achievements-in-ai-powered-pathology-products-strategic-partnerships-and-leadership-team-hires/
3. https://canvasbusinessmodel.com/blogs/target-market/pathai-target-market
4. https://www.pathologynews.com/industry-news/pathai-launches-new-pathologist-centric-features-on-aisight-to-enable-efficient-case-review-through-intelligent-case-prioritization-and-real-time-multi-institutional-collaboration/
5. https://newsroom.clevelandclinic.org/2022/03/10/pathai-and-cleveland-clinic-announce-collaboration-to-build-digital-pathology-infrastructure-and-evolve-use-of-ai-powered-pathology-algorithms-in-research-and-clinical-care
6. https://academic.oup.com/jamia/article/30/9/1503/7174318
7. https://hitconsultant.net/2024/05/14/pathai-unveils-ai-foundation-model-built-for-disease-detection/
8. https://newsroom.questdiagnostics.com/2024-05-01-Quest-Diagnostics-to-Acquire-PathAI-Diagnostics-to-Accelerate-AI-and-Digital-Pathology-Adoption-in-Cancer-Diagnosis-Forms-Licensing-Agreements-with-PathAI
9. https://www.multimodal.dev/post/ai-in-healthcare
10. https://canvasbusinessmodel.com/blogs/growth-strategy/pathai-growth-strategy
Claude Final Output
Key Principles of AI-First Applications:
1. Human-AI Collaboration
- Applications are designed with AI as a core component rather than an add-on
- Focus on augmenting human capabilities rather than replacing them
- Clear feedback loops between AI systems and human users
2. Data-Centric Architecture
- Built around robust data pipelines and continuous learning
- Strong emphasis on data quality and governance
- Scalable infrastructure to handle growing datasets
3. Adaptive User Experience
- Interfaces that evolve based on user interaction patterns
- Contextual awareness and personalization
- Clear communication of AI capabilities and limitations
Real-World Example: PathAI in Healthcare
Core Technology:
- PLUTO foundation model demonstrates superior performance in pathology tasks
- Focuses on efficiency and cost reduction while maintaining high accuracy
- Built for scalability and integration into existing workflows
Implementation Strategy:
- Strategic partnerships with healthcare institutions like Cleveland Clinic
- Creation of digital pathology data networks
- Focus on practical clinical applications and research
Impact:
- Improved diagnostic accuracy in cancer detection
- Enhanced efficiency in pathology workflows
- Reduced costs through optimized resource utilization
Best Practices for AI-First Applications:
1. Technical Implementation
- Start with clear use cases and success metrics
- Build robust data pipelines and validation processes
- Implement continuous monitoring and model updating
2. User Experience
- Design transparent interfaces that build trust
- Provide clear feedback on AI decisions and confidence levels
- Allow for human oversight and intervention
3. Integration and Scaling
- Focus on seamless integration with existing workflows
- Build scalable infrastructure from the start
- Plan for continuous improvement and iteration
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。