生物图像mcp服务器
MCP服务器,允许LLM代理访问显微镜图像数据。 通过以下方式读取150多种文件格式(CZI、ND2、LIF、OME-TIFF等) 生物格式 并暴露 五种工具用于检查元数据、生成视觉预览, 计算强度统计并转换为开放格式。
交给你的经纪人 .czi 并询问“收购了哪些渠道?”或 “这个图像饱和了吗?”--没有桌面应用程序或一次性脚本 必修的。
注意安全
这是一个非常新的概念验证实施。它已经 其架构具有健壮性、可扩展性和安全性。然而,它没有 广泛使用,在实践中发现问题!
谨慎使用,但也要热情,因为有法学硕士学位很好 更好地访问您的数据。如果你发现有什么问题,或者想 功能已调整,请提交问题!
快速启动
先决条件
- Jbang (为您安装和管理JVM)
安装应 下载中列出的命令行上的一行 页!
与Claude Code一起使用
claude mcp add bioimage-mcp \
-- jbang https://github.com/ichoran/bioimage-mcp-server/blob/main/runner/bioimage_mcp.java然后,未来对claude的调用将可以访问。
或者从bioimage_mcp.java文件的本地克隆或副本(通常是 应该使用系统上的绝对路径,而不仅仅是 runner/bioimage_mcp.java):
claude mcp add bioimage-mcp \
-- jbang runner/bioimage_mcp.java为了移除,
claude mcp remove bioimage-mcp并且未来的调用将不再具有访问权限。
与Claude Desktop一起使用
添加到您的Claude Desktop配置(claude_desktop_config.json), 对路径也有同样的警告:
{
"mcpServers": {
"bioimage-mcp": {
"command": "jbang",
"args": ["runner/bioimage_mcp.java"]
}
}
}其他客户
指示客户端通过URL或本地目标使用jbang运行,使用 克劳德的例子作为指导。
文件访问
默认情况下,服务器仅访问由声明的目录下的文件 MCP客户端(客户端根)。授予对其他路径的访问权限,或 要拒绝访问敏感目录,请复制runner文件并编辑 允许/拒绝列表:
BioImageMcpServer.builder()
.allow("/data/microscopy")
.allow("/shared/lab-images")
.deny("/data/microscopy/private")
.build()
.run(args);这使您的访问规则在 单个文件。然后将您的MCP客户端指向您编辑过的副本,而不是 原件。
对于快速一次性使用,您也可以通过 --allow 和 --deny 旗帜 在命令行上:
jbang runner/bioimage_mcp.java --allow /data/microscopy --deny /tmp/secretCLI标志与runner文件中硬编码的任何路径合并。 否认规则总是赢。详见DESIGN.md§5。
工具
| 工具 | 退货 | 目的 |
|---|---|---|
inspect_image | JSON | 尺寸、像素类型、物理尺寸、通道、仪器信息 |
get_thumbnail | PNG | 带Z投影和通道合成的RGB合成预览 |
get_plane | PNG | 全分辨率单通道灰度平面 |
get_intensity_stats | JSON | 最小值/最大值/平均值/标准偏差/中值、直方图、饱和度警告 |
export_to_tiff | JSON | 使用可选子集转换为OME-TIFF |
所有工具都接受绝对文件路径,并安全处理大文件 (自适应子采样、时间预算)。错误返回为 结构化消息,永远不会被默默吞噬——请参阅DESIGN.md了解 理论基础。
典型工作流程
inspect_image--了解文件中的内容(从summary细节)get_thumbnail--快速视觉概览get_plane/get_intensity_stats--详细调查export_to_tiff--转换为下游工具(FIJI、napari等)
示例会话(部分)
> Can you find a tiff file in (elided) and get image info about it?
● Searched for 1 pattern (ctrl+o to expand)
● Found several TIFF files. Let me inspect the first one.
● bioimage-mcp - inspect_image (MCP) [...]
● Here's the info on the first TIFF file:
┌─────────────────┬──────────────────────────┐
│ Property │ Value │
├─────────────────┼──────────────────────────┤
│ Format │ Tagged Image File Format │
├─────────────────┼──────────────────────────┤
│ Dimensions │ 2000 x 480 pixels │
├─────────────────┼──────────────────────────┤
│ Z slices │ 1 │
├─────────────────┼──────────────────────────┤
│ Channels │ 1 │
├─────────────────┼──────────────────────────┤
│ Timepoints │ 20,004 │
├─────────────────┼──────────────────────────┤
│ Pixel type │ uint16 │
├─────────────────┼──────────────────────────┤
│ Pixel size │ 1.0 x 1.0 µm │
├─────────────────┼──────────────────────────┤
│ Dimension order │ XYCZT │
└─────────────────┴──────────────────────────┘
This is a time-series with 20,004 frames — a single-channel, single-Z-plane
recording at 2000x480 pixels. Looks like it could be a calcium imaging or
similar time-lapse acquisition.❯ Let's get the image stats from the first 120 timepoints and the last 120
timepoints.
● bioimage-mcp - get_intensity_stats (MCP) [...]
● bioimage-mcp - get_intensity_stats (MCP) [...]
● Here's a comparison of the first and last 120 timepoints:
┌────────────────┬─────────────────────┬──────────────────────────┐
│ Statistic │ First 120 (t 0–119) │ Last 120 (t 19884–20003) │
├────────────────┼─────────────────────┼──────────────────────────┤
│ Min │ 59 │ 60 │
├────────────────┼─────────────────────┼──────────────────────────┤
│ Max │ 489 │ 281 │
├────────────────┼─────────────────────┼──────────────────────────┤
│ Mean │ 98.53 │ 98.43 │
├────────────────┼─────────────────────┼──────────────────────────┤
│ Std Dev │ 5.69 │ 5.07 │
├────────────────┼─────────────────────┼──────────────────────────┤
│ Median │ 98 │ 98 │
├────────────────┼─────────────────────┼──────────────────────────┤
│ Saturation │ 0% │ 0% │
├────────────────┼─────────────────────┼──────────────────────────┤
│ Bit depth used │ 0.66% │ 0.34% │
└────────────────┴─────────────────────┴──────────────────────────┘
Key observations:
- Very stable baseline — mean and median are essentially identical between the
start and end of the recording (~98).
- Reduced dynamic range over time — the max dropped from 489 to 281, and
stddev decreased from 5.69 to 5.07. This could indicate photobleaching,
reduced activity, or fewer bright transient events later in the recording.从源头构建
先决条件
- 磨坊 1.1+
安装 命令上应该有一两行 线.
命令
mill test # run all tests (367 unit + integration)
mill assembly # build fat jar
mill run # run the server directly via Mill
mill publishLocal # publish to ~/.ivy2/local for local testing与JBang共同开发
根据本地构建测试运行器(不发布到Maven 中央):
mill assembly
jbang --cp "$(mill show assembly | tr -d '"')" runner/bioimage_mcp.java集成测试
将服务器作为子进程生成,并在其上执行MCP协议 标准 :
mill assembly && jbang integration-test/SmokeTest.java看 integration-test/README.md 了解详情。
项目结构
src/server/ Main sources (Java 21, package lab.kerrr.mcpbio.bioimageserver)
test/src/server/ Unit tests (JUnit 5)
test/fixtures/ Test data (downloaded on demand, gitignored)
runner/ JBang entry point for end users
integration-test/ End-to-end MCP protocol testsBio-Formats API的使用仅限于 BioFormatsReader.java 和 BioFormatsWriter.java其他一切都取决于 ImageReader / ImageWriter 接口和模型记录。
许可证
GPL-3.0——见 许可证.
生物格式(ome:formats-gpl)是GPL-2.0,与 GPLv3。
