aind-data-mcp 0.1.2__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Allen Institute for Neural Dynamics
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.
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: aind-data-mcp
3
+ Version: 0.1.2
4
+ Summary: Generated from aind-library-template
5
+ Author: Allen Institute for Neural Dynamics
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: aind-data-access-api
12
+ Requires-Dist: fastmcp
13
+ Requires-Dist: hdmf-zarr>=0.11.1
14
+ Requires-Dist: langchain-core>=0.3.60
15
+ Requires-Dist: pydantic>=2.11.4
16
+ Requires-Dist: suffix-trees>=0.3.0
17
+ Dynamic: license-file
18
+
19
+ # AIND Data MCP Server
20
+
21
+ [![License](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
22
+ ![Code Style](https://img.shields.io/badge/code%20style-black-black)
23
+ [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
24
+ ![Interrogate](https://img.shields.io/badge/interrogate-100.0%25-brightgreen)
25
+ ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
26
+ ![Python](https://img.shields.io/badge/python->=3.11-blue?logo=python)
27
+
28
+ An MCP (Model Context Protocol) server that provides access to AIND (Allen Institute for Neural Dynamics) metadata and data assets through a comprehensive set of tools and resources. This server targets the **V2 aind-data-schema** format.
29
+
30
+ ## Features
31
+
32
+ This MCP server provides the following tools:
33
+
34
+ **Data Retrieval & Querying**
35
+ - `get_records` — Query MongoDB collections using filters and projections
36
+ - `aggregation_retrieval` — Execute complex MongoDB aggregation pipelines
37
+ - `count_records` — Count documents matching a filter
38
+ - `flatten_records` — Retrieve and flatten records into dot-notation for easier inspection
39
+ - `get_project_names` — List all project names in the database
40
+ - `get_summary` — Generate an AI-powered summary for a specific data asset
41
+
42
+ **Schema Navigation**
43
+ - `get_top_level_nodes` — Explore the top-level fields of the V2 metadata schema
44
+ - `get_additional_schema_help` — Query-writing guidance for V2 aggregations
45
+ - `get_modality_types` — List all available data modality names and abbreviations
46
+
47
+ **Schema Examples** (one tool per document type)
48
+ - `get_acquisition_example`, `get_data_description_example`, `get_instrument_example`, `get_procedures_example`, `get_subject_example`, `get_processing_example`, `get_model_example`, `get_quality_control_example`
49
+
50
+ **NWB File Access**
51
+ - `identify_nwb_contents_in_code_ocean` — Load an NWB file from the `/data` directory in a Code Ocean capsule
52
+ - `identify_nwb_contents_with_s3_link` — Load an NWB file from an S3 path
53
+
54
+ **Resources** (accessible via the MCP protocol)
55
+ - `resource://aind_api` — Context and usage patterns for the AIND data access API
56
+ - `resource://load_nwbfile` — Reference script for loading NWB files
57
+
58
+ ## Installation
59
+
60
+ Install uv if you haven't already — see [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/).
61
+
62
+ Install the MCP server using uv:
63
+
64
+ ```bash
65
+ uv tool install aind-data-mcp
66
+ ```
67
+
68
+ Or using pip:
69
+
70
+ ```bash
71
+ pip install aind-data-mcp
72
+ ```
73
+
74
+ ## Configuration
75
+
76
+ ### For Cline (VSCode Extension)
77
+
78
+ In order to ensure that the MCP server runs in your preferred client, you will have to download the `aind-data-mcp` package to your console. If space is an issue, please set `UV_CACHE_DIR` and `UV_TOOL_DIR` to locations that have capacity before proceeding with the next step.
79
+
80
+ 1. Simpler version of install
81
+ Run `uv tool install aind-data-mcp` on your terminal and proceed below to configuring your MCP clients.
82
+ 2. If the above step didn't work:
83
+
84
+ Create virtual environment with python 3.11 in IDE
85
+
86
+ ```bash
87
+ # Instructions for Conda
88
+ conda create -n <my_env> python=3.11
89
+ conda activate <my_env>
90
+
91
+ # Instructions for virtual environment
92
+ py -3.11 -m venv .venv
93
+ # Windows startup
94
+ .venv\Scripts\Activate.ps1
95
+ # Mac/ Linux startup
96
+ source .venv/bin/activate
97
+ ```
98
+
99
+ Run the following commands in your IDE terminal.
100
+
101
+ ```bash
102
+ pip install uv
103
+ uvx aind-data-mcp
104
+ ```
105
+
106
+ If all goes well, and you see the following notice - `Starting MCP server 'aind_data_mcp' with transport 'stdio'` -, you should be good for the set up in your client of choice!
107
+
108
+ ### Cursor IDE
109
+
110
+ 1. Install the MCP server:
111
+ ```bash
112
+ uv tool install aind-data-mcp
113
+ ```
114
+
115
+ 2. Create the MCP configuration file:
116
+ ```bash
117
+ mkdir -p ~/.cursor
118
+ ```
119
+
120
+ 3. Create `~/.cursor/mcp.json` with the following content:
121
+ ```json
122
+ {
123
+ "mcpServers": {
124
+ "aind-data-access": {
125
+ "command": "aind-data-mcp",
126
+ "args": [],
127
+ "env": {}
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ 4. **Important**: Replace `aind-data-mcp` with the full path if needed:
134
+ ```bash
135
+ which aind-data-mcp
136
+ ```
137
+ Use the full path (e.g., `/Users/username/.local/bin/aind-data-mcp`) in the `command` field.
138
+
139
+ 5. Restart Cursor completely (Cmd+Q then reopen)
140
+
141
+ **Note**: Cursor uses a different MCP configuration system than VSCode. The configuration must be in `~/.cursor/mcp.json`, not in the main settings.json file.
142
+
143
+ ## Instructions for use in MCP clients
144
+
145
+ JSON Config files to add MCP servers in clients should be structured like this
146
+
147
+ ```json
148
+ {
149
+ "mcpServers": {
150
+
151
+ }
152
+ }
153
+ ```
154
+
155
+ Insert the following lines into the mcpServers dictionary
156
+
157
+ ```json
158
+ "aind_data_mcp": {
159
+ "disabled": false,
160
+ "timeout": 300,
161
+ "type": "stdio",
162
+ "command": "aind-data-mcp"
163
+ }
164
+ ```
165
+
166
+ Note that after configuring the JSON files, it will take a few minutes for the server to populate in the client.
167
+
168
+ ### Claude Desktop App
169
+
170
+ - Click the three lines at the top left of the screen.
171
+ - File > Settings > Developer > Edit config
172
+
173
+ ### Cline in VSCode
174
+
175
+ - Ensure that Cline is downloaded to VSCode
176
+ - Click the three stacked rectangles at the top right of the Cline window
177
+ - Installed > Configure MCP Servers
178
+ - Close and reopen VSCode
179
+
180
+ ### Github Copilot in VSCode
181
+
182
+ - Command palette (ctrl shift p)
183
+ - Search for MCP: Add server
184
+ - Select `Manual Install` / `stdio`
185
+ - When prompted for a command, input `uvx aind-data-mcp`
186
+ - Name your server
187
+ - Close and reopen VSCode
188
+ - In Copilot chat -> Select agent mode -> Click the three stacked rectangles to configure tools
189
+ - API context and NWB loading patterns are served automatically as MCP resources (`resource://aind_api` and `resource://load_nwbfile`) — no manual file setup required
190
+
191
+ ### For use in Code Ocean
192
+
193
+ * Refer to the [code ocean MCP server](https://github.com/codeocean/codeocean-mcp-server) for additional support
194
+
195
+ ## Development
196
+
197
+ To develop the code, run
198
+
199
+ ```bash
200
+ uv sync --group dev
201
+ ```
202
+
203
+ To run tests:
204
+
205
+ ```bash
206
+ uv run coverage run -m unittest discover && uv run coverage report
207
+ ```
208
+
209
+ To run linting:
210
+
211
+ ```bash
212
+ uv run flake8 . && uv run interrogate --verbose .
213
+ ```
@@ -0,0 +1,195 @@
1
+ # AIND Data MCP Server
2
+
3
+ [![License](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
4
+ ![Code Style](https://img.shields.io/badge/code%20style-black-black)
5
+ [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
6
+ ![Interrogate](https://img.shields.io/badge/interrogate-100.0%25-brightgreen)
7
+ ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
8
+ ![Python](https://img.shields.io/badge/python->=3.11-blue?logo=python)
9
+
10
+ An MCP (Model Context Protocol) server that provides access to AIND (Allen Institute for Neural Dynamics) metadata and data assets through a comprehensive set of tools and resources. This server targets the **V2 aind-data-schema** format.
11
+
12
+ ## Features
13
+
14
+ This MCP server provides the following tools:
15
+
16
+ **Data Retrieval & Querying**
17
+ - `get_records` — Query MongoDB collections using filters and projections
18
+ - `aggregation_retrieval` — Execute complex MongoDB aggregation pipelines
19
+ - `count_records` — Count documents matching a filter
20
+ - `flatten_records` — Retrieve and flatten records into dot-notation for easier inspection
21
+ - `get_project_names` — List all project names in the database
22
+ - `get_summary` — Generate an AI-powered summary for a specific data asset
23
+
24
+ **Schema Navigation**
25
+ - `get_top_level_nodes` — Explore the top-level fields of the V2 metadata schema
26
+ - `get_additional_schema_help` — Query-writing guidance for V2 aggregations
27
+ - `get_modality_types` — List all available data modality names and abbreviations
28
+
29
+ **Schema Examples** (one tool per document type)
30
+ - `get_acquisition_example`, `get_data_description_example`, `get_instrument_example`, `get_procedures_example`, `get_subject_example`, `get_processing_example`, `get_model_example`, `get_quality_control_example`
31
+
32
+ **NWB File Access**
33
+ - `identify_nwb_contents_in_code_ocean` — Load an NWB file from the `/data` directory in a Code Ocean capsule
34
+ - `identify_nwb_contents_with_s3_link` — Load an NWB file from an S3 path
35
+
36
+ **Resources** (accessible via the MCP protocol)
37
+ - `resource://aind_api` — Context and usage patterns for the AIND data access API
38
+ - `resource://load_nwbfile` — Reference script for loading NWB files
39
+
40
+ ## Installation
41
+
42
+ Install uv if you haven't already — see [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/).
43
+
44
+ Install the MCP server using uv:
45
+
46
+ ```bash
47
+ uv tool install aind-data-mcp
48
+ ```
49
+
50
+ Or using pip:
51
+
52
+ ```bash
53
+ pip install aind-data-mcp
54
+ ```
55
+
56
+ ## Configuration
57
+
58
+ ### For Cline (VSCode Extension)
59
+
60
+ In order to ensure that the MCP server runs in your preferred client, you will have to download the `aind-data-mcp` package to your console. If space is an issue, please set `UV_CACHE_DIR` and `UV_TOOL_DIR` to locations that have capacity before proceeding with the next step.
61
+
62
+ 1. Simpler version of install
63
+ Run `uv tool install aind-data-mcp` on your terminal and proceed below to configuring your MCP clients.
64
+ 2. If the above step didn't work:
65
+
66
+ Create virtual environment with python 3.11 in IDE
67
+
68
+ ```bash
69
+ # Instructions for Conda
70
+ conda create -n <my_env> python=3.11
71
+ conda activate <my_env>
72
+
73
+ # Instructions for virtual environment
74
+ py -3.11 -m venv .venv
75
+ # Windows startup
76
+ .venv\Scripts\Activate.ps1
77
+ # Mac/ Linux startup
78
+ source .venv/bin/activate
79
+ ```
80
+
81
+ Run the following commands in your IDE terminal.
82
+
83
+ ```bash
84
+ pip install uv
85
+ uvx aind-data-mcp
86
+ ```
87
+
88
+ If all goes well, and you see the following notice - `Starting MCP server 'aind_data_mcp' with transport 'stdio'` -, you should be good for the set up in your client of choice!
89
+
90
+ ### Cursor IDE
91
+
92
+ 1. Install the MCP server:
93
+ ```bash
94
+ uv tool install aind-data-mcp
95
+ ```
96
+
97
+ 2. Create the MCP configuration file:
98
+ ```bash
99
+ mkdir -p ~/.cursor
100
+ ```
101
+
102
+ 3. Create `~/.cursor/mcp.json` with the following content:
103
+ ```json
104
+ {
105
+ "mcpServers": {
106
+ "aind-data-access": {
107
+ "command": "aind-data-mcp",
108
+ "args": [],
109
+ "env": {}
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ 4. **Important**: Replace `aind-data-mcp` with the full path if needed:
116
+ ```bash
117
+ which aind-data-mcp
118
+ ```
119
+ Use the full path (e.g., `/Users/username/.local/bin/aind-data-mcp`) in the `command` field.
120
+
121
+ 5. Restart Cursor completely (Cmd+Q then reopen)
122
+
123
+ **Note**: Cursor uses a different MCP configuration system than VSCode. The configuration must be in `~/.cursor/mcp.json`, not in the main settings.json file.
124
+
125
+ ## Instructions for use in MCP clients
126
+
127
+ JSON Config files to add MCP servers in clients should be structured like this
128
+
129
+ ```json
130
+ {
131
+ "mcpServers": {
132
+
133
+ }
134
+ }
135
+ ```
136
+
137
+ Insert the following lines into the mcpServers dictionary
138
+
139
+ ```json
140
+ "aind_data_mcp": {
141
+ "disabled": false,
142
+ "timeout": 300,
143
+ "type": "stdio",
144
+ "command": "aind-data-mcp"
145
+ }
146
+ ```
147
+
148
+ Note that after configuring the JSON files, it will take a few minutes for the server to populate in the client.
149
+
150
+ ### Claude Desktop App
151
+
152
+ - Click the three lines at the top left of the screen.
153
+ - File > Settings > Developer > Edit config
154
+
155
+ ### Cline in VSCode
156
+
157
+ - Ensure that Cline is downloaded to VSCode
158
+ - Click the three stacked rectangles at the top right of the Cline window
159
+ - Installed > Configure MCP Servers
160
+ - Close and reopen VSCode
161
+
162
+ ### Github Copilot in VSCode
163
+
164
+ - Command palette (ctrl shift p)
165
+ - Search for MCP: Add server
166
+ - Select `Manual Install` / `stdio`
167
+ - When prompted for a command, input `uvx aind-data-mcp`
168
+ - Name your server
169
+ - Close and reopen VSCode
170
+ - In Copilot chat -> Select agent mode -> Click the three stacked rectangles to configure tools
171
+ - API context and NWB loading patterns are served automatically as MCP resources (`resource://aind_api` and `resource://load_nwbfile`) — no manual file setup required
172
+
173
+ ### For use in Code Ocean
174
+
175
+ * Refer to the [code ocean MCP server](https://github.com/codeocean/codeocean-mcp-server) for additional support
176
+
177
+ ## Development
178
+
179
+ To develop the code, run
180
+
181
+ ```bash
182
+ uv sync --group dev
183
+ ```
184
+
185
+ To run tests:
186
+
187
+ ```bash
188
+ uv run coverage run -m unittest discover && uv run coverage report
189
+ ```
190
+
191
+ To run linting:
192
+
193
+ ```bash
194
+ uv run flake8 . && uv run interrogate --verbose .
195
+ ```
@@ -0,0 +1,90 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "aind-data-mcp"
7
+ description = "Generated from aind-library-template"
8
+ license = {text = "MIT"}
9
+ requires-python = ">=3.11"
10
+ authors = [
11
+ {name = "Allen Institute for Neural Dynamics"}
12
+ ]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3"
15
+ ]
16
+ readme = "README.md"
17
+ dynamic = ["version"]
18
+
19
+ dependencies = [
20
+ "aind-data-access-api",
21
+ "fastmcp",
22
+ "hdmf-zarr>=0.11.1",
23
+ "langchain-core>=0.3.60",
24
+ "pydantic>=2.11.4",
25
+ "suffix-trees>=0.3.0",
26
+ ]
27
+
28
+ [project.scripts]
29
+ aind-data-mcp = "aind_data_mcp.data_access_server:main"
30
+
31
+ [dependency-groups]
32
+ dev = [
33
+ 'black',
34
+ 'coverage',
35
+ 'flake8',
36
+ 'interrogate',
37
+ 'isort',
38
+ 'Sphinx',
39
+ 'furo'
40
+ ]
41
+
42
+ [tool.setuptools.packages.find]
43
+ where = ["src"]
44
+
45
+ [tool.setuptools.dynamic]
46
+ version = {attr = "aind_data_mcp.__version__"}
47
+
48
+ [tool.black]
49
+ line-length = 79
50
+ target_version = ['py311']
51
+ exclude = '''
52
+
53
+ (
54
+ /(
55
+ \.eggs # exclude a few common directories in the
56
+ | \.git # root of the project
57
+ | \.hg
58
+ | \.mypy_cache
59
+ | \.tox
60
+ | \.venv
61
+ | _build
62
+ | build
63
+ | dist
64
+ | .conda
65
+ )/
66
+ | .gitignore
67
+ )
68
+ '''
69
+
70
+ [tool.coverage.run]
71
+ omit = ["*__init__*"]
72
+ source = ["aind_data_mcp", "tests"]
73
+
74
+ [tool.coverage.report]
75
+ exclude_lines = [
76
+ "if __name__ == .__main__.:",
77
+ "^from .* import .*",
78
+ "^import .*",
79
+ "pragma: no cover"
80
+ ]
81
+ fail_under = 100
82
+
83
+ [tool.isort]
84
+ line_length = 79
85
+ profile = "black"
86
+ skip = [".conda"]
87
+
88
+ [tool.interrogate]
89
+ exclude = ["setup.py", "docs", "build", ".conda"]
90
+ fail-under = 100
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ """Init package"""
2
+ __version__ = "0.1.2"
@@ -0,0 +1,42 @@
1
+ """MCP server for AIND data access."""
2
+
3
+ from pathlib import Path
4
+
5
+ # Import tool modules — side-effect registers all @mcp.tool() decorators
6
+ from .mcp_instance import mcp # noqa: F401
7
+ from . import example_tools # noqa: F401
8
+ from . import nwb_tools # noqa: F401
9
+ from . import query_tools # noqa: F401
10
+ from . import schema_tools # noqa: F401
11
+
12
+
13
+ @mcp.resource("resource://aind_api")
14
+ def get_aind_data_access_api() -> str:
15
+ """
16
+ Get context on how to use the AIND data access api to show users how to
17
+ wrap tool calls
18
+ """
19
+ resource_path = Path(__file__).parent / "resources" / "aind_api_prompt.txt"
20
+ with open(resource_path, "r") as file:
21
+ file_content = file.read()
22
+ return file_content
23
+
24
+
25
+ @mcp.resource("resource://load_nwbfile")
26
+ def get_nwbfile_download_script() -> str:
27
+ """
28
+ Get context on how to return an NWBfile from the /data folder in current repository
29
+ """
30
+ resource_path = Path(__file__).parent / "resources" / "load_nwbfile.txt"
31
+ with open(resource_path, "r") as file:
32
+ file_content = file.read()
33
+ return file_content
34
+
35
+
36
+ def main():
37
+ """Main entry point for the MCP server."""
38
+ mcp.run(transport="stdio")
39
+
40
+
41
+ if __name__ == "__main__":
42
+ main()