bci-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bci_mcp-0.1.0/.cursor/rules/git-commits.mdc +22 -0
- bci_mcp-0.1.0/.env +1 -0
- bci_mcp-0.1.0/.githooks/prepare-commit-msg +7 -0
- bci_mcp-0.1.0/.github/workflows/ci.yml +22 -0
- bci_mcp-0.1.0/.github/workflows/deploy-pages.yml +46 -0
- bci_mcp-0.1.0/.gitignore +43 -0
- bci_mcp-0.1.0/.nojekyll +0 -0
- bci_mcp-0.1.0/AGENTS.md +36 -0
- bci_mcp-0.1.0/CHANGELOG.md +8 -0
- bci_mcp-0.1.0/CITATION.cff +16 -0
- bci_mcp-0.1.0/CLAUDE.md +107 -0
- bci_mcp-0.1.0/CONTRIBUTING.md +31 -0
- bci_mcp-0.1.0/Dockerfile +28 -0
- bci_mcp-0.1.0/LICENSE +21 -0
- bci_mcp-0.1.0/PKG-INFO +287 -0
- bci_mcp-0.1.0/README.md +228 -0
- bci_mcp-0.1.0/docker-compose.yml +27 -0
- bci_mcp-0.1.0/docs/api/bci-module.md +8 -0
- bci_mcp-0.1.0/docs/api/mcp-module.md +5 -0
- bci_mcp-0.1.0/docs/assets/hero.svg +72 -0
- bci_mcp-0.1.0/docs/changelog.md +9 -0
- bci_mcp-0.1.0/docs/contributing.md +24 -0
- bci_mcp-0.1.0/docs/features/bci-features.md +72 -0
- bci_mcp-0.1.0/docs/features/mcp-integration.md +76 -0
- bci_mcp-0.1.0/docs/features/signal-processing.md +74 -0
- bci_mcp-0.1.0/docs/getting-started/configuration.md +82 -0
- bci_mcp-0.1.0/docs/getting-started/installation.md +36 -0
- bci_mcp-0.1.0/docs/getting-started/quick-start.md +92 -0
- bci_mcp-0.1.0/docs/github-topics.md +11 -0
- bci_mcp-0.1.0/docs/index.md +75 -0
- bci_mcp-0.1.0/docs/superpowers/plans/2026-06-23-bci-mcp-foundation-and-mcp.md +2054 -0
- bci_mcp-0.1.0/docs/superpowers/plans/2026-06-23-bci-mcp-hardware-devices.md +1004 -0
- bci_mcp-0.1.0/docs/superpowers/plans/2026-06-23-bci-mcp-polish-seo.md +485 -0
- bci_mcp-0.1.0/docs/superpowers/plans/2026-06-23-bci-mcp-wow-features.md +1033 -0
- bci_mcp-0.1.0/docs/superpowers/specs/2026-06-23-bci-mcp-brain-ai-bridge-design.md +290 -0
- bci_mcp-0.1.0/examples/README.md +17 -0
- bci_mcp-0.1.0/examples/claude_desktop_config.json +8 -0
- bci_mcp-0.1.0/examples/mcp_quickstart.py +23 -0
- bci_mcp-0.1.0/examples/record_and_analyze.py +27 -0
- bci_mcp-0.1.0/hooks.py +36 -0
- bci_mcp-0.1.0/llms.txt +25 -0
- bci_mcp-0.1.0/mkdocs.yml +70 -0
- bci_mcp-0.1.0/pyproject.toml +59 -0
- bci_mcp-0.1.0/src/bci_mcp/__init__.py +5 -0
- bci_mcp-0.1.0/src/bci_mcp/cli.py +150 -0
- bci_mcp-0.1.0/src/bci_mcp/core/__init__.py +0 -0
- bci_mcp-0.1.0/src/bci_mcp/core/device.py +55 -0
- bci_mcp-0.1.0/src/bci_mcp/core/registry.py +48 -0
- bci_mcp-0.1.0/src/bci_mcp/core/ringbuffer.py +45 -0
- bci_mcp-0.1.0/src/bci_mcp/core/stream.py +65 -0
- bci_mcp-0.1.0/src/bci_mcp/dashboard/__init__.py +0 -0
- bci_mcp-0.1.0/src/bci_mcp/dashboard/server.py +52 -0
- bci_mcp-0.1.0/src/bci_mcp/dashboard/static/index.html +64 -0
- bci_mcp-0.1.0/src/bci_mcp/devices/__init__.py +13 -0
- bci_mcp-0.1.0/src/bci_mcp/devices/brainflow_device.py +73 -0
- bci_mcp-0.1.0/src/bci_mcp/devices/lsl_device.py +65 -0
- bci_mcp-0.1.0/src/bci_mcp/devices/neurofocus.py +212 -0
- bci_mcp-0.1.0/src/bci_mcp/devices/neurofocus_protocol.py +49 -0
- bci_mcp-0.1.0/src/bci_mcp/devices/playback.py +64 -0
- bci_mcp-0.1.0/src/bci_mcp/devices/serial_device.py +106 -0
- bci_mcp-0.1.0/src/bci_mcp/devices/synthetic.py +81 -0
- bci_mcp-0.1.0/src/bci_mcp/dsp/__init__.py +0 -0
- bci_mcp-0.1.0/src/bci_mcp/dsp/bands.py +34 -0
- bci_mcp-0.1.0/src/bci_mcp/dsp/calibration.py +57 -0
- bci_mcp-0.1.0/src/bci_mcp/dsp/filters.py +19 -0
- bci_mcp-0.1.0/src/bci_mcp/dsp/metrics.py +19 -0
- bci_mcp-0.1.0/src/bci_mcp/dsp/quality.py +26 -0
- bci_mcp-0.1.0/src/bci_mcp/dsp/state.py +30 -0
- bci_mcp-0.1.0/src/bci_mcp/lsl/__init__.py +0 -0
- bci_mcp-0.1.0/src/bci_mcp/lsl/publisher.py +43 -0
- bci_mcp-0.1.0/src/bci_mcp/mcp/__init__.py +0 -0
- bci_mcp-0.1.0/src/bci_mcp/mcp/server.py +109 -0
- bci_mcp-0.1.0/src/bci_mcp/mcp/service.py +95 -0
- bci_mcp-0.1.0/src/bci_mcp/neurofeedback/__init__.py +0 -0
- bci_mcp-0.1.0/src/bci_mcp/neurofeedback/trainer.py +69 -0
- bci_mcp-0.1.0/src/bci_mcp/pipeline.py +88 -0
- bci_mcp-0.1.0/src/bci_mcp/recording/__init__.py +0 -0
- bci_mcp-0.1.0/src/bci_mcp/recording/reader.py +56 -0
- bci_mcp-0.1.0/src/bci_mcp/recording/recorder.py +27 -0
- bci_mcp-0.1.0/src/bci_mcp/recording/writer.py +51 -0
- bci_mcp-0.1.0/tests/test_bands.py +20 -0
- bci_mcp-0.1.0/tests/test_brainflow_device.py +28 -0
- bci_mcp-0.1.0/tests/test_calibration.py +29 -0
- bci_mcp-0.1.0/tests/test_cli.py +18 -0
- bci_mcp-0.1.0/tests/test_cli_record.py +15 -0
- bci_mcp-0.1.0/tests/test_dashboard.py +30 -0
- bci_mcp-0.1.0/tests/test_device.py +22 -0
- bci_mcp-0.1.0/tests/test_discovery.py +23 -0
- bci_mcp-0.1.0/tests/test_examples.py +16 -0
- bci_mcp-0.1.0/tests/test_examples_compile.py +10 -0
- bci_mcp-0.1.0/tests/test_filters.py +33 -0
- bci_mcp-0.1.0/tests/test_lsl_device.py +40 -0
- bci_mcp-0.1.0/tests/test_lsl_publisher.py +34 -0
- bci_mcp-0.1.0/tests/test_mcp_service.py +81 -0
- bci_mcp-0.1.0/tests/test_metadata.py +26 -0
- bci_mcp-0.1.0/tests/test_metrics.py +19 -0
- bci_mcp-0.1.0/tests/test_neurofeedback.py +42 -0
- bci_mcp-0.1.0/tests/test_neurofocus_device.py +82 -0
- bci_mcp-0.1.0/tests/test_neurofocus_protocol.py +41 -0
- bci_mcp-0.1.0/tests/test_pipeline.py +34 -0
- bci_mcp-0.1.0/tests/test_playback.py +42 -0
- bci_mcp-0.1.0/tests/test_quality.py +26 -0
- bci_mcp-0.1.0/tests/test_readme.py +15 -0
- bci_mcp-0.1.0/tests/test_recording.py +36 -0
- bci_mcp-0.1.0/tests/test_registry.py +20 -0
- bci_mcp-0.1.0/tests/test_ringbuffer.py +32 -0
- bci_mcp-0.1.0/tests/test_serial_device.py +61 -0
- bci_mcp-0.1.0/tests/test_smoke.py +6 -0
- bci_mcp-0.1.0/tests/test_state.py +29 -0
- bci_mcp-0.1.0/tests/test_stream.py +26 -0
- bci_mcp-0.1.0/tests/test_synthetic.py +44 -0
- bci_mcp-0.1.0/uv.lock +2696 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Git commit rules — never add Co-authored-by trailers
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Git commits
|
|
7
|
+
|
|
8
|
+
**Never add `Co-authored-by` trailers to commit messages.**
|
|
9
|
+
|
|
10
|
+
This includes and is not limited to:
|
|
11
|
+
|
|
12
|
+
- `Co-authored-by: Cursor <cursoragent@cursor.com>`
|
|
13
|
+
- `Co-authored-by: Claude ...`
|
|
14
|
+
- Any other AI or agent co-author line
|
|
15
|
+
|
|
16
|
+
When committing:
|
|
17
|
+
|
|
18
|
+
1. Write the commit message yourself in a HEREDOC or `-m` flag — do not rely on tooling that auto-appends co-authors.
|
|
19
|
+
2. Before pushing, verify with `git log -1 --format='%B'` that no `Co-authored-by:` line is present.
|
|
20
|
+
3. If one appears, amend the commit and remove it before pushing.
|
|
21
|
+
|
|
22
|
+
The repository owner does not want AI tools listed as co-authors in git history.
|
bci_mcp-0.1.0/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
UV_PUBLISH_TOKEN=pypi-AgEIcHlwaS5vcmcCJDU2NzI1YzFjLWViNDUtNGY4Ni05ZTg4LWE5NjQ0MDRhNjczNAACKlszLCI5NGNmMDIzNS0yMTM1LTRhZTItOGE2Zi1lM2QyYjgyMDNlZjUiXQAABiAhWpMnw6i6SL9CmArvgm-LGvjsp-LQnOj8SOB1FndIew
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- run: python -m pip install -e ".[dev,docs]"
|
|
20
|
+
- run: ruff check src tests
|
|
21
|
+
- run: python -m pytest
|
|
22
|
+
- run: mkdocs build --strict
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Deploy MkDocs to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- 'docs/**'
|
|
8
|
+
- 'mkdocs.yml'
|
|
9
|
+
- 'hooks.py'
|
|
10
|
+
- 'llms.txt'
|
|
11
|
+
- '.nojekyll'
|
|
12
|
+
- 'src/**'
|
|
13
|
+
- 'pyproject.toml'
|
|
14
|
+
- '.github/workflows/deploy-pages.yml'
|
|
15
|
+
workflow_dispatch:
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
pages: write
|
|
20
|
+
id-token: write
|
|
21
|
+
|
|
22
|
+
concurrency:
|
|
23
|
+
group: pages
|
|
24
|
+
cancel-in-progress: false
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
deploy:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
environment:
|
|
30
|
+
name: github-pages
|
|
31
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
- uses: actions/setup-python@v5
|
|
35
|
+
with:
|
|
36
|
+
python-version: '3.12'
|
|
37
|
+
- run: |
|
|
38
|
+
python -m pip install --upgrade pip
|
|
39
|
+
pip install -e ".[docs]"
|
|
40
|
+
- run: mkdocs build --strict
|
|
41
|
+
- uses: actions/configure-pages@v5
|
|
42
|
+
- uses: actions/upload-pages-artifact@v3
|
|
43
|
+
with:
|
|
44
|
+
path: site
|
|
45
|
+
- id: deployment
|
|
46
|
+
uses: actions/deploy-pages@v4
|
bci_mcp-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
*.egg-info/
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
venv/
|
|
16
|
+
env/
|
|
17
|
+
.env/
|
|
18
|
+
|
|
19
|
+
# IDE files
|
|
20
|
+
.idea/
|
|
21
|
+
.vscode/
|
|
22
|
+
*.swp
|
|
23
|
+
*.swo
|
|
24
|
+
|
|
25
|
+
# Jupyter Notebook
|
|
26
|
+
.ipynb_checkpoints
|
|
27
|
+
|
|
28
|
+
# Data files
|
|
29
|
+
recordings/
|
|
30
|
+
*.npz
|
|
31
|
+
*.csv
|
|
32
|
+
*.pkl
|
|
33
|
+
|
|
34
|
+
# Logs
|
|
35
|
+
logs/
|
|
36
|
+
*.log
|
|
37
|
+
|
|
38
|
+
# Generated documentation
|
|
39
|
+
site/
|
|
40
|
+
|
|
41
|
+
# OS specific files
|
|
42
|
+
.DS_Store
|
|
43
|
+
Thumbs.db
|
bci_mcp-0.1.0/.nojekyll
ADDED
|
File without changes
|
bci_mcp-0.1.0/AGENTS.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Agent instructions (Cursor, Claude Code, Copilot, etc.)
|
|
2
|
+
|
|
3
|
+
Read this file before making git commits or opening PRs in this repository.
|
|
4
|
+
|
|
5
|
+
## Git commits — mandatory
|
|
6
|
+
|
|
7
|
+
**Do not add `Co-authored-by` trailers to any commit message.**
|
|
8
|
+
|
|
9
|
+
Forbidden examples:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
13
|
+
Co-authored-by: Claude Opus ... <noreply@anthropic.com>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The human author is the only author. AI assistants may help write code and commit messages, but must not be credited in git metadata.
|
|
17
|
+
|
|
18
|
+
Before every push:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git log -1 --format='%B' | rg 'Co-authored-by'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
If that matches anything, amend the commit and remove the trailer before pushing.
|
|
25
|
+
|
|
26
|
+
**Cursor injects `Co-authored-by: Cursor <cursoragent@cursor.com>` automatically.** This repo sets `core.hooksPath` to `.githooks/` so `prepare-commit-msg` strips those lines on every commit. After cloning, run:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git config core.hooksPath .githooks
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Other conventions
|
|
33
|
+
|
|
34
|
+
- Run `ruff check src tests && python -m pytest` before PRs.
|
|
35
|
+
- Docs: `pip install -e ".[docs]" && mkdocs build --strict`.
|
|
36
|
+
- See [CLAUDE.md](CLAUDE.md) for architecture and package layout.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
- Device-agnostic EEG acquisition: synthetic, NeuroFocus (serial + BLE), OpenBCI/Muse via BrainFlow, LSL, generic serial, recording playback.
|
|
5
|
+
- DSP pipeline: band powers (δ θ α β γ), focus/calm/attention/engagement/fatigue/meditation metrics, signal quality + artifacts, calibration.
|
|
6
|
+
- Real Model Context Protocol server (FastMCP, stdio) with tools, resources, and a prompt.
|
|
7
|
+
- CLI: devices, stream, record, play, neurofeedback, dashboard, serve.
|
|
8
|
+
- Recording (CSV/npz/EDF) + replay, neurofeedback trainer, LSL publisher, FastAPI web dashboard.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use BCI-MCP in your research, please cite it."
|
|
3
|
+
title: "BCI-MCP: Plug your brain into any AI"
|
|
4
|
+
abstract: "A Model Context Protocol server that streams live EEG brain state from any EEG device into AI assistants."
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: Ganbold
|
|
7
|
+
given-names: Enkhbold
|
|
8
|
+
repository-code: "https://github.com/enkhbold470/bci-mcp"
|
|
9
|
+
url: "https://enkhbold470.github.io/bci-mcp/"
|
|
10
|
+
license: MIT
|
|
11
|
+
keywords:
|
|
12
|
+
- EEG
|
|
13
|
+
- brain-computer interface
|
|
14
|
+
- Model Context Protocol
|
|
15
|
+
- neurofeedback
|
|
16
|
+
- BrainFlow
|
bci_mcp-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Git commits
|
|
6
|
+
|
|
7
|
+
**Never add `Co-authored-by` trailers** (Cursor, Claude, or any AI). See [AGENTS.md](AGENTS.md). Verify with `git log -1 --format='%B'` before pushing.
|
|
8
|
+
|
|
9
|
+
## What this project is
|
|
10
|
+
|
|
11
|
+
**BCI-MCP** is a Python package (`src/bci_mcp/`) that provides:
|
|
12
|
+
|
|
13
|
+
- **Device-agnostic EEG acquisition** via a URI registry (synthetic, NeuroFocus serial+BLE, BrainFlow/OpenBCI/Muse, LSL, generic serial, recording playback).
|
|
14
|
+
- **A real MCP server** built on the official MCP Python SDK (`mcp` on PyPI, `FastMCP`), exposing live brain state to Claude Desktop and any MCP client over stdio.
|
|
15
|
+
- **A DSP pipeline** that turns raw EEG into `BrainState` (focus, calm, attention, engagement, fatigue, meditation + δθαβγ band powers + signal quality).
|
|
16
|
+
- **A Rich CLI** with commands: `devices`, `stream`, `record`, `play`, `neurofeedback`, `dashboard`, `serve`.
|
|
17
|
+
- **Recording** (CSV/npz/EDF) + replay, neurofeedback trainer, LSL publisher, FastAPI web dashboard.
|
|
18
|
+
|
|
19
|
+
## Package layout
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
src/bci_mcp/
|
|
23
|
+
├── __init__.py # triggers device registration; __version__ = "0.1.0"
|
|
24
|
+
├── cli.py # Typer CLI (entry point: bci-mcp)
|
|
25
|
+
├── pipeline.py # Pipeline: Device → Stream → DSP → BrainState
|
|
26
|
+
├── core/
|
|
27
|
+
│ ├── device.py # Device ABC, Chunk, DeviceInfo dataclasses
|
|
28
|
+
│ ├── registry.py # URI registry (register/create_device/discover)
|
|
29
|
+
│ ├── ringbuffer.py # RingBuffer
|
|
30
|
+
│ └── stream.py # Stream (background thread polling device.read())
|
|
31
|
+
├── devices/
|
|
32
|
+
│ ├── synthetic.py # SyntheticDevice — no hardware needed
|
|
33
|
+
│ ├── neurofocus.py # NeuroFocus v4 (serial + BLE)
|
|
34
|
+
│ ├── brainflow_device.py # BrainFlow (OpenBCI, Muse, ...)
|
|
35
|
+
│ ├── lsl_device.py # LSL consumer
|
|
36
|
+
│ ├── serial_device.py # Generic serial (1 int/line)
|
|
37
|
+
│ └── playback.py # PlaybackDevice (npz/csv/edf replay)
|
|
38
|
+
├── dsp/
|
|
39
|
+
│ ├── filters.py # bandpass + notch (zero-phase, scipy.signal.filtfilt)
|
|
40
|
+
│ ├── bands.py # band_powers() via Welch PSD, relative_band_powers()
|
|
41
|
+
│ ├── metrics.py # raw_metrics() — focus/calm/attention/engagement/fatigue/meditation
|
|
42
|
+
│ ├── state.py # BrainState dataclass
|
|
43
|
+
│ ├── quality.py # assess_quality() — signal score + artifact flags
|
|
44
|
+
│ └── calibration.py # Calibration — personalized min/max scaling
|
|
45
|
+
├── mcp/
|
|
46
|
+
│ ├── server.py # FastMCP tools/resources/prompt + serve()
|
|
47
|
+
│ └── service.py # BrainService — testable core (server.py wraps this)
|
|
48
|
+
├── recording/
|
|
49
|
+
│ ├── recorder.py # Recorder stream consumer
|
|
50
|
+
│ ├── writer.py # save_recording() — npz/csv/edf
|
|
51
|
+
│ └── reader.py # load_recording() → Recording dataclass
|
|
52
|
+
├── neurofeedback/
|
|
53
|
+
│ └── trainer.py # NeurofeedbackSession
|
|
54
|
+
├── lsl/
|
|
55
|
+
│ └── publisher.py # LSL outlet publisher
|
|
56
|
+
└── dashboard/
|
|
57
|
+
└── server.py # FastAPI web dashboard
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Install and run
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install -e ".[all,dev]" # all extras + dev tools
|
|
64
|
+
|
|
65
|
+
bci-mcp devices # list URI schemes + discovered hardware
|
|
66
|
+
bci-mcp stream --device synthetic:// # live terminal brain-meter
|
|
67
|
+
bci-mcp stream --device synthetic:// --once # single snapshot (good for CI smoke)
|
|
68
|
+
bci-mcp record --device synthetic:// --seconds 10 --out session.npz
|
|
69
|
+
bci-mcp play session.npz
|
|
70
|
+
bci-mcp serve # MCP server (stdio)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Tests
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
ruff check src tests # linter (must be clean before commit)
|
|
77
|
+
python -m pytest # runs all tests (80+ hardware-free tests)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
All tests are **hardware-free**: synthetic device, recording playback, in-process LSL, BrainFlow synthetic board. No EEG headset needed.
|
|
81
|
+
|
|
82
|
+
## Architecture
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
Device.read() → Chunk → Stream (background thread) → RingBuffer
|
|
86
|
+
│
|
|
87
|
+
Pipeline.current_state() pulls latest N samples, runs: │
|
|
88
|
+
filters.bandpass + filters.notch │
|
|
89
|
+
→ bands.band_powers (Welch PSD) │
|
|
90
|
+
→ metrics.raw_metrics │
|
|
91
|
+
→ calibration.apply → BrainState │
|
|
92
|
+
│
|
|
93
|
+
Consumers: CLI brain-meter, FastMCP server, FastAPI dashboard,
|
|
94
|
+
Recorder (→ npz/csv/edf), LSL publisher, NeurofeedbackSession
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Device URI registry
|
|
98
|
+
|
|
99
|
+
Every device backend calls `bci_mcp.core.registry.register(scheme, factory)` at import time. `create_device(uri)` parses the URI and calls the factory. Schemes: `synthetic`, `neurofocus`, `brainflow`, `lsl`, `serial`, `playback`.
|
|
100
|
+
|
|
101
|
+
## MCP server
|
|
102
|
+
|
|
103
|
+
`bci_mcp.mcp.server` uses `FastMCP` from the official MCP Python SDK. It runs over **stdio** (the standard for Claude Desktop). Tools: `list_devices`, `connect`, `disconnect`, `get_brain_state`, `get_band_powers`, `get_signal_quality`, `calibrate`, `record`, `start_neurofeedback`, `get_neurofeedback_score`, `mark_event`, `stream_summary`. Resources: `brain://state`, `brain://device`. Prompt: `interpret_brain_state`.
|
|
104
|
+
|
|
105
|
+
## Design docs
|
|
106
|
+
|
|
107
|
+
Specs and implementation plans live under `docs/superpowers/`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Contributing to BCI-MCP
|
|
2
|
+
|
|
3
|
+
Thanks for your interest! BCI-MCP is a Python project (3.10+).
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m pip install -e ".[all,dev]"
|
|
9
|
+
git config core.hooksPath .githooks
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The hooks path enables `prepare-commit-msg`, which strips unwanted AI `Co-authored-by` trailers from commits. See [AGENTS.md](AGENTS.md).
|
|
13
|
+
|
|
14
|
+
## Develop
|
|
15
|
+
|
|
16
|
+
- Source lives in `src/bci_mcp/`, tests in `tests/`.
|
|
17
|
+
- All tests are hardware-free (synthetic device, recording playback, in-process LSL, BrainFlow synthetic board), so you can run the full suite with no headset.
|
|
18
|
+
- Before opening a PR:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
ruff check src tests
|
|
22
|
+
python -m pytest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Adding a device backend
|
|
26
|
+
|
|
27
|
+
Implement `bci_mcp.core.device.Device`, return `Chunk(data=(channels, n) float32 µV, timestamps=(n,))`, and register a URI scheme via `bci_mcp.core.registry.register(...)`. See `devices/synthetic.py` for the simplest example and `devices/neurofocus.py` for a real-hardware one.
|
|
28
|
+
|
|
29
|
+
## Design docs
|
|
30
|
+
|
|
31
|
+
Specs and implementation plans live under `docs/superpowers/`.
|
bci_mcp-0.1.0/Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
FROM python:3.10-slim
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
# Install system dependencies
|
|
6
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
7
|
+
build-essential \
|
|
8
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
9
|
+
|
|
10
|
+
# Copy requirements first for better caching
|
|
11
|
+
COPY requirements.txt .
|
|
12
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
13
|
+
|
|
14
|
+
# Copy application code
|
|
15
|
+
COPY . .
|
|
16
|
+
|
|
17
|
+
# Create directory for recordings
|
|
18
|
+
RUN mkdir -p /app/recordings && chmod 777 /app/recordings
|
|
19
|
+
|
|
20
|
+
# Create a non-root user to run the application
|
|
21
|
+
RUN useradd -m bciuser && chown -R bciuser:bciuser /app
|
|
22
|
+
USER bciuser
|
|
23
|
+
|
|
24
|
+
# Default command - start the MCP server
|
|
25
|
+
CMD ["python", "src/main.py", "--server"]
|
|
26
|
+
|
|
27
|
+
# Expose the WebSocket port
|
|
28
|
+
EXPOSE 8765
|
bci_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 enkhbold470
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|