Skip to main content
Glama

带有模型上下文协议的脑机接口(BCI-MCP)

该项目将脑机接口 (BCI) 技术与模型上下文协议 (MCP) 相结合,为神经信号采集、处理和人工智能交互创建一个强大的框架。

GitHub 页面 许可证:MIT

概述

BCI-MCP 结合了:

  • 脑机接口(BCI) :实时采集和处理神经信号

  • 模型上下文协议(MCP) :标准化AI通信接口

这种集成使得医疗保健、无障碍、研究和人机交互等领域的高级应用成为可能。

Related MCP server: KOI-MCP Integration

主要特点

BCI 核心功能

  • 神经信号采集:实时捕捉大脑活动的电信号

  • 信号处理:预处理、提取特征和分类脑信号

  • 命令生成:将解释的脑信号转换为命令

  • 反馈机制:提供反馈以帮助用户提高控制

  • 实时操作:以最小延迟处理大脑活动

MCP 集成功能

  • 标准化上下文共享:使用 MCP 将 BCI 数据与 AI 模型连接起来

  • 工具曝光:让 BCI 功能可用于 AI 应用程序

  • 可组合工作流程:构建结合 BCI 信号和 AI 处理的复杂操作

  • 安全数据交换:实现隐私保护的神经数据传输

系统架构

BCI-MCP系统由几个关键组件组成:

┌─────────────────┐      ┌─────────────────┐      ┌─────────────────┐
│                 │      │                 │      │                 │
│  BCI Hardware   │──────│  BCI Software   │──────│   MCP Server    │
│                 │      │                 │      │                 │
└─────────────────┘      └─────────────────┘      └────────┬────────┘
                                                           │
                                                           │
                                                  ┌────────▼────────┐
                                                  │                 │
                                                  │  AI Applications │
                                                  │                 │
                                                  └─────────────────┘

入门

先决条件

  • Python 3.10+

  • 兼容的EEG硬件(或使用模拟模式进行测试)

  • requirements.txt 中列出的其他依赖项

安装

# Clone the repository
git clone https://github.com/enkhbold470/bci-mcp.git
cd bci-mcp

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

使用 Docker

为了更容易设置,您可以使用 Docker:

# Build and start all services
docker-compose up -d

# Access the documentation at http://localhost:8000
# The MCP server will be available at ws://localhost:8765

基本用法

# Start the MCP server
python src/main.py --server

# Or use the interactive console
python src/main.py --interactive

# List available EEG devices
python src/main.py --list-ports

# Record a 60-second BCI session
python src/main.py --port /dev/tty.usbmodem1101 --record 60

高级应用程序

BCI-MCP 集成支持一系列尖端应用:

医疗保健和无障碍

  • 辅助技术:使行动不便人士能够控制设备

  • 康复:通过实时反馈支持神经康复

  • 诊断工具:辅助诊断神经系统疾病

研究与开发

  • 神经科学研究:促进大脑功能和认知的研究

  • BCI 训练:加速学习和适应 BCI 控制

  • 协议开发:建立神经数据交换标准

人工智能增强界面

  • 自适应界面:根据神经信号和人工智能辅助进行调整的界面

  • 意图识别:通过神经信号更好地理解用户意图

  • 增强沟通:增强言语障碍人士的沟通能力

文档

项目文档托管在 GitHub Pages 上: https://enkhbold470.github.io/bci-mcp/

维护文档

本文档使用 MkDocs 和 Material 主题构建。更新文档:

  1. 对main分支上docs/目录中的 Markdown 文件进行更改

  2. 提交并将更改推送到main分支

  3. GitHub Actions 工作流程将自动构建更新的文档并将其部署到 GitHub Pages

本地文档开发

要在本地使用文档:

  1. 安装所需的依赖项:

    pip install mkdocs-material mkdocstrings mkdocstrings-python
  2. 运行本地服务器:

    mkdocs serve
  3. 查看文档: http://localhost:8000

项目结构

.
├── docs/                  # Documentation files
│   ├── api/               # API Documentation
│   ├── features/          # Feature Documentation
│   ├── getting-started/   # Getting Started Guides
│   └── index.md           # Documentation Home Page
├── mkdocs.yml             # MkDocs Configuration
└── .github/workflows/     # GitHub Actions Workflows

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

  1. 分叉存储库

  2. 创建功能分支( git checkout -b feature/amazing-feature )

  3. 提交您的更改( git commit -m 'Add some amazing feature' )

  4. 推送到分支( git push origin feature/amazing-feature )

  5. 打开拉取请求

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

致谢

接触

Enkhbold Ganbold - GitHub 个人资料

项目链接: https://github.com/enkhbold470/bci-mcp

Available Tools

14 tools
calibrateC

Capture a baseline so focus/calm/etc. are personalized to the wearer.

Inputs: seconds, condition.

connectB

Connect to an EEG device and start streaming. Default is the synthetic brain.

Inputs: device_uri.

disconnectA

Disconnect from the current EEG device.

Inputs: no named parameters.

get_band_powersB

Get absolute and relative EEG band powers (delta, theta, alpha, beta, gamma).

Inputs: no named parameters.

get_brain_stateA

Get the current brain state. Returns heuristic band-power proxy metrics (focus, calm, attention, engagement, fatigue, meditation), band powers, and signal quality. Each reading carries confidence (0..1), per-metric metric_confidence, and a status ('ok'/'warming_up'/'unreliable') — weight the metrics by these and do not interpret an unreliable/low-confidence reading. Call get_metric_definitions to learn what each metric means.

Inputs: no named parameters.

get_metric_definitionsA

Explain each brain metric: its exact formula, the literature it draws on (with DOIs under references), and an honest caveat. Call this to learn what focus/calm/attention/engagement/fatigue/meditation actually measure and how much to trust them — they are heuristic proxies, not validated cognitive measurements. Cite a reference only for its role: a caveat source contests the metric and must never be cited as support.

Inputs: no named parameters.

get_neurofeedback_scoreA

Sample the current neurofeedback score (in-zone now + cumulative %).

Inputs: no named parameters.

get_pipeline_limitationsA

What this pipeline can and cannot do: the exact analysis method (Welch PSD window, band edges, filters), a plain-English list of limitations (it averages transients out, is not clinical/qEEG, metrics are heuristic proxies, no source localization/connectivity), and its intended use. Read this before drawing any conclusion from the metrics — especially do not present them as clinical, diagnostic, or event-level (ERP/spindle) results.

Inputs: no named parameters.

get_signal_qualityA

Get electrode signal quality, reading confidence, and detected artifacts (blink, railing, emg, flatline).

Inputs: no named parameters.

list_devicesA

List EEG devices/URIs you can connect to.

Inputs: no named parameters.

mark_eventC

Annotate the live stream with a labeled event marker.

Inputs: label (required).

recordB

Record the live stream for N seconds to a file (npz/csv/edf).

Inputs: fmt, path, seconds.

start_neurofeedbackC

Begin a neurofeedback session rewarding time spent above a metric target.

Inputs: metric, target.

stream_summaryB

Current brain-state snapshot. (The seconds window for rolling stats arrives in a later phase; this currently returns the live reading.)

Inputs: seconds.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 14 tools

    Disambiguation3/5

    Most tools target distinct actions, but get_brain_state, get_band_powers, get_signal_quality, and stream_summary overlap significantly because get_brain_state already bundles band powers, metrics, and signal quality. stream_summary is especially vague and its description admits it currently returns only the live reading, making it hard to distinguish from get_brain_state.

    Naming Consistency4/5

    The set mostly follows a predictable snake_case pattern with clear verb/noun forms such as list_devices, get_brain_state, mark_event, and start_neurofeedback. Minor deviations are bare verbs like connect, disconnect, record, and calibrate, plus the noun-like stream_summary, but these remain readable and conventional for session lifecycle actions.

    Tool Count5/5

    Fourteen tools is well-scoped for an EEG/BCI server that needs device lifecycle, signal inspection, calibration, events, recording, and neurofeedback. Each tool generally corresponds to a meaningful part of the live BCI workflow without excessive surface area.

    Completeness4/5

    The surface covers the core lifecycle: device discovery, connect/disconnect, signal and brain-state reads, calibration, event marking, recording, and neurofeedback start/score. Minor gaps remain, notably no explicit stop_neurofeedback or clear session-stop operation beyond disconnect, and marker/event retrieval is absent.

    Maintenance

    ActivityMaintained
    ResponsivenessMixed handling

    Related MCP Connectors

    Related MCP Servers