Skip to main content

NWB Model Context Protocol (MCP) Server

An MCP server for accessing NWB (Neurodata Without Borders) files, providing AI agents easy access to neuroscience data.

Features

  • 🚀 Rapid exploration of new datasets
  • 🗂️ Automatically-generated analysis reports
  • 🧠 Prompt templates instruct agents to get the most from the tools
  • 💡 "No Code" mode allows analysis without modifying the local filesystem
  • ⚡️ Uses lazynwb for efficient data access across multiple NWB files
  • ☁️ Supports local and cloud data (e.g. on AWS S3)
  • 🔒 Read-only access to NWB data
  • 🛠️ Easy setup

Requirements

1. uv

uv is used to run the server with the required dependencies, in an isolated virtual environment.

See the uv installation guide for platform-specific instructions for a system-wide installation.

Alternatively, install with pip in your system Python environment:

pip install uv

🛈 Note

uv, like pip, is one of the few tools it makes sense to install "globally" to your system Python, rather than in a virtual environment, since it is used to manage new virtual environments and Python versions.

2. Copilot Chat extension

Available on the VS Code extensions marketplace (in Code Ocean, this postInstall file should be used).

🛈 Note

Similar agent extensions, such as Cline or Claude Code, should also be able to connect to the server.

Add server to Copilot Chat in VS Code

Adding MCP to Copilot Chat

  • ensure MCP is enabled in the settings UI, or with JSON setting "chat.mcp.enabled": true
  • the first startup may take a few seconds as it downloads packages

🛈 Note

You may be prompted to choose between adding the server to a "global" or "workspace" config. If you intend to switch between datasets it may be preferable to have the mcp.json config in your workspace, to be able to easily modify the path to your data. The global setting is convenient in that the server will be available in all VS Code instances.

Example mcp.json

{
    "servers": {
        "nwb": {
            "command": "uvx",
            "args": [
                "nwb-mcp-server",
                "--root_dir", "data",
                "--glob_pattern", "*.nwb"
            ]
        }
    }
}

Server configuration parameters

Parameter Description Default
root_dir Root directory to search for NWB files (forward slash ok on Windows) "data"
glob_pattern A glob pattern to apply to root_dir to locate NWB files. Use "**/*.nwb" for sub-directories. "*.nwb"
tables Restrict the list of NWB tables to use, e.g. ["trials", "intervals/epochs"] null
infer_schema_length Number of NWB files to scan to infer schema for all. Affects server startup time. 1
anon Use anonymous S3 access via fsspec (for public S3 buckets) false
unattended Run the server in unattended mode (no user prompts, for automation) false
table_element_limit Max elements (columns x rows) allowed in a table returned by a SQL query 500

uvx parameters

Any of the following parameters can be added to the args list before nwb-mcp-server to customize the environment the server runs in: uvx parameters

--upgrade is useful to ensure the latest versions of dependencies are used.

🛈 Note

uvx is an alias for uv tool run, where "tool" means any pip-installable Python package that provides a command-line interface.

Usage

The server provides the tools for querying NWB files efficiently. Getting an agent to use them effectively requires careful design of the prompt, instructions, and the availability of other tools. This is a work in progress.

🛈 Note

The server creates a virtual, read-only SQL database from the NWB files, which the agent can query. Exploration of a dataset or basic analysis that can be expressed in SQL is possible entirely within the chat dialog, without the need for the agent to create and run Python scripts in the workspace.

Custom chat modes

Copy the .github folder into your project to make two chat modes available in Copilot: custom chat modes for Copilot These modes program Copilot's behavior and constrain the tools available, and are tailored for

  • rapid data exploration and basic analysis without editing files or install dependencies (No Code mode)
  • more complex analysis and processing with Python (Supervised Coding mode)

Start in No Code mode, then switch to Supervised Coding when prompted by the agent.

See VS Code docs on custom chat modes.

Non-NWB file support

🚧 Experimental 🚧 There is limited support for working with non-NWB files. Any set of files in tabular format than can be read lazily using a pl.scan_<format> function, including parquet and csv, can be used with the server. The provided prompt templates and chat modes are designed with the NWB format and the lazynwb package in mind, so the agent will receive confusing instructions (although it usually figures out the correct behavior!)

See the Polars I/O documentation for a complete list of compatible file formats.

Metadata

Release files for nwb-mcp-server 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nwb-mcp-server 0.1.9
File Size Uploaded Provenance
nwb_mcp_server-0.1.9.tar.gz 20.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nwb-mcp-server 0.1.9
File Interpreter ABI Platform
nwb_mcp_server-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 36.0 kB

Release files / nwb_mcp_server-0.1.9.tar.gz

Download URL nwb_mcp_server-0.1.9.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
25c95c00b12d8a01145595fb021806e30f109b54c46c88ee5bc86fac1f8608ed
BLAKE2b-256 checksum
How to use checksums
396435a49ed41126b3c628a5df1ca582c8ce10b35a18471cc752006fd1782aac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nwb_mcp_server-0.1.9-py3-none-any.whl

Download URL nwb_mcp_server-0.1.9-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21baca97b92116845e34cbbf11953e0aa30627566cc1b320b91451c6baeeeb70
BLAKE2b-256 checksum
How to use checksums
d2b4295601b01e737035856526d2f9713b988a3ad61551495283bb53043fb638
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for nwb-mcp-server 0.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page