Information
MCP 服务器:Ollama 深度研究员
这是 LangChain Ollama 深度研究员 的模型上下文协议 (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
# Edit the .env file with your API keys
使辅助脚本可执行:
chmod +x run-docker.sh
构建并运行 Docker 容器:
./run-docker.sh start
确保 Ollama 在你的主机上运行:
ollama pull deepseek-r1:8b # or your preferred model
ollama serve
辅助脚本提供了几个命令:
对于 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 以进行全面的研究过程跟踪和监控:
操作追踪:
所有大语言模型交互都被追踪
网络搜索操作被监控
研究工作流程步骤被跟踪
性能监控:
每个操作的响应时间
成功/失败率
资源利用率
调试与优化:
用于故障排除的详细追踪
性能瓶颈识别
查询优化见解
在 https://smith.langchain.com 下,通过您配置的项目名称访问所有追踪记录。
MCP资源
研究结果自动存储为MCP资源,从而实现:
持久访问
可通过research://\{topic\} URI 访问结果
自动保存完成的研究
带有元数据的JSON格式内容
资源面板集成
研究成果出现在MCP客户端的资源面板中
方便访问过去的研究主题
每个结果的时间戳和描述
上下文管理
在对话中高效重用研究成果
通过引用资源减少令牌使用
选择性地包含研究背景
可用工具
配置
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 and then research
提示示例:“Configure with perplexity and deepseek-r1:8b then research AI-First Applications”
Ollama研究工作流
研究过程受到IterDRAG的启发。这种方法将查询分解成子查询,为每个子查询检索文档,回答子查询,然后基于答案通过检索第二个子查询相关的文档来构建答案。
该过程如下:
给定用户提供的主题,使用本地LLM(通过Ollama)生成一个网络搜索查询
使用搜索引擎(配置为Tavily)查找相关来源
使用LLM总结与用户提供的研究主题相关的网络搜索发现
然后,它使用LLM反思总结,识别知识缺口
它生成一个新的搜索查询来解决这些知识缺口
过程重复进行,摘要随着来自网络搜索的新信息而迭代更新
它会沿着研究路径重复下去
运行可配置的迭代次数
输出
输出是一个包含研究总结的 markdown 文件,其中引用了研究过程中使用的所有来源。
在研究过程中收集的所有来源都得到了保留,并可以在最终输出中引用:
系统集成概述
External ServicesMCP ServerMCP Client LayerClaude Desktop Appuse_mcp_toolaccess_resourceuse_promptExecuteReadGetResultsResponseClaude AssistantTask PlanningTool SelectionResource SelectionPrompt TemplatesTool RegistryProtocol HandlerServer ManagerResource ManagerPrompt ManagerTools APIResearch ControllerConfiguration ManagerState ManagerResource APIPrompt APIOllamaSearch APIs
故障排除
以下是一些您可能会遇到的常见问题的解决方案:
Ollama 连接问题
确保 Ollama 正在运行:在终端执行 ollama list
尝试在关闭应用(系统托盘/菜单栏)后以终端模式运行 ollama:执行 ollama serve
检查 Ollama 是否可以通过 localhost:11434、0.0.0.0:11434 或 127.0.0.1:11434 访问
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 徽章
示例提示和输出记录
提示
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 最终输出
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