itasca-mcp-bridge
Runtime bridge that runs inside an ITASCA product process (PFC, FLAC, ...) and exposes the product's Python SDK as an HTTP API, enabling execution tools for MCP servers such as itasca-mcp.
The bridge is product-neutral: it drives the host through the shared ITASCA command language / Python SDK rather than any product-specific API.
Features
- Async tasks with progress polling. Submit a long simulation script
(
execute_taskmessage) and poll its status and paginated output while it runs (check_task_status). - Live REPL during a run. Send
execute_codeagainst the running task's namespace at any time to inspect state or tune parameters mid-cycle — no need to bake probes into the script up front. - Graceful interrupt. Stop a long cycling task on request
(
interrupt_task) without killing the product. - Unified output capture. Python
printand product console output (itasca.command()tables, list dumps, summaries) are interleaved in execution order in the task log.
Architecture
ITASCA's Python SDK is main-thread-only, so the bridge keeps the simulation on the main thread and serves remote requests around it with three parts:
flowchart TD
C[MCP client] -->|HTTP + SSE| S[HTTP server<br/>thread-per-request]
S -->|submit → Future| Q[MainThreadExecutor<br/>queue]
Q -->|Qt timer / blocking poll| M[product main thread<br/>itasca SDK + solver]
M -.->|callback at cycle| CB[interrupt check<br/>+ snippet executor]
CB -.-> M
- HTTP server (thread-per-request). A stdlib
http.server(no asyncio, no third-party dependency) serves each request on its own thread, hands the work to the main thread, and awaits aFuture. It never touches the SDK directly, so lightweight calls (status, interrupt) stay responsive even while a long task runs. Request/response is plainPOST /<command>; the one server→client doorbell (task_status_changed) is pushed over a single long-livedGET /eventsServer-Sent Events stream. - Main-thread queue.
MainThreadExecutorholds a thread-safe queue that the main thread drains — via a Qt timer in GUI mode, or a blocking poll in console mode. Submitted task scripts (execute_task) run here. - Cycle-gap callbacks. A cycling task holds the main thread, so two
itasca.set_callbackhooks keep it reachable: an interrupt check that stops the run (interrupt_task), and a snippet executor that runsexecute_codeREPL calls in the gaps between cycles — sharing the task's__main__namespace for live inspection and tuning.
HTTP protocol
The bridge is the source of truth for the wire contract — MCP servers such
as itasca-mcp are clients of it. Each request is a POST /<command> whose
body is a JSON object carrying a request_id; the JSON response echoes the
request_id. The server→client doorbell rides a single long-lived
GET /events SSE stream (payload-free task_status_changed events that
prompt the client to re-poll), and GET /health is a liveness probe. The
commands are product-neutral:
POST /<command> |
Purpose | Key body fields |
|---|---|---|
execute_task |
Submit a file-backed script as a tracked async task | task_id, script_path, description |
check_task_status |
Poll a task's status and paginated log | task_id, skip_newest, limit, filter_text |
list_tasks |
List known tasks | offset, limit |
interrupt_task |
Request a graceful interrupt of a running task | task_id |
execute_code |
Run a snippet in the running task's __main__ (sync REPL) |
code, timeout_ms |
Quick Start
Run inside the product's Python (GUI IPython console or console CLI):
Install from PyPI
In the product's IPython console:
from pip._internal.cli.main import main as pip_main
pip_main(["install", "--user", "itasca-mcp-bridge"])
import itasca_mcp_bridge
itasca_mcp_bridge.start()
The bridge is stdlib-only (http.server + Server-Sent Events), so there is
no third-party dependency to install or version-match — it lands cleanly in
any ITASCA embedded Python (3.6+) with no pins.
On every start() the bridge checks PyPI for a newer release (5-second
timeout; the Tsinghua mirror is tried when pypi.org is unreachable) and
self-upgrades before starting. The check is best-effort -- offline
machines and failed installs fall back to the installed version. To pin
the installed version, call start(auto_upgrade=False) or set the
environment variable ITASCA_MCP_BRIDGE_AUTO_UPGRADE=0. Corporate
mirrors can be configured with ITASCA_MCP_PIP_INDEX_URL.
After a self-upgrade the banner is followed by a short "What's new" list
of the release highlights you just received; call
itasca_mcp_bridge.whats_new() to reprint it anytime.
Run from a source checkout
%run C:/path/to/itasca-mcp-bridge/start_bridge.py
Use forward slashes in the path. Do not wrap it in quotes.
Code changes take effect on the next %run, so this is the preferred
workflow during development.
The bridge auto-detects the runtime: a Qt timer in GUI mode, a blocking loop in console mode.
Expected output:
============================================================
Itasca MCP Bridge Server
============================================================
Version: 0.4.2
URL: http://localhost:9001
Log: /your-working-dir/.itasca-mcp-bridge/bridge.log
============================================================
Requirements
- An ITASCA product with an embedded Python interpreter.
- Verified: PFC 6.0 / 7.0 / 9.0.
- FLAC3D: the bridge's core SDK/command mechanisms are verified compatible; full end-to-end validation is in progress.
- Python >= 3.6 (PFC 6/7 use Python 3.6; PFC 9 uses Python 3.10).
- No third-party runtime dependency: the transport is stdlib-only
(
http.server+ Server-Sent Events).
Troubleshooting
| Symptom | Fix |
|---|---|
| Server won't start | Re-run the install/start steps in the product's IPython console; check .itasca-mcp-bridge/bridge.log |
| Port in use | itasca_mcp_bridge.start(port=9002), then point your MCP client's bridge URL at http://localhost:9002 |
| Connection failed | Confirm the bridge is running and the port is reachable; see .itasca-mcp-bridge/bridge.log |
| No task execution / MCP cannot connect | If execution tools return ok=false, error.code=bridge_unavailable, error.details.reason=cannot connect to bridge service, confirm itasca_mcp_bridge.start() is running and your MCP client's bridge URL matches |
Relationship to MCP servers
This package is the in-process runtime only. Pair it with an MCP server that speaks its HTTP protocol — for example itasca-mcp — for full client setup.
License: MIT.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file itasca_mcp_bridge-0.4.3.tar.gz.
File metadata
- Download URL: itasca_mcp_bridge-0.4.3.tar.gz
- Upload date:
- Size: 88.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
906c4a50fe74adf1c065368e93f2e76c1117aa19ed2512df301f2e3a82a04cef
|
|
| MD5 |
5c9b219cdd4f15bc6f28f146a2633d01
|
|
| BLAKE2b-256 |
c8424966a81de360c5add03ddf4da2899864858164c881b4e54a66baecffba76
|
Provenance
The following attestation bundles were made for itasca_mcp_bridge-0.4.3.tar.gz:
Publisher:
publish.yml on yusong652/itasca-mcp-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
itasca_mcp_bridge-0.4.3.tar.gz -
Subject digest:
906c4a50fe74adf1c065368e93f2e76c1117aa19ed2512df301f2e3a82a04cef - Sigstore transparency entry: 2128342782
- Sigstore integration time:
-
Permalink:
yusong652/itasca-mcp-bridge@c03cf60851d5242e8c47d7db038eccf5962477b7 -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/yusong652
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c03cf60851d5242e8c47d7db038eccf5962477b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file itasca_mcp_bridge-0.4.3-py3-none-any.whl.
File metadata
- Download URL: itasca_mcp_bridge-0.4.3-py3-none-any.whl
- Upload date:
- Size: 73.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5de6ad83d16c9b78a5a0a8f7d6eaa573298c1a9cbb9e7b00979f8d90d3c32ae
|
|
| MD5 |
c9fc030a31cf638cb79ca299dca0cdd4
|
|
| BLAKE2b-256 |
e5f64741f7fd458fe3a3f72a58128686e07cc0cfd915a424468f6eb9e426a7d4
|
Provenance
The following attestation bundles were made for itasca_mcp_bridge-0.4.3-py3-none-any.whl:
Publisher:
publish.yml on yusong652/itasca-mcp-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
itasca_mcp_bridge-0.4.3-py3-none-any.whl -
Subject digest:
b5de6ad83d16c9b78a5a0a8f7d6eaa573298c1a9cbb9e7b00979f8d90d3c32ae - Sigstore transparency entry: 2128342809
- Sigstore integration time:
-
Permalink:
yusong652/itasca-mcp-bridge@c03cf60851d5242e8c47d7db038eccf5962477b7 -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/yusong652
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c03cf60851d5242e8c47d7db038eccf5962477b7 -
Trigger Event:
push
-
Statement type: