|
| 1 | +# 🤖 MCP Server |
| 2 | + |
| 3 | +The [`ngff-zarr-mcp`] Python package provides a Model Context Protocol (MCP) server that enables seamless integration with AI agents and development tools. This server provides a standardized interface for AI agents to interact with ngff-zarr's capabilities for converting datasets to the OME-Zarr scientific imaging data format. |
| 4 | + |
| 5 | +## What is MCP? |
| 6 | + |
| 7 | +The Model Context Protocol (MCP) is an open standard that allows AI agents to securely access external data sources and tools. It creates a bridge between AI models and various applications, enabling them to work together more effectively. |
| 8 | + |
| 9 | +## Integration with AI Agents |
| 10 | + |
| 11 | +The [`ngff-zarr-mcp`] server can be integrated with various AI agents and development environments, including: |
| 12 | + |
| 13 | +- **GitHub Copilot** in VS Code |
| 14 | +- **OpenCode** |
| 15 | +- **Cursor** |
| 16 | +- **Claude Code** |
| 17 | +- Any other agent that supports the MCP standard |
| 18 | + |
| 19 | +This integration allows you to use natural language to: |
| 20 | +- Convert datasets to OME-Zarr format |
| 21 | +- Optimize compression codecs |
| 22 | +- Configure sharding to limit file count |
| 23 | +- Generate Python scripts for batch processing |
| 24 | +- Validate OME-Zarr stores |
| 25 | +- ... and more! |
| 26 | + |
| 27 | +## Example Usage |
| 28 | + |
| 29 | +Here's an example of how you might interact with the MCP server through an AI agent: |
| 30 | + |
| 31 | +### OpenCode Demo |
| 32 | + |
| 33 | +The `ngff-zarr-mcp` Model Context Protocol (MCP) server converts datasets to the OME-Zarr scientific imaging data format, optimizes the compression codec, ensures a limited number of files are generated, and creates a Python script for re-use. |
| 34 | + |
| 35 | +<script src="https://asciinema.org/a/726628.js" id="asciicast-726628" async="true"></script> |
| 36 | + |
| 37 | +#### Sample Prompts |
| 38 | + |
| 39 | +> Convert LIDCFull.tif to OME-Zarr |
| 40 | +
|
| 41 | +> Find the optimal codec to use for this data. |
| 42 | +
|
| 43 | +> Use sharding to keep the number of files under 20. |
| 44 | +
|
| 45 | +> Create a Python script to convert all files in a provided input directory to a provided output directory. Use the codec we found to be optimal. |
| 46 | +
|
| 47 | +## Configuration |
| 48 | + |
| 49 | +The MCP server can be configured for use with different AI agents. Here's an example configuration for OpenCode: |
| 50 | + |
| 51 | +```json |
| 52 | +{ |
| 53 | + "$schema": "https://opencode.ai/config.json", |
| 54 | + "mcp": { |
| 55 | + "ngff-zarr": { |
| 56 | + "type": "local", |
| 57 | + "command": ["uvx", "ngff-zarr-mcp"], |
| 58 | + "enabled": true |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +A similar configuration can be used for other agents like GitHub Copilot or Cursor, adjusting the command and environment as needed. |
| 65 | +The [`ngff-zarr-mcp`] provides guidance on how to set up the MCP server for different environments. |
| 66 | + |
| 67 | +## Available Functions |
| 68 | + |
| 69 | +The MCP server provides the following functions: |
| 70 | + |
| 71 | +- **convert_images_to_ome_zarr**: Convert images to OME-Zarr format with customizable parameters |
| 72 | +- **get_ome_zarr_info**: Get detailed information about an OME-Zarr store |
| 73 | +- **validate_ome_zarr_store**: Validate OME-Zarr store structure and metadata |
| 74 | +- **optimize_ome_zarr_store**: Optimize existing stores with new compression/chunking |
| 75 | + |
| 76 | +## Benefits |
| 77 | + |
| 78 | +Using the MCP server provides several advantages: |
| 79 | + |
| 80 | +1. **Natural Language Interface**: Interact with ngff-zarr using conversational prompts |
| 81 | +2. **Automated Workflows**: Let AI agents handle complex conversion tasks |
| 82 | +3. **Intelligent Optimization**: Get AI-driven recommendations for compression and chunking |
| 83 | +4. **Code Generation**: Automatically generate Python scripts for batch processing |
| 84 | +5. **Seamless Integration**: Works within your existing development environment |
| 85 | + |
| 86 | +## Getting Started |
| 87 | + |
| 88 | +To use the MCP server: |
| 89 | + |
| 90 | +1. Install ngff-zarr with MCP support |
| 91 | +2. Configure your AI agent to use the [`ngff-zarr-mcp`] server |
| 92 | +3. Start interacting with natural language prompts |
| 93 | + |
| 94 | +For detailed installation and setup instructions, the [MCP server README](https://github.com/thewtex/ngff-zarr/tree/main/mcp/README.md) for comprehensive setup instructions and examples. |
| 95 | + |
| 96 | +[`ngff-zarr-mcp`]: https://pypi.org/project/ngff-zarr-mcp/ |
0 commit comments