Skip to main content

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

Project description

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
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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nwb_mcp_server-0.1.4.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nwb_mcp_server-0.1.4-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file nwb_mcp_server-0.1.4.tar.gz.

File metadata

  • Download URL: nwb_mcp_server-0.1.4.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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}

File hashes

Hashes for nwb_mcp_server-0.1.4.tar.gz
Algorithm Hash digest
SHA256 af11ceaada4397613bf2a4ad13888acbdfc41a0a4cb552f178f6191eac22f2ea
MD5 471d14d62b8047f76fe0bf6e08e83ca5
BLAKE2b-256 9f7a6e7d82370744ef4fa88d542251c90aaa90d13fe8cd88d3728a6ca0dc3eac

See more details on using hashes here.

File details

Details for the file nwb_mcp_server-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: nwb_mcp_server-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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}

File hashes

Hashes for nwb_mcp_server-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4f9f227ec170bc25ea162c422eb0b9c43b77252a144462ac82cceb2ac62e1733
MD5 8b3466a5209fe5acb01cb3cb9c8dd665
BLAKE2b-256 97ab4a9a2f213f9b8fe4cabfe1156115c1bf10fb4d6a275b90e43947f7e68280

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page