copick-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.
@@ -0,0 +1,174 @@
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
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 copick
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,351 @@
1
+ Metadata-Version: 2.4
2
+ Name: copick-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for Copick.
5
+ Project-URL: Repository, https://github.com/copick/copick-mcp
6
+ Project-URL: Issues, https://github.com/copick/copick-mcp/issues
7
+ Project-URL: Documentation, https://github.com/copick/copick-mcp#readme
8
+ Author-email: Kyle Harrington <czi@kyleharrington.com>, "Utz H. Ermel" <utz@ermel.me>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2025 copick
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: annotation,copick,cryo-et,cryoet,mcp,model-context-protocol,tomography
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Programming Language :: Python
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3 :: Only
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Programming Language :: Python :: 3.13
44
+ Classifier: Programming Language :: Python :: Implementation :: CPython
45
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
46
+ Requires-Python: >=3.9
47
+ Requires-Dist: click>=8.0
48
+ Requires-Dist: copick-torch
49
+ Requires-Dist: copick-utils
50
+ Requires-Dist: copick>=1.15.0
51
+ Requires-Dist: fastmcp>=0.1.0
52
+ Provides-Extra: dev
53
+ Requires-Dist: black>=25.1.0; extra == 'dev'
54
+ Requires-Dist: hatch-vcs>=0.4.0; extra == 'dev'
55
+ Requires-Dist: hatchling>=1.25.0; extra == 'dev'
56
+ Requires-Dist: ipython>=8.18.1; extra == 'dev'
57
+ Requires-Dist: pre-commit>=4.2.0; extra == 'dev'
58
+ Requires-Dist: ruff>=0.12.0; extra == 'dev'
59
+ Provides-Extra: test
60
+ Requires-Dist: pytest-cov>=6.2.1; extra == 'test'
61
+ Requires-Dist: pytest>=8.4.1; extra == 'test'
62
+ Description-Content-Type: text/markdown
63
+
64
+ # Copick MCP Server
65
+
66
+ A Model Context Protocol (MCP) server for Copick that provides two sets of tools:
67
+ 1. **Data Exploration Tools** - Browse and query copick project contents (read-only)
68
+ 2. **CLI Introspection Tools** - Discover and validate copick CLI commands for building processing pipelines
69
+
70
+ ## Features
71
+
72
+ - **Read-only data exploration** - List and inspect runs, picks, segmentations, meshes, tomograms, and project metadata
73
+ - **CLI discovery** - Dynamically discover all available copick CLI commands with full documentation
74
+ - **Command validation** - Validate copick CLI command syntax using Click's native parsing
75
+ - **Smart caching** - Efficient caching of copick project roots
76
+ - **Easy setup** - Simple CLI for registering with Claude Desktop
77
+
78
+ ## Installation
79
+
80
+ ```bash
81
+ cd copick-mcp
82
+ pip install -e .
83
+ ```
84
+
85
+ ## Quick Setup
86
+
87
+ ### Register with Claude Desktop
88
+
89
+ Use the copick CLI to register the MCP server with Claude Desktop:
90
+
91
+ ```bash
92
+ # Basic setup (default settings)
93
+ copick setup mcp
94
+
95
+ # Setup with custom server name
96
+ copick setup mcp --server-name "my-copick-server"
97
+
98
+ # Setup with default config path (optional - can be provided per-request)
99
+ copick setup mcp --config-path "/path/to/default/config.json"
100
+
101
+ # Check registration status
102
+ copick setup mcp-status
103
+ ```
104
+
105
+ After setup:
106
+ 1. Restart Claude Desktop completely
107
+ 2. The Copick MCP tools should now be available
108
+ 3. The server starts automatically when Claude Desktop connects
109
+
110
+ ### Manual Configuration (Optional)
111
+
112
+ If you prefer manual setup, add this to your Claude Desktop configuration file:
113
+
114
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
115
+
116
+ **Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
117
+
118
+ ```json
119
+ {
120
+ "mcpServers": {
121
+ "copick-mcp": {
122
+ "command": "python",
123
+ "args": ["-m", "copick_mcp.main"],
124
+ "env": {}
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ ## Available Tools
131
+
132
+ ### Data Exploration Tools (Read-Only)
133
+
134
+ All data exploration tools require a `config_path` parameter pointing to your copick configuration file.
135
+
136
+ #### `list_runs`
137
+ List all runs in a Copick project.
138
+ - **Args**: `config_path` (str)
139
+ - **Returns**: List of run names
140
+
141
+ #### `get_run_details`
142
+ Get detailed information about a specific run including voxel spacings, picks, meshes, and segmentations.
143
+ - **Args**: `config_path` (str), `run_name` (str)
144
+ - **Returns**: Comprehensive run details
145
+
146
+ #### `list_objects`
147
+ List all pickable objects defined in the project.
148
+ - **Args**: `config_path` (str)
149
+ - **Returns**: List of objects with properties (name, type, label, color, radius, etc.)
150
+
151
+ #### `list_picks`
152
+ List picks for a run with optional filtering.
153
+ - **Args**: `config_path` (str), `run_name` (str), `object_name` (optional), `user_id` (optional), `session_id` (optional)
154
+ - **Returns**: List of picks with point counts and sample coordinates
155
+
156
+ #### `list_meshes`
157
+ List meshes for a run with optional filtering.
158
+ - **Args**: `config_path` (str), `run_name` (str), `object_name` (optional), `user_id` (optional), `session_id` (optional)
159
+ - **Returns**: List of meshes
160
+
161
+ #### `list_segmentations`
162
+ List segmentations for a run with optional filtering.
163
+ - **Args**: `config_path` (str), `run_name` (str), `voxel_size` (optional), `name` (optional), `user_id` (optional), `session_id` (optional), `is_multilabel` (optional)
164
+ - **Returns**: List of segmentations with metadata
165
+
166
+ #### `list_tomograms`
167
+ List tomograms for a specific run and voxel spacing.
168
+ - **Args**: `config_path` (str), `run_name` (str), `voxel_spacing` (float)
169
+ - **Returns**: List of tomograms with feature information
170
+
171
+ #### `list_voxel_spacings`
172
+ List all voxel spacings available for a run.
173
+ - **Args**: `config_path` (str), `run_name` (str)
174
+ - **Returns**: List of voxel spacings with tomogram counts
175
+
176
+ #### `get_project_info`
177
+ Get general project information and statistics.
178
+ - **Args**: `config_path` (str)
179
+ - **Returns**: Project metadata and entity counts
180
+
181
+ #### `get_json_config`
182
+ Get the raw JSON configuration of the project.
183
+ - **Args**: `config_path` (str)
184
+ - **Returns**: Complete configuration dictionary
185
+
186
+ ### CLI Introspection Tools
187
+
188
+ These tools help LLMs discover and validate copick CLI commands for building processing pipelines.
189
+
190
+ #### `list_copick_cli_commands`
191
+ List all available copick CLI commands hierarchically organized by group.
192
+ - **Returns**: Complete command tree including:
193
+ - `main`: Core commands (add, browse, config, deposit, info, new, stats, sync)
194
+ - `inference`: Inference commands (e.g., membrain-seg)
195
+ - `training`: Training commands
196
+ - `evaluation`: Evaluation commands
197
+ - `process`: Processing commands (downsample, fit-spline, hull, skeletonize, etc.)
198
+ - `convert`: Conversion commands (picks2seg, mesh2seg, seg2picks, etc.)
199
+ - `logical`: Logical operations (clipmesh, clippicks, meshop, segop, etc.)
200
+
201
+ #### `get_copick_cli_command_info`
202
+ Get detailed information about a specific command.
203
+ - **Args**: `command_path` (str) - e.g., "convert.picks2seg" or "add"
204
+ - **Returns**: Full command details including:
205
+ - Help text and short description
206
+ - All parameters with types, defaults, and help text
207
+ - Required vs optional parameters
208
+ - Usage examples (if present in help)
209
+ - Command group
210
+
211
+ #### `validate_copick_cli_command`
212
+ Validate a copick CLI command string using Click's syntax validation.
213
+ - **Args**: `command_string` (str) - e.g., "copick convert picks2seg --config /path/to/config.json ..."
214
+ - **Returns**: Validation result including:
215
+ - Valid/invalid status
216
+ - Missing required parameters
217
+ - Parameter type errors
218
+ - Helpful error messages from Click
219
+
220
+ ## Usage Examples
221
+
222
+ ### Data Exploration Workflow
223
+
224
+ ```
225
+ User: "Show me all runs in my copick project at /data/my_project/config.json"
226
+
227
+ Assistant uses: list_runs(config_path="/data/my_project/config.json")
228
+
229
+ User: "What picks are available for run TS_001?"
230
+
231
+ Assistant uses: list_picks(config_path="/data/my_project/config.json", run_name="TS_001")
232
+
233
+ User: "Show me only the ribosome picks from user 'annotator1'"
234
+
235
+ Assistant uses: list_picks(
236
+ config_path="/data/my_project/config.json",
237
+ run_name="TS_001",
238
+ object_name="ribosome",
239
+ user_id="annotator1"
240
+ )
241
+ ```
242
+
243
+ ### CLI Discovery Workflow
244
+
245
+ ```
246
+ User: "I want to convert picks to a segmentation. What copick command can do that?"
247
+
248
+ Assistant uses: list_copick_cli_commands()
249
+ # Discovers convert.picks2seg command
250
+
251
+ Assistant uses: get_copick_cli_command_info(command_path="convert.picks2seg")
252
+ # Gets full documentation and parameters
253
+ Assistant explains:
254
+ "The picks2seg command converts picks to segmentation by painting spheres at pick locations.
255
+ It requires:
256
+ - --config: Path to copick config
257
+ - --input: Picks URI (format: object_name:user_id/session_id)
258
+ - --output: Segmentation URI (format: name:user_id/session_id@voxel_spacing)
259
+ - --radius: Sphere radius in angstroms (default: 10.0)"
260
+
261
+ User: "Can you validate this command for me: copick convert picks2seg --config /data/config.json --input 'ribosome:user1/manual-001' --output 'ribosome:picks2seg/painted-001@10.0'"
262
+
263
+ Assistant uses: validate_copick_cli_command(
264
+ command_string="copick convert picks2seg --config /data/config.json --input 'ribosome:user1/manual-001' --output 'ribosome:picks2seg/painted-001@10.0'"
265
+ )# Returns validation result: valid=True if syntax is correct
266
+ ```
267
+
268
+ ### Pipeline Building Workflow
269
+
270
+ ```
271
+ User: "I want to build a pipeline that:
272
+ 1. Converts ribosome picks to meshes
273
+ 2. Computes the convex hull of those meshes
274
+ 3. Converts the hulls to segmentations"
275
+
276
+ Assistant uses: list_copick_cli_commands()
277
+ # Discovers relevant commands in convert and process groups
278
+
279
+ Assistant uses: get_copick_cli_command_info(command_path="convert.picks2mesh")
280
+ Assistant uses: get_copick_cli_command_info(command_path="process.hull")
281
+ Assistant uses: get_copick_cli_command_info(command_path="convert.mesh2seg")
282
+ # Gets documentation for each command
283
+
284
+ Assistant suggests the pipeline:
285
+ "Here's a three-step pipeline for your workflow:
286
+
287
+ Step 1: Convert picks to meshes
288
+ copick convert picks2mesh --config /path/to/config.json \
289
+ --input 'ribosome:user1/manual-001' \
290
+ --output 'ribosome:pipeline/step1-meshes' \
291
+ --method convex_hull
292
+
293
+ Step 2: Compute convex hull (if not done in step 1)
294
+ copick process hull --config /path/to/config.json \
295
+ --input-mesh 'ribosome:pipeline/step1-meshes' \
296
+ --output-mesh 'ribosome:pipeline/step2-hulls'
297
+
298
+ Step 3: Convert meshes to segmentation
299
+ copick convert mesh2seg --config /path/to/config.json \
300
+ --input 'ribosome:pipeline/step2-hulls' \
301
+ --output 'ribosome:pipeline/final-seg@10.0'"
302
+ ```
303
+
304
+ ## Management Commands
305
+
306
+ ```bash
307
+ # Check MCP server status
308
+ copick setup mcp-status
309
+
310
+ # Remove MCP server configuration
311
+ copick setup mcp-remove --server-name "copick-mcp"
312
+
313
+ # Force removal without confirmation
314
+ copick setup mcp-remove --server-name "copick-mcp" --force
315
+ ```
316
+
317
+ ## Troubleshooting
318
+
319
+ 1. **"MCP server not found"**: Ensure you've restarted Claude Desktop completely after configuration
320
+ 2. **"Python module not found"**: Verify the package is installed and the Python path is correct in the config
321
+ 3. **"Permission denied"**: Check that the Claude config directory is writable
322
+ 4. **"Invalid JSON"**: Use `copick setup mcp-status` to validate your configuration
323
+ 5. **"Command not found" during CLI introspection**: Ensure copick and all plugin packages (copick-torch, copick-utils) are installed
324
+ 6. **"setup command not found"**: Make sure copick-mcp is installed (`pip install -e .` from the copick-mcp directory)
325
+
326
+ ## Development
327
+
328
+ ```bash
329
+ # Install in development mode
330
+ cd copick-mcp
331
+ pip install -e ".[dev]"
332
+
333
+ # Format code
334
+ black src/
335
+
336
+ # Lint
337
+ ruff check --fix src/
338
+
339
+ # Run the server locally for testing
340
+ python -m copick_mcp.main
341
+ ```
342
+
343
+ ## License
344
+
345
+ MIT License - See LICENSE file for details.
346
+
347
+ ## Links
348
+
349
+ - [Copick Documentation](https://copick.github.io/copick)
350
+ - [Model Context Protocol](https://modelcontextprotocol.io)
351
+ - [FastMCP](https://github.com/jlowin/fastmcp)