Brainstorm

Brainstorm

Enables AI agents to communicate, coordinate, and collaborate on complex tasks through a local MCP server.

Category
访问服务器

README

Brainstorm

MCP server enabling structured collaboration between AI agents.

Brainstorm allows multiple Claude Code instances on the same computer to communicate, coordinate, and collaborate on complex tasks through a local MCP server.

What Is Brainstorm?

Brainstorm is a Model Context Protocol (MCP) server that enables AI agents to collaborate with each other. Instead of isolated single-agent workflows, multiple AI agent instances can coordinate through structured communication, shared resources, and persistent state management.

Think of it as Slack for AI agents — a local service where different Claude Code terminal windows join projects, exchange messages, and work together on tasks that benefit from multi-perspective analysis.

Why Brainstorm Exists

Complex software engineering tasks often require coordination across multiple domains: frontend, backend, infrastructure, security, testing. Traditional single-agent workflows struggle with:

  • Context fragmentation: Different aspects of a problem require different expertise
  • Decision coordination: Architectural choices need input from multiple perspectives
  • Workload distribution: Large refactorings benefit from parallel work streams
  • Human-in-the-loop coordination: Coordinators facilitate approval workflows between agents and human supervisors

Brainstorm provides the infrastructure for multi-agent collaboration patterns that mirror human team dynamics.

Key Features

  • Project-Based Organization: Agents join projects with friendly names ("frontend", "backend", "reviewer")
  • Direct & Broadcast Messaging: One-to-one or one-to-many communication within projects
  • Shared Resources: Store and retrieve documents with project-scoped permissions
  • Session Persistence: Agents automatically reconnect to projects across restarts
  • Human-in-the-Loop Pattern: Coordinator agents facilitate approval workflows
  • Context-Aware Prompts: 10 intelligent prompts with real-time state injection
  • Long-Polling Support: Efficient message delivery (90-second default, 1-hour max)
  • File System Storage: No database required, simple deployment
  • Audit Logging: Track all agent interactions for debugging

How It Works

Architecture Overview

Brainstorm provides a three-layer architecture:

  1. MCP Protocol Layer: Exposes 14 tools via stdio transport for agent cooperation
  2. Storage Abstraction: File-based persistence with atomic operations and locking
  3. Type System: Forward-compatible data models for projects, messages, resources

Agent Interaction Pattern

1. Agent instances connect to Brainstorm MCP server
   ↓
2. Agents join projects with friendly names
   ↓
3. Agents communicate via direct or broadcast messages
   ↓
4. Agents share resources within project scope
   ↓
5. Agents receive real-time updates via long-polling

Example Deployment

Open multiple terminal windows on your computer, each running Claude Code:

  • Terminal 1: Frontend project → Joins as agent "frontend"
  • Terminal 2: Backend project → Joins as agent "backend"
  • Terminal 3: DevOps project → Joins as agent "devops"

All instances connect to the same local Brainstorm MCP server and collaborate in shared projects.

Installation

npm install
npm run build

Requirements: Node.js 18+

Quick Setup

To automatically configure this MCP server in Claude Code:

npm run config

This builds the project and adds the server to ~/.claude/mcp_config.json. Restart Claude Code to activate.

Run the Demos

See agent cooperation in action! Multiple demos showcase different collaboration patterns.

🎮 Tic-Tac-Toe

Two Claude Code agents play tic-tac-toe, coordinating moves and updating shared game state.

Terminal 1:

cd demos/tic-tac-toe && ./player-x.sh

Terminal 2:

cd demos/tic-tac-toe && ./player-o.sh

🗣️ Debate

Two agents debate opposite stances using web search, challenging arguments until reaching evidence-based consensus.

Terminal 1:

cd demos/debate && ./agent-a.sh

Terminal 2:

cd demos/debate && ./agent-b.sh

More Demos

  • 🐜 Pathfinding: Multiple agents navigate a maze with live web visualization
  • 🔬 Research Consensus: Three agents collaborate on research with different perspectives
  • 📦 File Storage: Demonstrates large file resource sharing

See demos/README.md for complete documentation.

Manual Configuration

Add to ~/.claude/mcp_config.json:

{
  "mcpServers": {
    "brainstorm": {
      "command": "node",
      "args": ["/absolute/path/to/brainstorm/dist/src/index.js"]
    }
  }
}

Environment Variables:

  • BRAINSTORM_STORAGE: Custom storage path (default: ~/.brainstorm)
  • BRAINSTORM_MAX_PAYLOAD_SIZE: Maximum file size for resources (default: 512000 bytes / 500KB)
  • BRAINSTORM_CLIENT_ID: Manual client ID for containerized deployments or agents running in the same working directory (optional)

Architecture

Three-Layer Design

  1. MCP Protocol Layer (src/server.ts)

    • Implements MCP server via stdio transport
    • Exposes 14 tools for agent cooperation
    • Provides 10 context-aware prompts for guided workflows
    • Enforces coordinator pattern for human-in-the-loop workflows
  2. Storage Abstraction Layer (src/storage.ts)

    • File-based persistence with atomic writes
    • Cross-platform locking using O_CREAT|O_EXCL
    • Handles concurrency for messages and member updates
    • Migration-ready for future database backend
  3. Type System (src/types.ts)

    • Core models: ProjectMetadata, AgentMetadata, Message, ResourceManifest
    • All types include schema_version for forward compatibility
    • Designed to map one-to-one with database tables

Key Design Patterns

  • Atomic Operations: Temp file → fsync → atomic rename for durability
  • Message Flow: Direct messages to inbox, broadcasts via fan-out copy
  • File Locking: Exclusive creation flags with 30-second stale timeout
  • Long-Polling: 2-second intervals, configurable timeout (default 90s, max 3600s)

Storage Structure

~/.brainstorm/
├── projects/<project-id>/
│   ├── metadata.json
│   ├── members/<agent-name>.json
│   ├── messages/<agent-name>/<timestamp-uuid>.json
│   └── resources/<resource-id>/
├── clients/<client-id>/
│   ├── identity.json
│   └── memberships.json
└── system/
    ├── config.json
    └── audit.log

Security Model

Trust Model: Brainstorm assumes cooperative agents, not adversarial ones. Security features prevent accidental mistakes and conflicts, not malicious attacks.

Protections:

  • Path traversal prevention (whitelist validation)
  • Resource permissions (deny-by-default)
  • DoS protection (connection limits)
  • Payload validation (JSON depth limits)
  • Audit logging for all operations

Use Case: Local development and trusted agent coordination, not multi-tenant or untrusted environments.

Development & Contributing

# Watch mode for development
npm run dev

# Run security tests
npm test

# Lint code
npm run lint

Test suite includes 57 tests covering security, concurrency, and feature functionality.

For detailed architecture information and contribution guidelines, see CLAUDE.md.

Known Limitations

Brainstorm is a proof-of-concept optimized for local development:

  • Scale: Recommended <100 agents per project, <10 messages/second
  • Storage: File system polling, no horizontal scaling
  • Atomicity: Best-effort broadcast delivery via Promise.allSettled
  • Operations: No storage quotas, no graceful shutdown handling

For production use, consider migrating to a database backend (SQLite/PostgreSQL). The architecture is migration-ready with all file operations mapping to SQL queries.

License

Business Source License 1.1 with automatic conversion to Apache 2.0 on October 29, 2029.

What This Means:

  • Development, testing, research: Free for all non-production use
  • Production deployments: Requires a separate commercial license
  • Future open source: On October 29, 2029, this code automatically becomes Apache 2.0 licensed (fully open source)

Why BSL?

We chose BSL 1.1 to:

  1. Keep the code public and transparent for developers and researchers
  2. Protect the ability to develop commercial offerings based on this work
  3. Ensure the project becomes fully open source within 4 years

Production use? Contact the licensor for commercial licensing options.

See LICENSE for full legal terms.


DISCLAIMER: This project has "works on my computer™" status. I hope it works on yours too. Otherwise, feel free to fork.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选