Skip to main content
Glama

mcp-research-collective

一个基于 Model Context Protocol (MCP) 构建的多智能体研究系统。专业智能体(规划者 → 研究员 → 推理者)通过共享信念的线程安全 黑板 进行协作,并作为 MCP 工具公开,可以连接到 Claude Desktop 或任何其他 MCP 主机。

Python License Local-first MCP Async

此项目展示了什么

  • Model Context Protocol — 一个真实、可运行的 FastMCP 服务器,包含七个工具(blackboard_set、blackboard_get、blackboard_query、blackboard_dump,以及 add/subtract/multiply/divide)。

  • 黑板架构 — 一个线程安全的共享信念存储(Belief 数据类 + 带有 RLock 保护的 upsert/read/query、TTL、正则表达式查询和标签过滤器的 Blackboard 类)。

  • 多智能体编排 — 规划者分解提示词 → 研究员从 JSON 知识库中获取事实 → 推理者合成最终答案。智能体只了解连接器,从不直接了解彼此;它们仅通过黑板进行协调。

  • 两种可互换的传输方式 — 用于快速笔记本/测试运行的进程内 MCPConnector,以及用于生产环境/Claude Desktop 集成的实际 STDIO FastMCP 服务器。

Related MCP server: deep-research

技术栈

  • Model Context Protocol Python SDK (mcp[cli]) — FastMCP 服务器、ClientSession、STDIO 传输

  • Python 3.10+、asyncio、threading.RLock

  • pytest 用于确定性的黑板/智能体测试

  • 无 LLM 依赖 — 此演示中的智能体在结构化知识库上进行编排。MCP 服务器是 你(或任何 MCP 主机)可以连接 LLM 的接口。

架构

flowchart TB
    U[User Prompt] --> P[PlannerAgent<br/>decomposes into subtasks]
    P -->|publishes 'task.list'| BB[(Blackboard<br/>thread-safe<br/>belief store)]
    BB -->|reads tasks| R[ResearchAgent<br/>fetches from kb/*.json]
    R -->|publishes belief.what / why / how| BB
    BB -->|reads beliefs| S[ReasonerAgent<br/>synthesizes answer]
    S -->|publishes answer.v1| BB
    S --> Out[Final answer<br/>+ full blackboard state]

    subgraph "MCP Surface"
        BB <-->|set/get/query/dump| MCP[FastMCP server<br/>STDIO transport]
        MCP <-->|JSON-RPC| Claude[Claude Desktop /<br/>any MCP host]
    end

快速入门

# 1. Python env
python -m venv .venv
source .venv/Scripts/activate   # Windows: .venv\Scripts\activate
pip install -e .[dev]

# 2. Run the deterministic tests
pytest

# 3. Run the in-process orchestrator from the CLI
mcp-research-orchestrator "What is a Faculty Senate, why have one, and how is it built?"

# 4. Run the standalone MCP server (for Claude Desktop or another MCP host)
mcp-research-collective

程序化使用(进程内,无 STDIO)

from mcp_research_collective import run_collective

answer, blackboard_state_json = run_collective(
    "What is the role of a Faculty Senate and why have one?"
)

print(answer)
# # Synthesized Answer
#
# **What it is**
# - Elected body of faculty that represents the academic community...
# ...
# **Why it matters**
# - Ensures academic decisions are not solely administrative
# ...

与 Claude Desktop 一起使用

这是其独特之处:运行进程内演示的相同代码也是一个可连接到 Claude Desktop 的工作 MCP 服务器。将其添加到你的 claude_desktop_config.json 中:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "research-collective": {
      "command": "python",
      "args": ["-m", "mcp_research_collective.entrypoints.run_server"],
      "env": {
        "PYTHONPATH": "/absolute/path/to/mcp-research-collective/src"
      }
    }
  }
}

重启 Claude Desktop 后,你将在 Claude UI 中看到四个 blackboard_* 工具和四个数学工具。尝试:

使用 blackboard_set 工具发布关于我项目截止日期的事实,然后使用 blackboard_query 将其找回。

添加新的研究主题

在 src/mcp_research_collective/kb/ 中放入一个 JSON 文件,格式如下:

{
  "key": "topic.subkey",
  "what": ["fact 1", "fact 2"],
  "why":  ["fact 1", "fact 2"],
  "how":  ["fact 1", "fact 2"]
}

然后使用 topic_key="topic.subkey" 构建编排器。无需更改代码。

我的收获

带有黑板的“规划者→研究员→推理者”模式使得每个智能体的职责足够小,可以独立进行推理。系统根据提示词动态调整其工作量:仅询问“是什么”和“为什么”会导致规划者仅发布 define.what 和 explain.why。研究员获取所需的确切内容,而黑板跟踪这种选择性的上下文收集。

最大的收获不是 MCP 线格式,而是强制所有状态变更通过 mcp.call("blackboard.set", ...) 的纪律。这单一的瓶颈使得整个系统变得极其易于观察:dump_state() 可以准确显示每个智能体贡献了什么、何时贡献以及以何种置信度贡献。添加第四个智能体(如评论者或缓存)非常简单,因为契约仅仅是“读取带标签的信念,写入带标签的信念”。

项目布局

mcp-research-collective/
├── src/mcp_research_collective/
│   ├── blackboard.py        # Belief + thread-safe Blackboard
│   ├── connector.py         # In-process MCPConnector (set/get/query/dump)
│   ├── kb/*.json            # Knowledge base topics (drop-in JSON files)
│   ├── knowledge_base.py    # Loader for kb/*.json
│   ├── agents.py            # PlannerAgent, ResearchAgent, ReasonerAgent
│   ├── orchestrator.py      # CollectiveOrchestrator + run_collective
│   ├── mcp_server.py        # FastMCP server exposing blackboard + math tools
│   └── entrypoints/
│       ├── run_server.py        # `python -m ... run_server`
│       └── run_orchestrator.py  # `python -m ... run_orchestrator "<q>"`
├── tests/                   # blackboard + connector + orchestrator + KB tests
└── notebooks/demo.ipynb     # walkthrough with full blackboard state dump

Available Tools

8 tools
addB

Sum two numbers.

Inputs: a (required), b (required). Returns: result

blackboard_dumpA

Return the full (non-expired) blackboard state.

Inputs: no named parameters. Returns: object

blackboard_getA

Read a single belief by key. Returns None if absent or expired.

Inputs: key (required). Returns: result

blackboard_queryB

Query beliefs by regex pattern (over key or string value) and/or tag.

Inputs: pattern, tag. Returns: result

blackboard_setB

Publish a belief to the shared blackboard.

Returns the stored belief as a dict (with timestamp + provenance).

Inputs: key (required), value (required), source, confidence, +1 more. Returns: object

divideA

Divide a by b. Raises if b == 0.

Inputs: a (required), b (required). Returns: result

multiplyA

Multiply two numbers.

Inputs: a (required), b (required). Returns: result

subtractA

Subtract b from a.

Inputs: a (required), b (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 8 tools

    Disambiguation5/5

    All tools have clearly distinct purposes: the four arithmetic operations are separate, and the four blackboard operations (set, get, query, dump) each serve unique functions. There is no overlap or ambiguity.

    Naming Consistency3/5

    Arithmetic tools use single verbs (add, subtract, multiply, divide) while blackboard tools use a noun_verb pattern (blackboard_dump, blackboard_get, blackboard_query, blackboard_set). This inconsistency in naming convention across the server reduces coherence.

    Tool Count5/5

    With 8 tools covering two distinct subdomains (arithmetic and blackboard), the count feels well-scoped. Each tool serves a clear purpose without unnecessary duplication or bloat.

    Completeness4/5

    The arithmetic set is complete for basic operations. The blackboard tools are mostly complete but lack a delete/remove operation, which could be a gap for typical blackboard use cases. Minor gap.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      B
      maintenance
      File-based multi-agent coordination with persistent tasks, reports, issues and reviews. FCoP 4.0.5 provides 25 canonical MCP tools and 6 read-only resources over local stdio. Work stays in your project as Markdown records, with task lifecycle validation and branch workflows. Includes a Python API and a CLI for setup, inspection and diagnostics.
      25
      50 PyPI
      4
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables deep research tasks using a multi-agent architecture that integrates any LLM and MCP tools. Available via MCP stdio, streamable HTTP, and SSE transports.
      16
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A multi-tool task agent MCP server with file search, SQLite query, calculator, and report writing tools. Enables Claude Code, Claude Desktop, or Cursor to control the same tools used by the agent, with guardrails for safety.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Shared memory and orchestration for coding agents, enabling persistent knowledge, multi-agent coordination, and a canonical workflow across MCP-compatible AI clients.
      83
      -