
Ephys
io.github.happyc0der由 GitHub 帳號 happyc0der 發布v0.5.1更新於 Oct 28, 2026
Read-only analysis of intracortical BCI recordings (NWB, DANDI, WAV): spikes, PSTHs, decoding, plots
概覽
唯讀的 MCP 伺服器,用來分析皮質內腦機介面紀錄(NWB、WAV、DANDI、LSL):訊號品質、動作電位、PSTH、解碼與繪圖。
- 可以做什麼
- 開啟並檢視合成、本機 NWB、本機 WAV、即時 LSL 或 DANDI 來源的工作階段,讀取通道、取樣率、行為訊號、授權與引用資訊
- 搜尋 DANDI 資料集、列出其檔案,並查看網路上的 LSL 串流與緩衝狀態
- 評估訊號品質,偵測與分選動作電位,設定或讀取探針幾何與腦區標籤
- 計算放電率、依試次對齊的 PSTH、GPFA 或 PCA 潛在因子,以及含留出與跨工作階段評分的脊迴歸或卡爾曼解碼器
- 內嵌產生圖表:探針陣列圖、PSTH、光柵圖、解碼對照圖與潛在因子圖
- 適用情境
- 適合神經科學與腦機介面研究或教學情境:讓助理探索動作電位層級的紀錄、跨工作階段評估解碼器,或從本機檔案與 DANDI 資料集產生圖表。它針對皮質內資料,而非頭皮腦電。
- 執行需求
- 透過 uvx 以 stdio 在本機執行,需要已安裝 uv;沒有安裝步驟,也未宣告任何憑證。選用擴充可加入 LSL 即時資料來源與動作電位分選。選用的 HTTP 模式需要 bearer 權杖,超出私有網路時還需前置 TLS。DANDI 串流與 LSL 需要網路存取。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Ephys,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
ephys-mcp
An MCP server that lets an LLM analyse intracortical (spike-level) brain-computer-interface recordings: signal quality, spike detection, firing rates, and cursor-velocity decoding.
Existing BCI MCP servers target scalp EEG. This one targets the kind of data a high-channel-count implant produces, and defines a read-only adapter contract so a live device backend can be added when a vendor publishes an API.
Research and education software. Not a medical device. Not for clinical use. Not affiliated with or endorsed by Neuralink Corp. or any other implant manufacturer.
Example output
Figures from the built-in synthetic source (32 units, 300 s, seed 2), produced by the server's own plot tools.
Status
v0.5. The planned feature set is complete: local NWB files, local broadband WAV recordings, live Lab Streaming Layer streams, streaming from the DANDI Archive, a synthetic motor-cortex source with ground truth, spike detection, quality metrics, ridge and Kalman decoders, trial-aligned PSTHs, spike sorting, cross-session (FALCON-style) evaluation, latent-factor models (GPFA, PCA), probe geometry, and figures. 24 tools. Bug reports and feature requests go to GitHub Issues.
Install and run
Needs uv. No install step: uvx ephys-mcp fetches the package and starts the server on stdio.
Claude Code:
Claude Desktop (claude_desktop_config.json):
From a checkout, use uv run ephys-mcp instead, or uv --directory /path/to/ephys-mcp run ephys-mcp in the configs above.
HTTP transport
For remote clients or hosted agents, serve streamable HTTP instead of stdio:
Every request must then carry Authorization: Bearer <token>. The server refuses to bind to a non-loopback address without a token, and tokens must be at least 16 characters. Put TLS in front of it (a reverse proxy) before exposing it beyond a private network: the token travels in clear text otherwise. On loopback the token is optional, so ephys-mcp --http alone serves http://127.0.0.1:8000/mcp for local testing.
Then ask, for real data: "Find a small motor cortex dataset on DANDI, open it, and tell me how well hand velocity can be decoded." Or offline: "Open a synthetic session, check signal quality, fit a Kalman decoder and show me a decoded window."
Data sources
Dataset licence and citation come from the archive and are returned by open_session, so the model can attribute the data. Many datasets record only during trials; the server tracks those spans (recorded_fraction) and leaves the gaps out of rates and decoding instead of reading them as silence.
WAV samples carry no physical unit, so amplitudes are reported as ADC counts unless you pass uv_per_count; every amplitude result names its unit. Clips in a folder are separate recordings, so the server says that timing across those channels is not meaningful. Spike times from WAV are threshold crossings, not sorted units.
Reference results, all simple causal linear baselines rather than state of the art:
- MC_Maze_Small (DANDI 000140, 142 units, last 20% held out, 50 ms bins): ridge R² 0.50, Kalman R² 0.34 for hand velocity.
- FALCON H1 (DANDI 000954, human 7-DoF velocity, 176 channels, 20 ms bins,
eval_mask): ridge trained on the first held-in day scores R² 0.43 on that day's minival, 0.07 one week later and below zero on the held-out days. That decay is the point of the benchmark; the Kalman filter is unsuitable for this scripted calibration data. FALCON's official test labels are private, so these are not leaderboard scores.
Decoder hyperparameters (ridge strength, the neural lead for Kalman) are chosen by blocked cross-validation inside the training split. Ridge history is 0.5 s of spike counts whatever the bin size.
GPFA is implemented from the paper's equations in numpy and scipy (EM over loadings, offsets, noise and per-factor timescales; no deep-learning dependency), and runs in seconds on a hundred trials. On the simulator, whose true latent is 2-D cursor velocity, it finds two dominant factors that explain velocity with R² 0.95 (PCA: 0.68). On MC_Maze_Small it shows the rotating population trajectory around movement onset that motor cortex is known for. LFADS-class models are out of scope: they need a training run of minutes and a deep-learning stack.
Tools
Resource: ephys://sessions. Prompts: analyze_session, falcon_evaluate.
Tools return summaries, never raw arrays, so results fit in a model's context.
Optional extras
Sorting uses the session's probe geometry, from the file's electrode table or from set_probe_geometry, so contacts under 100 µm apart are sorted jointly. This matters on dense probes: on a simulated 20 µm laminar probe, sorting with the true geometry finds the 12 real units, while treating contacts as independent reports 15, counting the same unit again on neighbouring contacts. Without geometry, channels are placed far apart and treated as isolated electrodes. On the simulator, spykingcircus2 recovers every unit with recall above 0.95.
Brain-area labels come from the NWB electrodes table when present (MC_Maze reports PMd and M1); get_probe lists them per channel so an analysis can be restricted to one area with the units argument. Note that none of the DANDI datasets tried so far stores contact coordinates, so for those set_probe_geometry is the way to supply an array layout.
Plot tools return the PNG inline, so a vision-capable model can read the figure, and also save it under ~/.cache/ephys-mcp/plots (override with EPHYS_MCP_OUTPUT_DIR). Figures use a categorical palette checked for colour-blind separation, with direct labels so identity never rests on colour alone.
Design rules
- Read-only. The
NeuralSourcecontract has no write, stimulate or configure method. None will be added without a separate safety design. - Local by default. stdio transport, no telemetry. HTTP is opt-in and token-gated. Neural data is sensitive.
- No bundled third-party data. See DATA_LICENSES.md.
Writing a source adapter
For recordings, subclass ephys_mcp.sources.base.NeuralSource (info, read_raw, spike_times, behavior). For a live device, subclass ephys_mcp.sources.live.RingBufferSource and call push(samples) from a reader thread; sources/lsl.py is a complete example in about 60 lines, and sources/n1_stub.py lists what an implant adapter would additionally need. Register the class in ephys_mcp/sources/__init__.py.
Live sessions report time as seconds since open, and only the most recent buffer is readable, so t_start_s and duration_s move forward.
Development
Citing
See CITATION.cff; GitHub's "Cite this repository" button uses it. Cite the datasets you analyse separately: get_session_info returns each one's citation.
Licence
CC0 1.0 Universal. The authors waive all copyright and related rights to the extent the law allows. Use it for anything, no attribution required. CC0 does not grant patent or trademark rights.
來源:README.md,提交 84e76f1
工具
0版本歷史
2- v0.5.1最新Sep 22, 2026
- v0.4.0Sep 22, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分