champollion-sulcal-mcp

champollion-sulcal-mcp

Exposes each stage of the Champollion sulcal embedding pipeline as MCP tools, enabling agents to run, monitor, and debug the pipeline without manual shell commands.

Category
访问服务器

README

champollion-sulcal-mcp

A FastMCP server wrapping the Champollion sulcal embedding pipeline — exposes each pipeline stage as an MCP tool so an agent can run, monitor, and debug the pipeline without shelling out manually.

Overview

This is a stdio MCP server (not a web service). It doesn't run the pipeline in-process — each start_* tool launches one of the pipeline's CLI scripts as a subprocess and tracks it as a background job (status + log file on disk), which callers poll until it reaches a terminal state.

It's consumed by the technician agent in the sibling champollion_agents repo, and also ships its own Claude Code subagent definition and skills so it can be driven directly from Claude Code.

How it works

  1. A caller (an MCP client, or the Technician agent via claude-code-sdk) invokes a tool such as start_cortical_tiles.
  2. The tool validates its arguments (paths must be absolute), resolves the pipeline's script location via preflight.detect(), and builds an argv matching that script's real CLI.
  3. runner.launch() spawns the script as a subprocess with an environment built by _build_env() (selectively passes HF_TOKEN, injects BRAINVISA_SHARE, prepends BrainVISA/pixi bins to PATH), and returns immediately with a job_id.
  4. The subprocess's combined stdout/stderr is streamed line-by-line into a log file; progress lines matching fold N/M update the job's progress.
  5. The caller polls get_job_status(output_dir, job_id) (and can tail get_job_log) until the job is succeeded, failed, or cancelled.

Pipeline stages

Stage Tool Purpose
1 start_morphologist Generate sulcal graphs from T1 MRI using Morphologist
2 start_cortical_tiles Extract 28 standardized sulcal region crops
3 start_config Generate Champollion dataset YAML configuration
4 start_embeddings Compute 56-fold sulcal embeddings (28 regions × 2 hemispheres)
5 start_combine Collect per-region embedding CSVs into a single output directory
6 start_snapshots Render sulcal graph meshes, cortical tile masks, and UMAP plots
start_pipeline Run stages 1–6 sequentially as one umbrella job (stages skippable)
start_streaming Scan-centric mode: one worker per scan runs stages 2–4 in parallel; combine runs once after all workers drain
start_training Train a self-supervised champollion_V1 encoder for one region

Project layout

src/champollion_sulcal_mcp/
├── server.py            # FastMCP instance, tool registration, entry point (main())
├── preflight.py          # locates the champollion_pipeline repo + its scripts/submodules
├── job_store.py           # JobState/JobProgress models, JSON job file persistence
├── runner.py               # subprocess launch, log streaming, progress parsing, cancel
└── tools/
    ├── stages.py           # one start_<stage> tool per pipeline stage + maintenance tools
    ├── pipeline.py          # start_pipeline composite/umbrella job orchestration
    ├── jobs.py               # get_job_status, list_jobs, cancel_job, get_job_log
    └── utils.py               # get_pipeline_info, preflight_check
agents/
└── champollion-pipeline.md  # Claude Code subagent definition for this MCP server
skills/
├── run-pipeline/             # SKILL.md guiding stage-centric vs streaming execution
├── monitor/                   # SKILL.md for the job-polling loop
└── debug/                      # SKILL.md + known error patterns for failure diagnosis
docs/
└── agents_architecture.md      # early design doc for the champollion_agents repo (historical, superseded — see note below)
tests/                           # pytest suite with fake_pipeline_dir / recording_runner fixtures

MCP tools reference

Registered in server.py:

Stage launchersstart_morphologist, start_cortical_tiles, start_config, start_training, start_embeddings, start_combine, start_snapshots

Composite pipelinestart_pipeline

Streamingstart_streaming

Maintenancepurge_subject (remove a subject's cortical_tiles derivatives), prune_failed_subjects (remove outputs for subjects that failed QC)

Job lifecycleget_job_status, list_jobs, cancel_job, get_job_log

Utilitiesget_pipeline_info (server/stage metadata), preflight_check (verify the pipeline is correctly configured and accessible)

Requirements

  • Python 3.11 or 3.12
  • pixi
  • The sibling champollion_pipeline repository (not included here) — must contain the stage scripts under src/ (generate_morphologist_graphs.py, run_cortical_tiles.py, generate_champollion_config.py, generate_embeddings.py, put_together_embeddings.py, generate_snapshots.py, train_champollion.py, run_streaming.py) and the external/champollion_V1 and external/cortical_tiles submodules.

Installation

pixi install

Configuration

Variable Purpose Default
CHAMPOLLION_PIPELINE_DIR Absolute path to the champollion_pipeline repo Falls back to ../champollion_pipeline relative to this package
HF_TOKEN HuggingFace token Passed through only to the embeddings and streaming stages; stripped from every other stage's subprocess environment
BRAINVISA / BRAINVISA_SHARE BrainVISA install location / share dir Auto-injected from the pipeline's pixi environment if not already set in the environment

Running

This is a stdio server meant to be launched by an MCP client (e.g. the Technician agent's ClaudeCodeOptions.mcp_servers config in champollion_agents), not run interactively on its own:

pixi run run                  # python -m champollion_sulcal_mcp.server
# or, once installed:
champollion-sulcal-mcp

Claude Code integration

Beyond the raw MCP tools, this repo ships assets for using the pipeline directly from Claude Code:

  • agents/champollion-pipeline.md — a subagent scoped to exactly the MCP tools it needs, with an operational playbook: always preflight first, never guess paths, default output layout, per-stage required parameters, a known-error-pattern table, and the exact CLI invocation each tool wraps.
  • skills/run-pipeline — guides choosing stage-centric vs. streaming execution and gathering the right parameters.
  • skills/monitor — a poll-every-30-seconds monitoring loop with per-job-type progress reporting.
  • skills/debug — systematic failure diagnosis: read the full log, match against known error patterns, report root cause and fix.

Job tracking

Each job is persisted as <output_dir>/.mcp_jobs/<job_id>.json (atomic write) with its combined stdout/stderr log at <output_dir>/.mcp_jobs/<job_id>.log. Status lifecycle: pendingrunning → one of succeeded / failed / cancelled. start_pipeline additionally writes an "umbrella" job whose progress tracks current_stage / stages_done / stages_total and the currently active child job_id.

Testing

pixi run test           # full suite
pixi run test-unit        # unit-marked tests only
pixi run test-fast         # stop on first failure
pixi run test-cov           # with coverage report

tests/conftest.py provides fake_pipeline_dir (a temp dir with stub stage scripts and submodule folders) and recording_runner (stubs runner.launch to record calls instead of spawning real subprocesses), so most tool behavior can be tested without a real champollion_pipeline checkout.

Linting

pixi run lint        # ruff check
pixi run lint-fix      # ruff check --fix
pixi run format         # ruff format

Note on docs/agents_architecture.md

That document is an early architecture proposal for the champollion_agents repo (ACP/acp-sdk, OpenAI-compatible LLM backend, in-process ChromaDB indexing). It predates and does not reflect the current implementation of either repo — champollion_agents now runs its agents through claude-code-sdk rather than a custom ACP/LangGraph stack, and this repo has no LLM or ACP code at all. Kept for historical context only.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选