Files
JuliaMSI_MCP/bin/run_server.jl
T
Pixelguy14 c3d5daeec5
CI / test (push) Has been cancelled
feat: JuliaMSI MCP server v0.1.0 — 20 tools ready for testing
Implements the Model Context Protocol server for the JuliaMSI mass
spectrometry imaging engine, covering phases 1–3 of the implementation
plan plus the main phase-4 items.

Tools (20):
  session/dataset:   msi_open_dataset, msi_close_dataset, msi_dataset_info,
                     msi_get_dataset_stats
  spectra:           msi_get_spectrum_at_coord, msi_get_spectrum_by_index
  ion images:        msi_get_mz_slice, msi_get_multiple_mz_slices,
                     msi_plan_ion_image, msi_plan_multiple_slices
  preprocessing:     msi_plan_preprocessing, msi_plan_streaming_pipeline,
                     msi_plan_analytics
  execution:         msi_execute_runspec, msi_list_plans,
                     msi_get_task_status, msi_get_task_result,
                     msi_cancel_task, msi_list_tasks
  maintenance:       msi_clean_artifacts

Resources (msi://): dataset/metadata, dataset/stats,
  tasks/{task_id}/status, tasks/{task_id}/result
Prompts: analyze_region_of_interest, standard_pipeline, diagnose_task

- Persistent session: one MSIData kept alive between tool calls
- Plan -> execute -> poll async core (SHA-256 RunSpecs + background tasks)
- Results as on-disk artifacts (CSV/PGM/MatrixMarket) with compact previews
- Structured JSON-RPC error mapping with suggested actions
- stdio and Streamable HTTP transports, optional shared-token auth
- Artifact retention (age + size budgets) and glibc malloc_trim cleanup
- 107 tests + end-to-end stdio smoke test; validated on HR2MSI bladder
  (imzML) and T9_A1/Col_1 (mzML)

Required JuliaMSI engine fixes are tracked in patches/ (already upstream
on the rel/Windows_Mac_Recompatibility branch and GitHub main).
2026-11-25 13:25:13 -06:00

79 lines
2.1 KiB
Julia

#!/usr/bin/env julia
# ---------------------------------------------------------------------------
# JuliaMSI MCP server entry point.
#
# julia --project=/path/to/JuliaMSI_MCP --threads=auto bin/run_server.jl
# julia --project=/path/to/JuliaMSI_MCP --threads=auto bin/run_server.jl --http --port 3000
# ---------------------------------------------------------------------------
using JuliaMSI_MCP
function usage()
println(stderr, """
JuliaMSI MCP server $(JuliaMSI_MCP.SERVER_VERSION)
Usage:
julia --project=<project> --threads=auto bin/run_server.jl [options]
Options:
--http Serve MCP over Streamable HTTP instead of stdio
--host <addr> Bind address for --http (default 127.0.0.1)
--port <n> Port for --http (default 3000)
--token <value> Require `Authorization: Bearer <value>` (HTTP only;
also JULIA_MSI_MCP_TOKEN)
--version Print the version and exit
-h, --help Show this help
""")
end
function main(args)
http = false
host = "127.0.0.1"
port = 3000
token = nothing
i = 1
while i <= length(args)
a = args[i]
if a == "--http"
http = true
elseif a == "--host"
i += 1
i <= length(args) || (usage(); return 2)
host = args[i]
elseif a == "--port"
i += 1
i <= length(args) || (usage(); return 2)
port = try
parse(Int, args[i])
catch
println(stderr, "Invalid --port value: $(args[i])")
return 2
end
elseif a == "--token"
i += 1
i <= length(args) || (usage(); return 2)
token = args[i]
elseif a == "--version"
println(JuliaMSI_MCP.SERVER_VERSION)
return 0
elseif a in ("-h", "--help")
usage()
return 0
else
println(stderr, "Unknown argument: $(a)")
usage()
return 2
end
i += 1
end
if http
run_http(host=host, port=port, token=token)
else
run_stdio()
end
return 0
end
exit(main(ARGS))