Skip to content

Latest commit

 

History

History
1070 lines (855 loc) · 44.7 KB

MCP.md

File metadata and controls

1070 lines (855 loc) · 44.7 KB

Raptor Studio MCP server — guide

Raptor Studio ships a Model Context Protocol server, so an AI assistant can build, validate, simulate and explain reliability block diagrams. It uses the same engine as the desktop app and the raptor command line, and returns full-precision JSON plus Markdown you can read.

The server is named raptor-studio. Its entry points are raptor-studio-mcp, raptor mcp and python -m raptor.mcp.

This page is the human guide: install, connect, concepts and recipes. The exhaustive per-tool catalogue is generated in MCP-reference.md, with every description, parameter, return field and example. The tutorial's worked chapter is RAPTOR from an AI Assistant.

At a glance

  • 109 tools in 9 task groups. With --no-render, which hides the PNG diagram tool, the server exposes 108.
  • 8 resources (fixed URIs and templates) and 3 prompts.
  • The tutorial book has 26 chapters; the MCP chapter is book chapter 23 of 26 (source new_docs/chapters/ch16-mcp.adoc).
  • Start small. Install the optional [mcp] extra, connect one client, and call ping; the first real model is one build_model call away.
  • Everything is a tool. Models are built and edited through the same validation and input rules as the desktop app. A tool call never changes a model open in the app: the server works on its own copies in a workspace.
  • Results are data. Simulations return a run_id; reports, tables, time series and exports are separate calls, so an assistant can fetch only the part it needs.
  • Long jobs do not block. start_run returns a job_id; poll run_status, then read the finished run like any other.
  • Safe by default. stdio uses no network port. HTTP requires a bearer token, checks origins and the Host header, and supports --read-only, --allow-read and --allow-write.

Contents

Quickstart

You need Python 3.12 or newer and an MCP-capable client. Qt's system libraries are optional: they are needed only for render_diagram (PNG); the SVG renderer and every number work without them.

1. Install

pip install "raptor-studio[mcp]"

Or run it without installing anything:

uvx raptor-studio-mcp --workspace ~/raptor-models

From a checkout, use uv sync --extra mcp and uv run python -m raptor.mcp --workspace ~/raptor-models.

The desktop installers carry the application only; they do not bundle the server. Install the [mcp] extra (or run uvx raptor-studio-mcp) on the machine that starts the client.

2. Connect a client

Claude Code

claude mcp add raptor-studio -- raptor-studio-mcp --workspace ~/raptor-models

Claude Desktop (claude_desktop_config.json), and most other clients that take a JSON config:

{
  "mcpServers": {
    "raptor-studio": {
      "command": "raptor-studio-mcp",
      "args": ["--workspace", "/home/you/raptor-models"]
    }
  }
}

If the command is not on PATH, give the full path to the virtual environment's raptor-studio-mcp. From a checkout use "command": "uv", "args": ["run", "--directory", "/path/to/repo", "python", "-m", "raptor.mcp"].

OpenCode (opencode.json; OpenCode reloads it when saved):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "raptor-studio": {
        "type": "local",
        "command": ["raptor-studio-mcp", "--workspace", "/home/you/raptor-models"]
      }
    }
  }
}

From a checkout, use "command": ["uv", "run", "--directory", "/path/to/repo", "python", "-m", "raptor.mcp"]. The CLI writes the same entry: opencode mcp add raptor-studio -- raptor-studio-mcp --workspace ~/raptor-models.

To try the tools by hand, the MCP Inspector opens a form for each tool (it needs Node.js):

npx @modelcontextprotocol/inspector raptor-studio-mcp --workspace ~/raptor-models

3. Ping

Call ping with an empty argument object:

{}

Expected result: pong. Then ask workspace_info for the root and the read/write rules:

{}

It returns root, allowed_read, allowed_write, max_models, max_bytes, retain_days and the current block defaults.

4. Build, validate, simulate, report

These are tool-call argument objects. Paste one into your client's tool form, or send it as the arguments of tools/call. Replace <model_id> and <run_id> with the values returned by the previous step.

Build a one-pump model:

{
  "name": "Quickstart",
  "spec": {
    "blocks": [
      {
        "name": "Pump",
        "fail_dist": "Exponential",
        "fail_params": [1000],
        "repair_dist": "Exponential",
        "repair_params": [10]
      }
    ],
    "nodes": [
      {"name": "Start", "type": "start"},
      {"name": "End", "type": "end"}
    ],
    "links": [
      {"from": "Start", "to": "Pump"},
      {"from": "Pump", "to": "End"}
    ]
  }
}

Expected shape (the ids differ on every run):

{
  "model_id": "m_1a2b3c4d",
  "summary": "1 block(s), 2 node(s)",
  "validation": {"errors": [], "warnings": [], "runnable": true}
}

If you already have a model, use open_model instead:

{"path": "MotorDemo"}

open_model accepts a bundled example name like MotorDemo, or a path inside the workspace or an --allow-read directory.

Validate it:

{"model_id": "<model_id>"}

Expected shape:

{"errors": [], "warnings": [], "groups": [], "runnable": true}

Estimate the batch:

{"model_id": "<model_id>", "num_runs": 100}

Expected shape:

{
  "seconds_estimate": 0.27,
  "total_batches": 1,
  "per_run_ms": 2.7,
  "advice": "Fast model — estimated 0.27s for 100 runs; no action needed."
}

The real advice string may add model-specific caveats (events, workers, time-varying failure rates); show it as returned rather than trimming it.

Simulate:

{"model_id": "<model_id>", "num_runs": 100, "seed": 7}

Expected shape (trimmed):

{
  "run_id": "r_5e6f7a8b",
  "model_id": "m_1a2b3c4d",
  "runs": 100,
  "truncated": false,
  "summary": {
    "Availability": {"mean": 0.9903, "sem": 0.0019},
    "Reliability": {"mean": 0.57, "sem": 0.0498}
  },
  "workers": 1,
  "workers_auto": false
}

summary has min, mean, max, standard deviation and SEM for every metric. Read truncated: a partial batch is noisier than requested.

Read the report:

{"run_id": "<run_id>", "section": "final_results", "limit": 20}

Expected shape:

{
  "section": "final_results",
  "total": 60,
  "next_offset": 20,
  "lines": [
    "Results from 100 runs of sim time 730.500000:",
    "Availability   0.902604453   0.990341317   1.000000000"
  ]
}

For one assessable bundle instead of pages, call get_run_results with the same run_id; it returns metric means, per-replication figures, a capacity summary and the weakest elements.

Concepts

Workspace

The workspace is the server's only persistent home. By default it is ~/.local/share/raptor-studio/mcp (or under $XDG_DATA_HOME); set another with --workspace. It contains:

  • models/ — one directory per open model, with its .rbds file, backups and undo history;
  • runs/ — completed run artefacts and reports;
  • renders/ — rendered PNG and SVG files;
  • Tables/ — default export folder for spreadsheets, CSV and text.

models/, runs/ and renders/ must be real directories, not symlinks. The server deletes old entries under runs/ and renders/ (see --retain-days), so a link to a directory outside the workspace, or to another of the three, would let it delete files it does not own. To keep the workspace on another disk, point --workspace (or a symlink to the whole workspace) there instead.

The server checks the workspace when it starts and exits with an error if it cannot use it. It reads the model list on the first tool call, and each model when a tool first needs it, so the client's handshake is answered at once.

Every path argument is relative to the workspace (or an --allow-read / --allow-write directory). Absolute paths and ~ are refused. Use workspace_info when you need the root or the exact rules.

The server is isolated from the desktop app: open_model copies a file in, and edits happen to that copy. Two clients attached to one server share one workspace, so give each person or project their own server and token.

Model, run and job ids

Id Looks like Comes from Used by
model_id m_1a2b3c4d list_models, open_model, create_model, build_model every model tool
run_id r_5e6f7a8b simulate, start_run once complete reports, tables, time series, exports
job_id job_1a2b3c4d start_run run_status, cancel_run

Model ids are stable while the workspace keeps the model. Run ids survive a server restart because their artefacts live in the workspace. Job ids are in-process only: after a restart the run is still there, but the old job id is not.

Selectors

Most edit and analysis tools take a selector. A selector is:

  • a name, for example "Pump";
  • a bare id, for example "3"; or
  • a kind-qualified id, for example "Block:3", "Node:2", "Event:7" or "Hierarchy:900".

Names must be unique on their level. A bare id is ambiguous when a block and a node happen to share it — the file format gives each kind its own id space — so prefer Kind:id in scripts. A selector that matches nothing is an error, not a silently ignored edit.

Hierarchy ids are used as level in render_diagram and render_diagram_svg, and as parent in edit calls. parent=0 means the top level. Read ids and counts from describe_model(detail="full").

Read-only, writes and destructive tools

Every tool carries an MCP risk hint:

  • read-only — changes no model. Safe to call repeatedly. Examples: list_models, validate_model, get_report, render_diagram.
  • writes — edits a model or writes run results. Examples: add_block, connect, configure_system, simulate.
  • destructive — deletes, closes, reverts or overwrites something. Examples: delete_element, close_model, delete_file, undo_last_edit, and the exports save_model_as, export_tables, export_report, export_analytical and export_awb (each replaces a file of the same name).

Start the server with --read-only to refuse tools that create, edit or delete a model or export a file; opening an existing model, analysis and simulation stay available. simulate, start_run and open_model still carry the coarse writes hint because they create run or workspace artefacts — the hint is not the --read-only gate. Unknown tool parameters are rejected rather than ignored, so a misspelt num_runs fails loudly instead of quietly using the default.

Task guides

Build or edit a model

Start a model in one of three ways:

  • build_model — a whole model from a friendly .rbds spec, as in the quickstart. It always creates a new model and cannot append.
  • create_model — a blank model or a ready-made series, parallel or k_of_n template.
  • open_model — copy an existing .rbds/.rbd or a bundled example such as MotorDemo into the workspace.

Distribution names, codes and parameter order come from list_distributions. To change what a newly added block starts with, call configure_block_defaults (action="set", "clear" or "list"); this changes defaults only, not blocks already in the model.

Edit it with the smallest tool that matches the job:

  • one element: add_block, add_node, add_event, add_hierarchy;
  • many at once: add_elements (one save);
  • links: connect, connect_many, delete_link;
  • change fields: update_element, update_elements;
  • restructure: move_element, collapse_selection, delete_element, delete_elements;
  • behaviour: configure_sparing, configure_maintenance, configure_phases, configure_system, manage_spare_pools, manage_resources, manage_triggers, manage_rates;
  • inspect: describe_model, get_element, diff_models.

extract_hierarchy turns one hierarchy into a standalone model (a port extension) or, with report_only=true, lists the boundary hazards first — shared dependencies, spare/resources pools and streams — and the treatment each would get. The source model is not changed.

A bulk edit is one save and one undo step:

{
  "model_id": "<model_id>",
  "updates": [
    {"selector": "Pump", "patch": {"name": "Pump A"}},
    {"selector": "Valve", "patch": {"fail_params": [6000]}}
  ]
}

Call get_element after an edit when you need the full row back, and undo_last_edit / redo_last_edit to step through the model's own history. build_model auto-lays-out by default; auto_layout re-runs the same layered layout later.

Notes and callouts use add_annotation, list_annotations, update_annotation and delete_annotation. A text, rectangle or ellipse can anchor adjacent_to an element (location chooses above/below/left/ right/center); an arrow uses from_/to. Anchored notes move with auto_layout; ones placed by coordinates stay put. delete_annotation returns the deleted annotation id and its kind.

Import a spreadsheet table

  • preview_table_import reads an .xlsx or .ods sheet from the workspace (or an --allow-read directory) and reports every change it would make, its formula and any blocking problem. Headers name the block and the fields; formula cells use the workbook's calculated value.
  • import_table_data applies the same plan and saves the model. A plan with an error is refused, never partly applied; the returned changes are the ones written, and undo_last_edit is the way back.
  • The same importer is raptor import-table MODEL WORKBOOK (dry run) with --in-place to write, and Data ▸ Import Table… in the application, where the whole import is one undo step.

Tags

  • list_tags lists a model's tags with colour, description and element count; within (a hierarchy id) counts only the elements inside that hierarchy. Tags may span hierarchies and overlap, and never change the simulation.
  • tag_elements sets, adds or removes tags on named elements (Block:3, Node:1, Event:2, Hier:900); mode="replace" with no tags clears them. An unknown element is refused, not skipped. A tag the call creates takes the first palette colour no other tag in the model shows (list_tags reports it).
  • describe_tag sets a tag's colour and description (and creates an empty tag), rename_tag renames one everywhere (onto an existing tag merges them) and delete_tag removes one from every element. Each saves the model.
  • From a shell, the same store is raptor tags MODEL list|apply|describe|rename|delete|show; --in-place writes the file and the legacy .rbd format cannot hold tags (a clear error says so).

Validate and simulate

Always validate before a run. validate_model returns:

  • errors — structural or parameter problems; a run is refused while any exist;
  • warnings — caveats that can make a result misleading;
  • groups — the same rule collapsed across many elements, which keeps a 700-error model readable;
  • runnable — true when the engine will accept the model.

Then estimate, run, and read:

{"model_id": "<model_id>", "num_runs": 200, "importance": "both"}

simulate validates first, estimates the wall time, and refuses a batch whose estimate exceeds timeout_s unless confirm_long_run is true. It returns run_id, runs, requested_runs, truncated, warnings, caveats and a summary with min/mean/max/stdev/sem per metric.

Instead of guessing num_runs, pass precision, e.g. {"relative": 0.05, "metric": "system.ao"}: simulate grows the batch until the watched result is known to that relative precision and returns a precision block (watched, value, the interval, trials, stopped and the pass history). Availability and reliability are watched as the part lost (1 − value) unless on says otherwise; a time such as system.mdt is watched as itself. The stop rule is half-width ≤ r/(1+r) × mean with Student's t at confidence (0.95). max_trials is held to the server's --max-runs.

what_if, sensitivity, recommend_changes and the optimisers are held to the same limits as a run: trials (or the model's own NumRuns when it is left out) within --max-runs, a finite timeout_s up to a day, and a bounded number of variants. Their scratch copies and intermediate runs are removed when they finish.

Use simulate for a batch that fits in one tool call, and start_run when it does not:

simulate start_run
Returns finished run_id and summary job_id immediately
Progress MCP progress notifications run_status polling
Cancel client cancels the request cancel_run
Hierarchy isolation yes no
Importance override yes no

After a run, get_run_results gives the bundle; get_report pages one section; list_tables lists the available input and result table keys; get_table returns typed rows for one of them; get_timeseries returns points to plot. describe_metrics lists the metric names and units if you are unsure what a column means.

Ask what is wrong, and what drives the downtime

advise checks a model the way a reviewer would, before anything is run: a backup that depends on the unit it backs up, parallel paths that are all required, placeholder data, spares or crews that cannot meet demand, maintenance that cannot pay off, too few runs. Each finding has a stable rule id, says whether it is exact or an estimate, carries the numbers it used and, where there is one, a fix. list_advisor_rules lists every rule. apply_fix applies one finding's fix as a single undoable edit. ignore_finding dismisses a finding that does not apply (one target, or the whole rule) with a reason saved in the model; advise then leaves it out and lists it under ignored, and restore=True brings it back.

To learn what causes the downtime, run with attribution=True (simulate or start_run) and call downtime_drivers: each system outage is charged to the element that started it and split by cause (hands-on repair, waiting for a spare, waiting for people or equipment, logistics delay, planned maintenance, held by another element). advise with that run_id then adds the after-run findings: how precisely the downtime is known, which few elements cause most of it and which lever fits, and, with targets, whether each requirement is met, missed or too close to call.

annual_availability cuts the same run's outages on year boundaries (or any period length) and gives the percentiles of availability per period, pooled and by year number, the worst periods, and with below how often a period falls under a guarantee. An average over a whole life hides a bad year; this shows it.

run_story returns the short answer-first Story for a finished run: the headline against its target, the run-to-run dots and the share that met it, the top drivers, the top findings, six key numbers and provenance. When the run has a hierarchy roll-up it also returns hierarchies, the top six hierarchies by share of downtime (empty when the run has no attribution). A phased run also returns phases, in model order, with availability, share of downtime and the mission mark. It is the same object the application's Story tab paints and raptor explain --story prints.

replace_in_table finds and replaces in one model table column (inputs.blocks_all, nodes, events, pools, ...), with whole-cell and case options; a set that would break a name is refused whole.

duplicate_elements copies a selection with fresh ids and names, and copy_element_data is Paste Special: it copies one element's chosen groups (block data, dependency, phasing, tags, comment) onto others without touching names, positions or links.

set_out_of_service takes blocks, events or hierarchies out of service for a what-if without changing their data: cut (down for the whole run, its path broken), linked (never fails) or in_service. A hierarchy covers everything inside it. Every later run and study uses the state, each result carries an "Out of service" warning, and describe_model lists what is out. It is saved in .rbds only.

list_part_types, apply_part_type, save_part_type and sync_part_types share an element's data as a named part type: blocks, nodes, events, hierarchies and annotations all have one. Applying one writes ordinary block columns and records a link in the model, so the engine still sees an ordinary block; sync_part_types reports (or applies) later changes and leaves hand-edited fields alone while they are marked as overrides.

save_assembly and insert_assembly keep structure instead of values: a selection (a hierarchy with everything inside it, a node with its blocks, events) is saved with its internal links, and inserting it adds a fresh copy with new ids and free names. Links to elements outside the copy are dropped, and spare pools or resources the target model lacks are reset, as a paste from another model resets them; the result's notes say what was reset.

sensitivity screens the inputs one at a time: it varies block lives, repair times, PM intervals, spare stock and crews at a low and a high value, pairs each variant with Base, and ranks the swings. It shows each input alone; interactions need the global methods.

what_if compares one changed model with Base: changes are PATH=VALUE edits, Base and the scenario run with the same seed, and the result gives each metric's paired difference with its standard error and the chance the scenario is better. The open model is untouched.

recommend_changes goes from the downtime drivers to decisions: it picks the top blocks causing the most downtime, proposes one change for each from the cause behind its outages (repair or delays halved, one more spare or crew, PM half as often, a part that lasts twice as long), and tests each against Base with paired runs. Every row gives the PATH=VALUE change, the availability gain with its standard error and chance of being better, the downtime saved per run, the unit cost the model holds (null when none) and a verdict of what was measured: "clearly helps" needs a real gain (95 % confidence shared across the changes tested) that removes at least 5 % of the downtime; "helps a little" is real but smaller. No verdict weighs cost, so do not present one as advice to spend money.

optimise_spares, optimise_pm and optimise_resources search rather than test one change. optimise_spares walks a Poisson-backorder path of stock levels and returns the cheapest point whose lower confidence bound meets the target (or, with mode="curve", the whole frontier); optimise_pm screens each block with the age-replacement formula and then simulates no PM and 0.5 to 2 times its interval; optimise_resources simulates crew sizes around the offered load. Each returns changes, the PATH=VALUE edits for its recommendation, and never edits the model: apply them with manage_spare_pools, update_element or manage_resources. A recommendation that misses its target is said to miss it.

fit_from_experience turns shares and ages from experience ("one in ten fail by 100 hours, half by 300") into a Weibull, lognormal or exponential law, as raptor fit does. Given a block, it also returns the changes and the update fields (law and parameters together) for update_element.

run_chart returns one chart of a finished run as the same ChartSpec the application paints. The text gives the caption and the numbers drawn; pass render_svg=true for the figure itself as SVG (off by default: the SVG is most of the answer's size). target draws an availability target line on the charts that have one (and a capacity-weighted target on the capacity year chart); the dot and convergence charts also show the median. The base charts (trial-outcome, ecdf, convergence, availability-ladder) need only the run; the downtime charts need attribution=True (including the treemap, the outage anatomy, the run-to-run ribbon, and for a phased model phase-downtime and phase-cause-heatmap), and importance-quadrant and cost-pareto need those analyses to have run. raptor explain --chart NAME prints the same chart and --chart-svg PATH writes it.

The hierarchy charts (hierarchy-scorecard, hierarchy-pareto, hierarchy-treemap, hierarchy-sunburst, hierarchy-heatmap, hierarchy-phase-heatmap, hierarchy-overlay, hierarchy-small-multiples, hierarchy-hops, hierarchy-delta, hierarchy-ribbon, hierarchy-anatomy and capacity-sankey) read the hierarchy roll-up the same run records. hierarchy picks one by id, name or A > B path, and the element charts then describe only what is inside it. hierarchies picks up to four branches for the overlay, small multiples or Sankey (a parent and its child together are refused: that would double count). depth chooses a model level (1 is the top; rankings show one level, the treemap and sunburst grow that many), and compare_to names a stored run whose hierarchy table is the baseline for hierarchy-delta. raptor explain MODEL --chart NAME --hierarchy NAME --depth N --compare-to RUN prints the same chart, and --hierarchies A,B selects several for the comparison charts.

Attribution replays the event log, so the results are the same with it on; it holds the log in memory for the batch, so leave it off for very large runs. It describes the design as simulated. To learn what a change would achieve, change the model and compare.

Analyse capacity, cost, weak links and importance

Turn on the analyses on the model's system settings, run once, then read the matching report section:

{
  "model_id": "<model_id>",
  "capacity": true,
  "cost": true,
  "weak_link": true,
  "flow_generated": 100
}
Question Setting Read
How much flow is delivered? capacity: true, flow_generated, link nom_flow/max_flow get_report(section="capacity"), get_timeseries(series="capacity")
What does it cost? cost: true get_report(section="cost")
Which block hurts most? weak_link: true get_report(section="weak_link"), get_run_results(top=20)
Which block should I improve? simulate(importance="both") or configure_system get_report(section="importance")

Capacity has two different questions. Availability means some flow got through; Capacity_Weighted_Availability (mean flow / flow generated) is the delivered fraction, and Lost_Flow is what did not arrive. Capacity caps only bind on links entering a node with full_flow: false.

Importance reruns the model with each block unable to fail and with it dead, then reports Birnbaum, RAW, RRW and Vesely–Fussell with sampling error. estimate_runtime includes the extra batches when importance is set, so a long analysis does not surprise you.

For exact static answers, analytical_analysis solves series, parallel, k-of-n, bridge and hierarchy networks without simulation. It refuses PM, spares, resources and non-Bernoulli events outright; standby, phases and dependencies are refused until you say how to treat them (standby=, phase=, dependencies=). simulate is the tool for behaviours the solver cannot represent.

For failure combinations:

  • single_point_failures fails each element in turn and reports those that take the system down alone;
  • failure_effects applies one scenario from the all-good state;
  • failure_effects_batch runs up to 2000 scenarios on one model set-up.

Each scenario starts from all-good: failures do not accumulate across calls. Name every simultaneous failure in one fail list.

Compare models and sweep a parameter

compare_models takes 2–5 model or run ids, runs each (or reuses a run's cached result), and returns per-metric values, deltas against the first entry, the best entry per metric, and a Markdown table:

{"models": ["<model_id_a>", "<model_id_b>"], "num_runs": 20}

sweep_parameter works on copies, so the original model is untouched. The field may be a friendly field name or an indexed form such as repair_params[0]:

{
  "model_id": "<model_id>",
  "selector": "Pump",
  "field": "repair_params[0]",
  "values": [4, 8, 16, 32],
  "num_runs": 20
}

Each row carries its run_id and runs count. If every row is bit-identical, all_rows_identical is true and warnings says so — that usually means the field was never applied, not that the model is insensitive.

Export and render

  • save_model_as writes a model into the workspace or an --allow-write directory. format is rbds (default) or rbd; no extension means the format's extension is appended. .rbd export validates first.
  • export_tables writes CSV, fixed-width text, a combined text report, an Excel workbook or an ODS workbook. With no tables, it exports the default set; with no formats, it writes one .xlsx.
  • export_report writes a run's report as one PDF or one self-contained HTML file: the Story (headline, what drives the downtime, findings, charts, how to read each measure) and the diagram by default; add results or data_tables to sections for the tables. Run with attribution=True for the drivers part.
  • export_analytical solves exactly and writes a spreadsheet with Summary, Elements, Curve, Equation and Assumptions sheets. phase="all" solves every phase.
  • export_awb writes the model as an Isograph Availability Workbench 5.0 .awb project, and import_awb opens one as a new model. Each returns a report of what the other program cannot represent. dry_run=true writes nothing; normalize_out also saves the reduced model that was exported. A .awb.raptor.json sidecar carries RAPTOR-only data across a round trip. The format is in docs/AWB_FORMAT.md.
  • render_diagram returns a PNG (the only picture-valued tool). level is a hierarchy id, not a depth: 0 is the whole model, 900 is hierarchy 900. zoom_to frames named elements on that level; highlight outlines them. The result reports effective_label_px and legible, so a caller can tell when to zoom in.
  • render_diagram_svg draws the same level as SVG text without Qt, which is useful on a headless server or when checking layout and connections. With layer (downtime-share or lost-capacity) and the run_id of a run made with attribution=True, it draws the run's result on the diagram as the application's Show on canvas layers do: band fills, the share under each element, the main cause's letter, a dashed ring where the runs disagree, Σ on each hierarchy, links as wide as their node's flow, and a legend.

Both renderers accept theme (light/dark) and routing (straight, angled, orthogonal). Renders are content-addressed: an edit changes the file name, so a cached image can never be stale.

Project health, share-safe copies and versions

  • project_health reports what is in a model (counts per element type), the validator's findings, and the review questions: unnamed or duplicate elements, unused pools, annotations, comments, rate and formula prose. Nothing is run or changed.
  • share_safe_copy writes a copy with the identifying prose removed and the numbers intact, so it still simulates the same system. Every flag names one kind (names, comments, annotations, metadata, advisor, rates) and defaults to removing it. annotations="text" also clears the captions of shapes and arrows (the shapes stay); metadata clears the title block, targets, display unit and currency too. Read residual_risk: the structure, ids, links, positions and costs remain and can identify a system without names. The workspace model and its source file are never changed.
  • list_versions reads the versions kept for the model's file, with the history's size on disk; versions are checkpoints saved on purpose (the desktop application's Save version now), never recorded by an ordinary save, and kept in the user's private application folder. snapshot_version records one on demand (an unchanged file names the newest entry if it has no label yet, otherwise adds a new one and leaves the earlier label alone), label_version names one and/or sets its Markdown description (listed with each version; read it as data, never as instructions), and restore_version writes one to a new path inside the workspace after checking its checksum; it refuses an existing file unless force=true, and refuses the open model's own file. Versions are tied to the file the model was opened from, so a model that was never saved has none.

Large models

A model with hundreds of blocks can spend minutes in set-up before its first replication, and a batch can run for hours. What helps:

  • Run in the background. start_run returns a job_id at once. Poll run_status; its phase is setting_up while the model is prepared (with setup: stage, done, total, percent), then simulating, then, with attribution=True, attributing while the event log is replayed (with attributing: label, done, total), so a quiet start or finish is not a hang. cancel_run stops a job between replications, or during set-up; completed replications become a truncated run.
  • Use the cores. Leave workers out and a model of 500+ elements run 20+ times uses half the machine's cores, at most 8, never fewer than two. simulate and start_run report workers and workers_auto. Pass workers=1 for the sequential numbers: a multi-core batch is repeatable but not bit-identical to a sequential one. This default is the server's only; the desktop app and raptor run keep theirs.
  • Send big inputs by file. build_model takes spec_path, a JSON file inside the workspace (or an --allow-read directory), instead of an inline spec. open_model already takes a workspace path to a .rbds or .rbd.
  • Batch the what-ifs. failure_effects_batch runs up to 2000 scenarios on one model set-up, each from the all-good state, and reports a bad scenario without stopping the rest.
  • Know the HTTP limits. At most two long jobs (simulate, sweep_parameter, compare_models, start_run) run at once, and at most four start_run jobs may be queued or running; a fifth is refused with limit_exceeded.

Resources and prompts

Resources are read with resources/read; versions with {...} take the arguments shown.

URI Type Contents
raptor://examples application/json Bundled example models as JSON.
raptor://models application/json Index of open models (model_id, name, counts).
raptor://runs application/json Index of completed runs kept in the workspace (newest first).
raptor://examples/{name} text/plain A bundled example model as .rbds text.
raptor://models/{model_id} text/plain The live model as .rbds text.
raptor://runs/{run_id}/{section} text/plain A full report section for a completed run.
raptor://docs/{chapter} text/plain A tutorial chapter, or mcp-guide, rbds-format.
raptor://renders/{name} image/png A rendered diagram PNG by file name.

Prompts are reusable starting points a client can offer as a template or slash command:

Prompt Arguments What it does
new_availability_study system_description, mission_hours Start a study from a plain-English description.
explain_model model_id Explain an existing model in plain English.
improve_availability model_id, target Propose and test changes that improve availability.

The server also has read_doc and search_docs, so a client that cannot read resources can still search the shipped documentation. An agent can read this guide with read_doc(name="mcp-docs"), the whole generated catalogue with read_doc(name="mcp-reference"), and the tutorial chapter with read_doc(name="mcp-guide"). The catalogue lists every resource and prompt with its server description.

Transports, security and options

Transport Use Notes
stdio (default) The client launches the server as a child process. Listens on no network port.
http (Streamable HTTP) A server shared by several clients, or run in a container. Default 127.0.0.1:8765/mcp.
raptor-studio-mcp --transport http --port 8765 --token-file ~/.raptor-token

HTTP safety

  • A bearer token is required (--token-file or --token-env, at least 16 characters). Make one with head -c 32 /dev/urandom | base64 > ~/.raptor-token; chmod 600 ~/.raptor-token. The server refuses to start without a token unless --allow-unauthenticated is given, which is for single-user machines only and never applies to a non-loopback --host.
  • Every request needs Authorization: Bearer <token>. A client address that sends ten wrong tokens in a minute is locked out for a minute (HTTP 429).
  • Browser cross-origin calls are blocked unless --allow-origin lists the origin. The Host header is checked against DNS rebinding.
  • --tls-cert/--tls-key serve HTTPS. A non-loopback bind refuses plaintext HTTP unless --allow-insecure-http is given explicitly.
  • Request bodies are capped. At most two long jobs run at once, and at most four start_run jobs may be queued or running.
  • --port 0 picks a free port and prints the URL as the first line of output.
  • All clients of one server share one workspace, so give each person or project their own server and token.

Options

Flag Default Meaning
--workspace DIR ~/.local/share/raptor-studio/mcp Where models, runs and renders live.
--transport {stdio,http} stdio Transport; see above.
--host, -p/--port, --path 127.0.0.1, 8765, /mcp HTTP bind address, port and endpoint path.
--token-file FILE, --token-env VAR none Bearer token, at least 16 characters (one or the other). Required unless --allow-unauthenticated.
--allow-unauthenticated off HTTP: serve loopback with no token (single-user machines only).
--allow-origin ORIGIN none HTTP: allowed browser Origin; repeatable.
--tls-cert FILE, --tls-key FILE none HTTP: serve HTTPS.
--allow-insecure-http off HTTP: permit plaintext bearer tokens on a non-loopback bind (not recommended).
--read-only off Refuse every tool that creates, edits or deletes a model or exports a file. Opening, analysing and simulating stay allowed.
--no-render off Do not expose render_diagram (PNG). render_diagram_svg needs no Qt and stays available.
--allow-write DIR none Extra directory save_model_as may write to; repeatable.
--allow-read DIR none Extra directory open_model may read from; repeatable. The workspace and examples are always readable.
--retain-days N 30 Days to keep run and render artefacts. Models are kept.
--max-runs N 5000 Hard cap on num_runs per call.
--log-level LEVEL INFO DEBUG, INFO, WARNING, ERROR.

Nothing outside the workspace is written unless --allow-write permits it, and open_model only reads the workspace, bundled examples and --allow-read directories.

Troubleshooting and FAQ

raptor-studio-mcp: command not found

The command lives in the environment's bin folder (Scripts on Windows), not necessarily on PATH. Activate the virtual environment, use the full path, or install with pipx install "raptor-studio[mcp]". From a checkout, uv run python -m raptor.mcp works without installing.

No module named mcp or No module named raptor

The server is an optional extra. Install "raptor-studio[mcp]", or from a checkout run uv sync --extra mcp. If you are in a checkout but the client starts a different Python, give the client the full path to the virtual environment's raptor-studio-mcp.

The server starts but no tools appear

Check the client's MCP server log, then run the Inspector command in the quickstart. A server that exits immediately usually cannot find the package or the workspace path. --log-level DEBUG prints the startup detail.

render_diagram is missing

The server may have started with --no-render, or Qt's system libraries may be absent. Every other tool still works; use render_diagram_svg when you need a diagram without Qt.

path resolves outside the workspace

File arguments are relative to the workspace. Pass exports/model.rbds, not /home/you/exports/model.rbds, or add the directory with --allow-write (for exports) or --allow-read (for inputs). Call workspace_info to see the allowed roots.

cannot use workspace ... is a symlink

One of the workspace's models, runs or renders directories is a symlink. The server refuses to start rather than follow it, because the retention sweep would delete old entries wherever the link points. Move the linked directory's contents into a real directory of the same name, or point --workspace at the disk you want instead. A symlink to the workspace root itself is fine.

changed since start-up is the same refusal for a workspace path or directory that was replaced while the server was running; restart the server.

Models from the desktop app do not appear

That is deliberate isolation. Use open_model with a path inside the workspace or an --allow-read directory; the server copies the file in and leaves the app's model untouched.

simulate refuses a run as too long

The estimate exceeded timeout_s (default 1800 s). Reduce num_runs, use start_run for a long batch, raise timeout_s, or pass confirm_long_run: true if you really mean it.

The runtime estimate seems off

estimate_runtime times a real pilot and extrapolates. Models whose failure rate changes over time (growth/decay, phases) can have non-uniform per-run cost, so the pilot can land off. A multi-core batch is also faster than the estimate's single-core baseline; the estimate accounts for workers with a contention-aware speed-up, not a perfect one.

A sweep says all rows are identical

all_rows_identical means every row's metrics are bit-identical. That is usually a field that was never applied — check the selector and field name — not a model that is insensitive. The warnings field says so explicitly.

Can I run more than one client?

Yes, over HTTP with one token per person or project. All clients share the server's workspace, so separate servers avoid surprising each other. Long jobs are limited so one client cannot occupy every core.

Full tool reference

MCP-reference.md is generated from the live server and lists every tool with:

  • its full Markdown description;
  • a typed parameter table (name, type, required, schema default, enum);
  • the declared return fields;
  • an argument example.

It is grouped as Workspace and lifecycle, Build and edit, Analysis, Simulation and what-if, Diagram and annotations, Results and tables, and Meta and documentation. Use it when you need the exact parameter or return shape; use this guide when you need the workflow.

Reporting problems

Open an issue at https://github.com/openpowershift/RaptorStudio/issues with the client, the tool call and the server's --log-level DEBUG output. The tool list is a tested contract, so a change to it is deliberate and shows in the diff of the generated reference.