多源研究协调服务器

Research MCP Server是一个模型上下文协议(MCP)服务器,为AI助手提供共识驱动的多源研究能力,包括网络搜索、学术论文、库文档和AI推理的综合协调。

  • by norvalbv
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 norvalbv/deep-research-mcp

使用说明

研究MCP服务器

人工智能助手的智能多源研究编排

概述

研究MCP服务器是一个模型上下文协议(MCP)服务器,它提供 共识驱动的多源研究能力 Claude、ChatGPT和其他MCP兼容客户端等人工智能助手。它使用 3-5名法学硕士就研究策略进行投票,然后动态地编排跨网络搜索、学术论文、图书馆文档和人工智能推理的研究,通过内置的事实检查提供全面、经过验证的见解。

为什么要研究MCP?

  • 共识规划:2-5位法学硕士对研究策略进行投票+对每个子问题进行独立规划
  • 生产就绪报告:强制数字特定性,无占位符代码,明确的成功标准
  • 分阶段合成:采用关键发现提取的令牌高效方法(令牌减少约40%)
  • 代码验证:针对Context7文档的合成后验证捕获了幻觉代码
  • 内联引用:所有索赔均来源于([perplexity:url], [context7:lib], [arxiv:id])
  • 多模型验证:关键挑战+多个LLM的共识验证
  • 可操作性检查表:评估综合的特异性、完整性和无矛盾输出
  • 上下文高效报告:分段架构,按需阅读(防止AI上下文膨胀)
  • 动态执行:具有并行处理功能的定制研究计划
  • 多源合成:结合困惑、arXiv、Context7和直接LLM推理

特性

核心能力

  • 适应性研究规划:根共识+独立子问题规划
  • 多源搜索:
    • 通过困惑API进行网络搜索
    • 通过arXiv发表的学术论文,附有人工智能生成的摘要
    • 通过Context7获取库文档(共享+特定文档提取)
    • 深度推理
  • 并行处理:主查询+子问题同时执行
  • 分阶段合成:主要综合→ 关键发现提取→ 亚Q合成(令牌高效)
  • 代码验证:根据Context7文件进行综合后验证
  • 验证流程:关键挑战+多模式共识+充足性投票

🚀 安装

先决条件

快速开始

# Clone the repository
git clone https://github.com/yourusername/research-mcp.git
cd research-mcp

# Install dependencies
npm install
# or
bun install

# Build TypeScript
npm run build

与MCP客户端集成

克劳德桌面/光标

添加到MCP配置文件中:

克劳德桌面版: ~/Library/Application Support/Claude/claude_desktop_config.json 光标: ~/.cursor/mcp.json

{
  "mcpServers": {
    "research": {
      "command": "node",
      "args": ["/path/to/deep-research-mcp/dist/index.js"],
      "env": {
        "PERPLEXITY_API_KEY": "your-key",
        "GEMINI_API_KEY": "your-key",
        "OPENAI_API_KEY": "your-key",
        "ARXIV_STORAGE_PATH": "/path/to/storage/",
        "CONTEXT7_API_KEY": "your-key"
      }
    }
  }
}

添加配置后重新启动客户端。

💡 用法

基本示例(异步模式)

让你的人工智能助手使用研究工具:

I need to research transformer architectures.
Can you use the start_research tool to give me a comprehensive overview?

AI将呼叫:

{
  "query": "How do transformer architectures work?",
  "depth_level": 2
}

然后投票给 check_research_status 使用返回 job_id.

阅读研究报告引用

当人物角色使用格式引用研究时 [R-135216:5-19],您可以验证内容:

Use the read_report tool to verify what the persona cited:
{
  "citation": "[R-135216:5-19]"
}

这将返回报告R-135216的第5-19行。

具有丰富上下文的高级示例

I'm building an AI memory companion that extracts entities and deduplicates memories.
I need to create 600+ test examples for evaluation, but my current template-based
approach creates unrealistic data. Research the best approaches for creating
high-quality evaluation datasets.

Context:
- Solo developer with 20 hour budget
- Already reviewed papers on Excel formula repair and DAHL biomedical benchmark
- Found that synthetic data is 40% simpler than real data
- Random template filling doesn't work

Specific questions:
1. What makes evaluation data representative?
2. How to generate hard negatives?

Tech stack: Python, Neo4j, LangSmith

这引发了一场复杂的研究会议,其中包括:

{
  "query": "How to create high-quality evaluation datasets for LLM testing?",
  "project_description": "AI memory companion with semantic extraction/dedup",
  "current_state": "85 test examples, need 600+",
  "problem_statement": "Template-based generation creates unrealistic data",
  "constraints": ["Solo developer", "20 hours"],
  "domain": "LLM evaluation datasets",
  "depth_level": 4,
  "papers_read": ["Excel formula repair", "DAHL biomedical benchmark"],
  "key_findings": ["Synthetic data 40% simpler than real data"],
  "rejected_approaches": ["Random template filling"],
  "sub_questions": [
    "What makes evaluation data representative?",
    "How to generate hard negatives?"
  ],
  "tech_stack": ["Python", "Neo4j", "LangSmith"],
  "output_format": "actionable_steps",
  "include_code_examples": true
}

保存研究报告

您可以通过设置将研究输出另存为本地标记文件 report: true:

{
  "query": "How do transformer architectures work?",
  "depth_level": 3,
  "report": true,
  "report_path": "/Users/name/Documents/research/"  // optional
}

默认行为:

  • 报告保存到 ~/research-reports/
  • 文件名格式: research-YYYY-MM-DD-sanitized-query.md
  • 例子: research-2025-12-10-how-do-transformer-architectures-work.md
  • 响应中包含的文件路径

自定义目录:使用 report_path 参数以指定其他位置。

可用工具

MCP服务器公开了五个工具:

  1. start_research -具有丰富参数的异步研究编排器(立即返回job_id)
  2. check_research_status -轮询异步作业状态并在完成时检索结果
  3. read_report -使用引文格式从研究报告中读取特定行(例如。, [R-135216:5-19])
  4. read_paper -通过arXiv MCP阅读全文
  5. download_paper -通过arXiv MCP下载PDF

参数参考

参数 类型 说明
query 字符串 必需.你的研究问题
depth_level 1-5 研究深度(如果省略,则自动检测)
project_description string 你正在构建什么
current_state string 你现在在哪里
problem_statement string 要解决的具体问题
constraints string[] 时间/预算/技术限制
domain string 研究领域/地区
papers_read string[] 已审阅的论文(防止冗余)
key_findings string[] 你已经知道的
rejected_approaches string[] 已排除的方法
sub_questions string[] 并行回答的具体问题
tech_stack string[] 正在使用的技术(触发Context7文档)
output_format enum summary, detailed, actionable_steps,或 direct (仅回答,无报告包装)
include_code_examples boolean 是否获取代码示例
date_range string 首选日期范围(例如,“2024-2025”)

🔍 运作原理

智能研究架构(v2)

该研究系统采用了一种复杂的分阶段方法,旨在提高令牌效率和代码准确性:

第一阶段:根规划

  • 协商一致投票 2-5 LLM决定研究复杂性(1-5)
  • 根规划器创建策略 仅限主查询
  • 识别 共享文档 需求(基本API/语法文档)
  • 每个子问题得到 独立规划 (轻便、快速)

第二阶段:并行数据收集

  • 共享上下文7文档 为所有查询提取一次(例如,“React基础”)
  • 以完全工具访问权限执行主查询
  • 独立计划的子问题 通过快速LLM呼叫
    • 每个子Q选择自己的工具(context7、conference、arxiv)
    • 可以请求 特定上下文7主题 超越共享文档
  • 所有聚会都是为了速度而并行进行的

阶段3:分阶段合成(代币高效)

  1. 主查询综合 -对主要问题的全面回答
  2. 关键发现提取 -~500个主要结论摘要
  3. 子问题综合 -平行,注入关键发现以增强一致性
    • 防止主答案和子答案之间的矛盾
    • 每个子Q合成只使用相关数据(并非所有研究)

第4阶段:代码验证通过

  • 从合成报告中提取所有代码块
  • 根据验证 权威的Context7文档
  • 修复了幻觉API、过时的语法、不正确的方法名
  • Context7成为代码准确性的真实来源

阶段4.5:PVR一致性验证

基于 arxiv:2310.03025 和 阿:2305.14251:

  • 全局约束清单:在综合之前从来源中提取关键事实
  • NLI横截面:检查各部分的索赔是否存在矛盾
  • 牵连评分:目标分数>=0.85(研究支持阈值)
  • 投机性重新滚动:仅重新生成矛盾的部分(不是全部)
  • 结果:与顺序处理相比,6倍速度下的一致性为98%

关键阈值(来自研究):

度量 值 来源
牵连阈值 0.85 arxiv:2310.03025
验证超时 5s 行业标准
最大重滚尝试次数 2 防止无限循环

第5阶段:多模型验证

  • 关键挑战:LLM攻击合成以发现差距
  • 共识 (深度>=4):3个LLM验证了发现
  • 充分性投票:综合与批判
  • 如果发现重大差距,则重新综合

为什么是这种架构?

令牌效率:

  • 与单片方法相比,分阶段合成使用的令牌减少了约40%
  • 子问题看不到完整的主查询数据转储
  • 关键发现摘要可防止冗余上下文

代码准确性:

  • Context7验证在交付前捕获了幻觉代码
  • 内联引用追踪每一项声明的来源
  • 文档提取一次并缓存以通过验证

一致性保证(PVR):

  • 全局约束清单确保所有部分共享一致的事实
  • 横截面NLI检测截面之间的矛盾
  • 推测性的重新滚动只修复了矛盾的部分(比顺序快6倍)
  • 研究支持的0.85推断阈值(arxiv:2310.03025)
  • 98%的一致性与顺序处理

研究质量:

  • 独立的子Q计划可防止根计划的偏差
  • 每个子Q都得到了最佳的刀具选择
  • 关键发现注入确保了连贯、不矛盾的答案
  • 合成LLM使用温度=0.2进行确定性特定输出
  • 可部署解决方案的生产工程师角色提示
  • 明确的数字特异性要求(无“高”、“快”、“好”)
  • 很少有镜头示例强制执行生产就绪代码(没有TODO/FIXME)
  • 交付前基于检查表的验证审核可操作性

研究支持的验证

验证层采用了最近人工智能研究的技术,以确保高质量、真实的输出:

多样化的LLM组合 (R-212511,R-214931):

  • 使用3种以上不同的模型架构进行投票(Gemini、GPT-4o-mini、Claude Haiku)
  • 研究表明,不同的组合可以实现 >98.8%的成功率 与相同型号的套装相比
  • 在共识任务中,多个小型多样化模型的表现优于单个大型模型
  • 通过架构多样性减轻相关错误和系统偏差

基于上下文的验证 (arxiv:2510.02340v2,arxiv:4403.12958v2):

  • 验证器从网络搜索和论文中接收原子事实作为明确的基础上下文
  • 提示指示LLM依赖 仅 论参数知识提供的外部语境
  • 解决知识截断问题-防止对最新信息的误报(例如,新的人工智能模型)
  • >95%有效 防止过时的知识导致验证失败

BetterBench代码标准 (arxiv:2411.12990v1):

  • 区分 说明性代码 (如果标记了占位符,则可以) 生产代码 (无占位符)
  • 占位符API键(YOUR_API_KEY)是安全最佳实践,而不是关键差距
  • 明确标记的模拟和概念示例可用于演示目的
  • 防止在教学上适当的代码示例上出现错误

研究流程图

graph TD
    A[Query + Context] --> B[Root Planning: 2-5 LLM Consensus]
    B --> C[Main Query Strategy]
    B --> D[Identify Shared Docs]
    D --> E[Fetch Base Context7 Docs]
    A --> F[Plan Each Sub-Q Independently]
    
    C --> G[Execute Main Query]
    E --> G
    F --> H[Execute Sub-Qs in Parallel]
    E --> H
    
    G --> GM[Extract Global Manifest]
    GM --> I[Phase 1: Main Synthesis]
    I --> J[Extract Key Findings ~500 tokens]
    J --> K[Phase 2: Sub-Q Syntheses Parallel]
    H --> K
    
    K --> PVR{PVR Check: Score >= 0.85?}
    PVR -->|No| RR[Re-roll Contradicting Sections]
    RR --> K
    PVR -->|Yes| L[Code Validation vs Context7]
    L --> M[Critical Challenge]
    M --> N{Depth >= 4?}
    N -->|Yes| O[Multi-LLM Consensus]
    N -->|No| P[Sufficiency Vote]
    O --> P
    P --> Q{Sufficient?}
    Q -->|Yes| R[Report with Inline Citations]
    Q -->|No| S[Re-synthesize]
    S --> I
深度 困惑 深度 上下文7 arXiv 共识 挑战 投票 代码
1 是 否 否 不 否
2 是 是 否 否 是 不 否
3 是 是 否 否 是 对 是
4 是 是 有 有 是

内联引用

报告现在包括 内联源引用 可追溯性:

  • [perplexity:url] -网络搜索查找
  • [context7:library-name] -图书馆文件/代码
  • [arxiv:paper-id] -学术论文
  • [deep_analysis] -LLM推理

例子:

LangSmith provides dataset management [context7:langsmith] which supports 
version control [perplexity:langsmith-docs] as validated in recent research 
[arxiv:2024.12345].

上下文高效的报告结构

报告使用 分段式建筑 对于AI消费:

  1. 执行摘要 -概述+带ID和线条范围的部分索引
  2. 按需阅读 -AI只能加载特定部分
  3. 快速参考 -引文示例(R-ID:section, R-ID:section:20-50)

示例用法:

read_report(citation="R-182602:q1")          # Read sub-question 1
read_report(citation="R-182602:q1:20-50")    # Lines 20-50 of sub-Q 1
read_report(citation="R-182602", full=true)  # Full report (last resort)

这可以防止上下文膨胀——AI助手只加载他们需要的东西。

常见问题

困惑API错误

  • 401未经授权:检查一下 PERPLEXITY_API_KEY 设置正确
  • 429价格有限:您已超过API配额。检查 困惑仪表板
  • 连接超时:验证网络连接

Context7或arXiv连接问题

这些作为子流程生成。检查:

# Verify Context7 MCP is accessible (if installed separately)
# Verify arXiv MCP server is installed:
uv tool run arxiv-mcp-server --help

arXiv MCP服务器初始化失败(隔离环境中的EOF错误):

如果你看到 Error: calling "initialize": EOF 在PATH受限的环境中(例如,反重力、CI/CD),服务器可能无法找到 uv 二元的。解决:

  1. 设置UV_BINARY_PATH环境变量 (建议用于隔离环境):
{
  "mcpServers": {
    "research": {
      "command": "node",
      "args": ["/path/to/deep-research-mcp/dist/index.js"],
      "env": {
        "UV_BINARY_PATH": "/opt/homebrew/bin/uv",  // Apple Silicon
        // or "/usr/local/bin/uv" for Intel Mac / Linux
        "PERPLEXITY_API_KEY": "your-key",
        "GEMINI_API_KEY": "your-key"
      }
    }
  }
}
  1. 安装uv 如果尚未安装:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. 常见的紫外线安装路径 (如果不在PATH中,则自动选中):
    • /opt/homebrew/bin/uv (苹果硅自制)
    • /usr/local/bin/uv (英特尔Mac Homebrew/Linux)
    • ~/.local/bin/uv (用户本地安装)
    • ~/.cargo/bin/uv (货物安装)

服务器现在使用 延迟初始化 -arXiv客户端仅在以下情况下创建 read_paper 或 download_paper 实际上调用了工具,以防止初始化失败。

MCP客户端未检测到服务器

  1. 验证MCP配置中的路径是否正确(绝对路径)
  2. 重新启动MCP客户端(Claude Desktop、Cursor等)
  3. 检查客户端日志中的连接错误:
    • 克劳德桌面版: ~/Library/Logs/Claude/
    • 光标:开发人员工具→ 控制台

环境变量未加载

如果您看到“未连接”错误,尽管MCP配置中有API密钥,请尝试以下解决方案:

选项1:使用内置的JavaScript文件 (推荐)

{
  "mcpServers": {
    "research": {
      "command": "node",
      "args": ["/absolute/path/to/research-mcp/dist/index.js"],
      "env": {
        "PERPLEXITY_API_KEY": "your-key",
        "GEMINI_API_KEY": "your-key",
        "OPENAI_API_KEY": "your-key"
      }
    }
  }
}

选项2:用空格固定路径

如果您的路径包含空格(例如。, /Users/name/Desktop/Personal and learning/...):

{
  "command": "npx",
  "args": [
    "tsx",
    "/Users/name/Desktop/Personal and learning/quick-mcp/research/src/index.ts"
  ]
}

注意:带空格的路径在JSON数组中处理得当。问题通常是使用源文件而不是构建文件。

输出结构示例

# Research Results: [Your Query]

## Complexity Assessment

**Level**: 4/5
**Reasoning**: Complex research requiring academic papers and library documentation

## Research Action Plan

**Estimated Time**: ~45s

**Steps Executed**:
1. **perplexity**: Search for recent approaches and best practices _(parallel)_
2. **deep_analysis**: Analyze web findings for technical insights
3. **context7**: Fetch React and TypeScript documentation _(parallel, shared + specific)_
4. **arxiv**: Search academic papers on evaluation datasets
5. **consensus**: Validate findings across multiple models

## Synthesis with Inline Citations

### Overview

LangSmith provides comprehensive dataset management [context7:langsmith] which enables
evaluation workflow automation [perplexity:langsmith-docs]. Recent research shows that
synthetic data generation requires careful attention to distribution matching [arxiv:2024.12345].

\`\`\`typescript
// Code validated against Context7
import { Dataset } from "langsmith";

const dataset = new Dataset("my-eval-set");
\`\`\`

### Sub-Question 1: What makes evaluation data representative?

Representative data must match real-world distributions [deep_analysis] and include
edge cases from production logs [context7:langsmith]. Studies indicate that 600+ examples
provide sufficient statistical power for small effect detection [arxiv:2024.67890].

## Code Validation Summary

✅ 3 code blocks validated
✅ 1 syntax correction applied (outdated API method)

## Multi-Model Consensus
[3 LLMs validated findings—shows agreement/disagreement]

## Critical Challenge
[Critical validation—alternative perspectives and gaps identified]

## Quality Validation

**Vote Result**: 2 sufficient, 1 insufficient
**Status**: ✅ Response is sufficient

**Model Feedback**:
- ✅ **gemini-3-flash-preview**: Response comprehensively addresses the query with actionable steps
- ✅ **gpt-5-mini-2025-08-07**: Good coverage of edge cases and validation methods
- ❌ **claude-3.5-haiku**: Could benefit from more code examples

---

**Report ID**: R-182602

**Usage Examples**:
\`\`\`
read_report(citation="R-182602:overview")      # Read overview section
read_report(citation="R-182602:q1")            # Read sub-question 1
read_report(citation="R-182602:q1:20-50")      # Lines 20-50 of sub-Q 1
read_report(citation="R-182602", full=true)    # Full report (last resort)
\`\`\`

此MCP构建在其他MCP服务器和工具之上

  • 困惑AI -网络搜索功能
  • arXiv -学术论文库
  • 背景7 -图书馆文献检索
  • 本项目的所有贡献者和用户

基准测试

该项目包括全面的基准测试工具,用于将MCP研究质量与困惑基线进行比较:

运行基准

# Generate responses for benchmark dataset
npm run benchmark:generate              # Generate only missing responses
npm run benchmark:generate:new-set      # Clear all responses and start fresh

# Regenerate only a single category (useful for iterating on a category). Example:
npm run benchmark:generate -- --category synthesis --force

# Run full benchmark comparison (generates new results)
npm run benchmark:compare

# View latest benchmark results
npm run benchmark:view

# Compare multiple benchmark runs over time
npm run benchmark:compare-results

响应生成选项:

  • benchmark:generate -仅为尚未生成响应的样本生成响应(增量)
  • benchmark:generate:new-set -清除所有现有响应并从头开始重新生成(在代码库更改后使用)
  • benchmark:generate -- --category <name> --force -仅重新生成一个类别(例如。, synthesis)无论反应年龄如何

这使您能够:

  1. 更改您的研究代码库
  2. 跑 npm run benchmark:generate:new-set 用新代码重新生成所有响应
  3. 使用以下方法将结果与之前的基准进行比较 benchmark:compare-results

查看结果

运行基准测试后,您可以随时轻松查看结果:

  • npm run benchmark:view -显示详细的决策矩阵和建议
  • npm run benchmark:compare-results -将多个运行与趋势指标并排比较(↑↓→)

示例输出来自 benchmark:view:

================================================================================
DECISION MATRIX: MCP vs Perplexity
Generated: 2025-12-21T02:17:33.512Z
Total Comparisons: 69
================================================================================

RECOMMENDATIONS
--------------------------------------------------------------------------------

Use Perplexity for:
  - multi_hop_reasoning (win rate: 80%, p<0.05)
  - synthesis (win rate: 90%, p<0.05)
  - latency-critical tasks (<2s vs ~5min)

No clear winner (prefer lower cost):
  - single_hop_factual (60% vs 40%, p=0.63)

DETAILED BREAKDOWN
--------------------------------------------------------------------------------
Category              | MCP Win  | P(Sup)  | 95% CI          | Recommendation
--------------------------------------------------------------------------------
single_hop_factual    | 60%      | 0.63    | [-0.80, 1.30]   | TIE
multi_hop_reasoning   | 20%      | 0.01    | [-2.20, -0.35]  | USE_PERPLEXITY

SWITCHING POINTS:
  - Simple factual lookup: USE PERPLEXITY (faster)

示例输出来自 benchmark:compare-results:

====================================================================================================
BENCHMARK COMPARISON
2 benchmark runs found
====================================================================================================

Category              | Run 1         | Run 2         
----------------------|---------------|---------------
                      | Dec 20, 09:30 | Dec 21, 02:17 
----------------------|---------------|---------------
single_hop_factual    | 70%           | 60% ↓         
multi_hop_reasoning   | 30%           | 20% ↓         
synthesis             | 10% →         | 10% →         

RECOMMENDATION CHANGES
----------------------------------------------------------------------------------------------------
single_hop_factual: Run 1: TIE → Run 2: TIE
multi_hop_reasoning: Run 1: TIE → Run 2: USE_PERPLEXITY

Legend: ↑ = improved, ↓ = declined, → = stable

结果存储在 benchmarks/results/ 作为带有时间戳的JSON文件。