切片机mcp
  
用于控制的MCP服务器 3D切片机 从克劳德代码, 游标、OpenCode或任何MCP客户端。
桥没有嵌入切片器。它将Python代码段发送到Slicer的WebServer 端点并读取通过以下方式返回的JSON __execResult.
状态
- 注册了48个MCP工具和4个MCP资源。
slicer-prod命令同步为绿色:.claude/commands/恢复和
slicer-prod/.claude/commands 是一个有效的符号链接。
- 非集成套件在本地和CI中都是绿色的。
- 切片器5.10.0已经过手动烟雾测试,但
SLICER_TESTED_VERSIONS 仍然将5.6.2列为最新测试版本。
core/async_client.py存在但未连接到注册服务器。
安装
git clone https://github.com/brainbloodbarrier/3dslicer-claude-bridge.git
cd 3dslicer-claude-bridge
uv sync --extra dev --extra metrics跑
- 在3D切片器中,启动 模块->开发工具->Web服务器.
- 启动MCP服务器:
uv run slicer-mcp- 配置您的MCP客户端:
{
"mcpServers": {
"slicer-bridge": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/3dslicer-claude-bridge",
"run",
"slicer-mcp"
],
"env": {
"SLICER_URL": "http://localhost:2016"
}
}
}
}客户端特定设置: docs/guides/setup-mcp-clients.md.
存储库映射
src/slicer_mcp/
server.py FastMCP entry point
_registry/ tool/resource registration and error mapping
features/ domain logic and Slicer Python snippet generation
core/ HTTP client, config, circuit breaker, metrics, resources
spine_constants.py only remaining root compatibility shim
.claude/commands/ canonical command docs
slicer-prod/ small MCP client surface for Claude Code and OpenCode
tests/ unit, contract, integration, and benchmark tests
docs/ client setup, project status, historical plans一份软件包维护说明保存在 src/slicer_mcp/AGENTS.md。不要按文件夹添加 代理人文件;它们漂移得太快了。
发展
# Unit tests, no running Slicer required
uv run pytest -v -m "not integration and not benchmark"
# Integration tests, requires Slicer on localhost:2016
uv run pytest -v -m integration
# Lint, format, and type-check
uv run ruff check src tests
uv run ruff format --check src tests
uv run mypy src/
# Validate slicer-prod command sync
python3 slicer-prod/scripts/sync_surface.py --checkCI在Python 3.12上执行相同的检查和覆盖率。
配置
配置由以下人员验证 slicer_mcp.core.config.SlicerMCPConfig. 环境变量使用 SLICER_ 前缀。
| 变量 | 默认值 | 用途 |
|---|---|---|
SLICER_URL | http://localhost:2016 | 切片器Web服务器端点 |
SLICER_TIMEOUT | 30 | HTTP超时,秒 |
SLICER_MIN_VERSION | 5.0.0 | 预期的最小切片器版本 |
SLICER_RETRY_MAX_ATTEMPTS | 3 | 重试连接错误计数 |
SLICER_RETRY_BACKOFF_BASE | 1.0 | 重试退避基数,秒 |
SLICER_CIRCUIT_BREAKER_THRESHOLD | 5 | 断路前故障 |
SLICER_CIRCUIT_BREAKER_TIMEOUT | 30.0 | 半开探头前几秒 |
SLICER_AUDIT_LOG | disabled | 已执行代码的审核日志路径 |
SLICER_METRICS_ENABLED | false | 启用Prometheus指标 |
