GEMPACK MCP

GEMPACK MCP

An MCP server that exposes the local GEMPACK CGE toolchain (TABLO, GEMSIM, HAR utilities) as tools Claude can call: compile models, run simulations, read solution and HAR data files, and export to CSV/Excel.

Category
访问服务器

README

GEMPACK MCP

An MCP server that exposes the local GEMPACK CGE toolchain (TABLO, GEMSIM, HAR utilities) as tools Claude can call: compile models, run simulations, read solution and HAR data files, and export to CSV/Excel.

中文速览:这是一个把本机 GEMPACK(TABLO/GEMSIM/HAR 工具链)封装成 MCP 工具的服务, 让 Claude 能直接帮你编译模型、跑模拟、读 SL4/HAR 结果、导出 CSV/Excel。 已注册到 Claude Code(user 作用域),工作区指向存放模型的文件夹(如 ./workspace),开箱即用。


Setup

Item Value
GEMPACK binaries (GP_DIR) C:\Program Files\GP (with dll64\ runtime)
GEMPACK version 12.1.004
Licence a GEMSIM-only GEMPACK licence
Workspace (sandbox root) a folder or drive that holds your GEMPACK models (.tab/.cmf/.har/.sl4)
Models your own model folders under the workspace
Python .venv\Scripts\python.exe (FastMCP 3.3)
Transport stdio (registered with Claude Code); HTTP optional

Licence limitation that shaped the design: this licence does not permit TABLO to generate Fortran code. Only the interpretive GEMSIM engine is available — so compile always targets GEMSIM aux files and run_simulation uses the gemsim (or sagem) solver. TABLO-generated model EXEs are not built.


Tools

All file arguments are workspace-relative (or absolute inside the workspace) and confined to the sandbox root.

Tool What it does
gempack_list_workspace(subdir=".") List .tab/.cmf/.har/.sl4 files to discover what's available.
gempack_compile_tab(tab_file, sti_file=None, aux_name=None) Compile .tab → GEMSIM .gss/.gst. Pass your own .sti for models needing condensation; otherwise a no-condensation GEMSIM stored-input is generated.
gempack_run_simulation(cmf_file, solver="gemsim") Run a simulation from a .cmf.sl4 solution, .upd data, summary .har. Aux files must already exist.
gempack_read_solution(sl4_file) Convert .sl4<stem>_sol.har and list every solved variable (name → header code → size).
gempack_list_har_headers(har_file) List headers in a HAR file (4-char code, dimensions, type) + a full .see dump.
gempack_read_har_header(har_file, header) Extract one header to CSV (long format: index columns + Value).
gempack_convert(src_file, dst_file, headers=None) Export HAR → CSV or HAR → XLS/XLSX (legacy .xls, one header per sheet).

Typical flow

  1. gempack_list_workspace("examples/minimal") — see the files.
  2. gempack_compile_tab("examples/minimal/minimal.tab") — build aux files.
  3. gempack_run_simulation("examples/minimal/MINIMAL.CMF") — solve.
  4. gempack_read_solution(<the .sl4 from step 3>) — list result variables.
  5. gempack_read_har_header(<solution_har>, <header code>) — read values.

Note: some tools leave artifacts next to your model files by design — seehar writes <stem>-har.see, read_solution writes <stem>_sol.har, read_har_header writes _<stem>_<header>.csv. These are returned as paths so you can open them; delete them if you don't want them.


Install / register

To install and register:

# 1. dependencies
.venv\Scripts\python.exe -m pip install -r requirements.txt

# 2. register with Claude Code (user scope, stdio)
claude mcp add -s user gempack -e GEMPACK_WORKSPACE=./workspace -- `
  "<path-to-repo>\.venv\Scripts\python.exe" `
  "<path-to-repo>\server.py"

# 3. verify
claude mcp list        # -> gempack: ... ✓ Connected

To remove: claude mcp remove gempack -s user.

Use a forward slash (e.g. D:/models) for the workspace value — a trailing backslash gets escaped against the quote on Windows and breaks claude mcp add.

Changing the sandbox root

The server reads file paths only inside its allowed roots. Set:

  • GEMPACK_WORKSPACE — primary root (relative paths resolve here).
  • GEMPACK_EXTRA_ROOTS — extra read/write roots, ;-separated (e.g. add F:\).

Anything outside these roots is refused (verified: C:\Windows\win.ini is blocked).


Configuration (env vars)

See .env.example. Key defaults:

Var Default Meaning
GEMPACK_DIR C:\Program Files\GP GEMPACK install.
GEMPACK_WORKSPACE <project>\workspace Sandbox root (relative paths resolve here).
GEMPACK_EXTRA_ROOTS (empty) Extra allowed roots, ;-separated.
GEMPACK_SIM_TIMEOUT 1800 Simulation timeout (s).
GEMPACK_COMPILE_TIMEOUT 600 Compile timeout (s).
GEMPACK_TOOL_TIMEOUT 180 HAR/convert timeout (s).

A .env file in the project root is loaded automatically; the MCP client's env block and real environment variables override it.


HTTP transport (optional — for Claude on another machine)

Not needed for local use. If you want a remote Claude to reach this server:

$env:GEMPACK_TOKEN = "<a-long-random-secret>"   # required
.\run-http.bat          # serves http://127.0.0.1:8765/mcp

Clients must send Authorization: Bearer <token>. To accept connections from other machines, set GEMPACK_HTTP_HOST=0.0.0.0 and open the port in the firewall (see run-http.bat for the netsh command).


Tests

tests\test_e2e.py drives every operation against a pristine copy of the minimal example (in tests\minimal\) using the real GEMPACK engine:

$env:PYTHONPATH = (Get-Location)
.venv\Scripts\python.exe tests\test_e2e.py
# -> === required: 9/9 passed; info: 2/2 ok ===

Layout

gempack-mcp\
  server.py            FastMCP server: 7 tools + stdio/HTTP launch
  gempack_mcp\
    config.py          env-var config (paths, roots, timeouts, token)
    sandbox.py         path confinement to the allowed roots
    runner.py          non-interactive subprocess runner (EOF stdin, file snapshot)
    gp.py              the GEMPACK operations (verified CLI invocations)
  tests\test_e2e.py    end-to-end test against the minimal example
  run-stdio.bat        launch stdio manually
  run-http.bat         launch HTTP (needs GEMPACK_TOKEN)
  .env.example         documented configuration
  requirements.txt

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选