opensim-bio-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
opensim-bio-mcp
Typed, reproducible access to OpenSim musculoskeletal models for humans and AI agents, through a Python library, a CLI and a local Model Context Protocol (MCP) server.
Unofficial. This project is not affiliated with or endorsed by Stanford University or the OpenSim project. It uses the official OpenSim Python bindings.
Status: pre-alpha (0.1.0.dev0). Tested against OpenSim 4.6 on macOS arm64. The interface may change. Read Known limitations before using any output.
What it does
An agent (or you, from the CLI) can inspect a model, compute muscle geometry at a posture, and run coordinate-sweep experiments that record musculotendon length and moment arm for chosen muscles while one coordinate moves through a range. Every run is a self-contained directory:
the exact input spec, the model's hash, software versions and the source commit;
CSV results and figures;
verification.json, with automatic checks on every run: the moment arm against a finite difference of length (r = −dL/dq), whether the requested posture was actually held, whether muscles span the coordinate, and optional invariance checks;REPRODUCE.md, with the CLI command that reruns it without any agent.
scripts/verify_direct_opensim.py independently recomputes a run with the raw OpenSim API, without
this package's analysis code.
Related MCP server: COMSOL MCP Verifier
Principles
OpenSim is the only source of numbers. Nothing is estimated or filled in. Every result traces to a run directory.
Failures are reported, not hidden. A run with a failed check completes with status
completed_with_failed_checksand quotes the check.Numerical agreement is not biomechanical validity. The checks show that the software reports what OpenSim computes, and that OpenSim's quantities are self-consistent. Whether the model represents real people for your question is not established by any automated check.
No clinical, diagnostic or injury-risk claims. Moment arms and lengths say nothing about activation, force or joint loading.
Safe by design. No shell or code-execution tools. All paths are confined to a workspace directory. OpenSim runs in a worker subprocess with timeouts, never in the server process. Run size is capped.
Install (macOS Apple Silicon or Linux x86_64)
OpenSim comes from the official opensim-org conda channel, so install with conda:
bash scripts/setup_macos.shor step by step:
conda env create -f environment.yml # OpenSim 4.6, Python 3.12, MCP SDK v2
conda activate opensim-bio-mcp
pip install -e ".[dev]" --no-deps
opensim-bio-mcp init-workspace -w ./workspace # layout + example experiment spec
opensim-bio-mcp fetch-models -w ./workspace # pinned models, hash-verified, written read-only
OPENSIM_BIO_MCP_TEST_WORKSPACE=./workspace pytest -vThere is no Linux aarch64 OpenSim build, so ARM Linux VMs and containers can't run it.
Use from an MCP client
Claude Code:
claude mcp add opensim -- /path/to/envs/opensim-bio-mcp/bin/opensim-bio-mcp serve --workspace /path/to/workspaceCodex (~/.codex/config.toml):
[mcp_servers.opensim]
command = "/path/to/envs/opensim-bio-mcp/bin/opensim-bio-mcp"
args = ["serve", "--workspace", "/path/to/workspace"]
tool_timeout_sec = 900Tools: get_environment_info, list_models, inspect_model, list_coordinates, list_muscles,
compute_muscle_geometry, get_experiment_schema, create_experiment, validate_experiment,
run_experiment, list_runs, get_run_results.
Typical flow: get_environment_info → list_models → list_coordinates / list_muscles →
get_experiment_schema → create_experiment → validate_experiment → run_experiment →
get_run_results.
Use without an agent
opensim-bio-mcp env -w ./workspace
opensim-bio-mcp inspect rajagopal2016 -w ./workspace --section coordinates
opensim-bio-mcp validate-experiment experiments/knee_flexion_muscle_geometry/spec.json -w ./workspace
opensim-bio-mcp run-experiment experiments/knee_flexion_muscle_geometry/spec.json -w ./workspace
python scripts/verify_direct_opensim.py workspace/runs/knee-flexion-muscle-geometry/<run_id> --every 5Exit codes for run-experiment: 0 succeeded, 3 completed with failed checks, 1 failed.
Example experiment
experiments/knee_flexion_muscle_geometry/spec.json sweeps right knee flexion from 0 to 110° in the
Rajagopal 2016 model under three hip/ankle conditions. It records musculotendon length and knee
moment arm for 12 muscles, checks every moment arm against a finite difference of length, and checks
that the monoarticular muscles are invariant to hip and ankle posture.
Models
Registry id | Model | Notes |
| Rajagopal et al. 2016 full-body model | |
| Rajagopal 2016 with the Lai 2017 high-flexion and Uhlrich 2022 passive-curve changes | |
| OpenSim 2-DOF arm example | test fixture only, not for scientific conclusions |
Models are downloaded from pinned commits of opensim-org/opensim-models into your workspace and verified by hash. They are not redistributed here, and their licenses are independent of this project's. Check them before publishing anything derived from a model.
Known limitations
Geometry only. No forces, activations, inverse kinematics, inverse dynamics or Moco yet.
F-001: moment arm vs −dL/dq while wrapping (
docs/DECISIONS.mdD-016, D-024). Themoment_arm_fd_agreementcheck flags rows where OpenSim'scomputeMomentArmdiffers from the finite-difference derivative ofgetLength, and both quantities are written tomoment_arms.csv.Two engaged wrap objects (gastrocnemii near knee extension; up to 18 mm in the example experiment): an OpenSim 4.6 defect in
getLength. It is fixed upstream in opensim-core #4485 but not yet released. This package uses the 4.6 release, so its results still show it.Single wrap objects (bfsh_r at 96–110°, grac_r at 0°; up to 0.3 mm): unchanged by that fix, cause unknown.
No regression baselines yet. They will only be recorded from reviewed real runs.
Tested on macOS arm64 only so far. Linux x86_64 should work but has not been tested.
Layout
src/opensim_bio_mcp/ core/ models/ analysis/ experiments/ visualization/ server/ jobs.py worker.py cli.py
experiments/ versioned experiment specs (inputs)
scripts/ setup, independent cross-check, baseline recording
tests/ unit (incl. a fenced OpenSim test double), integration (real OpenSim), regression
docs/ ARCHITECTURE, DECISIONS, FEASIBILITY, LEARNING, REFERENCES, ROADMAP
workspace/ (git-ignored) models, runs, logsContributing
See CONTRIBUTING.md. The rules for AI agents working in this repository are in AGENTS.md; they apply to human contributors too.
License and citation
Apache-2.0 (LICENSE). If you use this software, cite it with CITATION.cff and cite OpenSim and the models you used.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Inspect, edit, and simulate an open Modeloop control-system model from your coding agent.
Generate and edit 3D models, rig characters, retarget animations and retrieve their tasks.
Your personal world model for any agent.
Manage SysML2 projects; check, evaluate, verify, query, document and diagram models.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI agents and MCP clients to perform 3D asset creation and verification: exact b-rep CAD, GLB validation with embedded certificates, mesh inspection, and physics scenes, with most tools running without Blender.3648 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables coding agents to run bounded COMSOL simulations with contract validation, model inspection, provenance tracking, and deterministic verifier feedback.2MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables deterministic evaluation of MMG amplitude and spectral metrics, electromechanical delay, and peripheral muscular fatigue kinetics through native JSON-RPC tools for LLMs and autonomous agents.MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to build complete OpenSees structural models, run static, modal and pushover analyses, and read back displacements, reactions, forces and mode shapes over the Model Context Protocol. Includes an optional live GUI bridge for launching, syncing and screenshotting the desktop application.10-