
Gretl MCP
io.github.OndrejLapes由 GitHub 帳號 OndrejLapes 發布v0.2.1更新於 Oct 24, 2026
Run Hansl/Gretl econometrics workflows via MCP with GUI launch and artifacts.
概覽
本機 MCP 伺服器,讓助理執行 Hansl/Gretl 計量經濟學腳本、指令與 .inp 檔案,並回傳 Gretl CLI 的輸出與產物。
- 可以做什麼
- 檢查 Gretl CLI 與 GUI 是否可用,並啟動可見的 Gretl 桌面程式,可選擇在其中開啟資料集或腳本檔案。查詢已安裝的 Gretl 指令、函式與套件說明,並取得某個指令的說明。執行產生的 Hansl 腳本、原始 Gretl 指令列與既有的本機 .inp 檔案,回傳輸出及產生的產物路徑。執行原生 pkg 操作(例如 install、query、run-sample、unload、remove、index),並用 makepkg 建置 .gfn 或 .zip 函式套件。開啟本機資料集回傳彙總統計,或估計 OLS 模型。
- 適用情境
- 適合在 Gretl 中進行計量經濟學工作:教學輔助、教科書重現與作業自動化、AR/ARIMA/VAR 預測儀表板、蒙地卡羅與壓力測試,以及以已儲存腳本為基礎的可重現研究流程。
- 執行需求
- 以本機 stdio 程序在使用者電腦上執行(僅桌面端)。需要 Node.js 20 或更新版本、Gretl 2026b 或更新版本且 gretlcli 可用,以及支援 stdio 伺服器的 MCP 用戶端。選用環境變數 GRETL_CLI 與 GRETL_GUI 可指定 CLI 與 GUI 執行檔路徑;GRETLMCP_WORKSPACE_DIR 設定工作區目錄,GRETLMCP_OPEN_GUI 控制預設是否開啟 GUI。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Gretl MCP,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Gretl MCP
Built for AI agents: run Hansl/Gretl workflows, get graph screenshots, and view calculations in the real Gretl GUI.
It lets MCP clients run Gretl/Hansl scripts, raw Gretl command lines, existing
.inp files, package operations, package builds, help lookups, dataset
summaries, and OLS models. The generic gretl_run_script tool is the main path
for prompt-generated Gretl workflows: the client writes Hansl from the user's
request, runs it through Gretl, and returns Gretl's output plus generated
artifacts.
Keywords: Claude Gretl, MCP econometrics, Hansl AI, Gretl GUI automation.
Key Features
- Scriptable Gretl control through
gretlcli. - GUI-first workflow tools that launch
gretl.exeand fail if the GUI did not open. - Capability discovery for Gretl commands, functions, and package commands.
- Generic execution tools for full Hansl scripts, command lists, and local
.inpscript files. - Package tools for
pkgandmakepkgworkflows from the Gretl Function Package Guide. - High-level tools for version checks, command help, dataset summaries, and OLS.
- Stdio transport, compatible with common MCP clients.
- Safe defaults for arbitrary scripts, with documented escape hatches.
Requirements
- Node.js 20 or newer.
- Gretl 2026b or newer with
gretlcliavailable. - An MCP client that supports stdio servers.
Getting Started
One-command install (after npm publish):
Local install from GitHub:
Then point your MCP client at the built server:
Visual Walkthrough
Forecast output example (actual vs forecast):
Forecast error panel:
Install Gretl
Windows
Download Gretl from the official page: https://gretl.sourceforge.net/win32/
For a no-admin setup, extract the zip archive to:
Verify:
macOS
Install via Homebrew (if available on your setup) or the Gretl project site:
Linux
Install from your distro packages, then verify:
MCP Client Config
Use this JSON config for stdio MCP clients:
After npm publication, the standard MCP config is:
Client Setup
Claude Code
Local GitHub build:
npm install path:
Codex
Local GitHub build:
npm install path:
Cursor, Windsurf, Cline, and similar clients
Use the local JSON config above. If the client asks for a command and args separately, use:
VS Code
Try It Quickly
Ask your agent:
The MCP response includes generated artifact paths, workspace/script paths, and GUI launch details.
Configuration
gretl-mcp supports environment variables and CLI flags.
Environment variables:
GRETL_CLI: optional path togretlcliorgretlcli.exe.GRETL_GUI: optional path togretlorgretl.exe.GRETLMCP_WORKSPACE_DIR: optional directory for Gretl run workspaces.GRETLMCP_OPEN_GUI: set tofalseto stop tools from opening Gretl windows by default.GRETLMCP_REQUIRE_GUI: set tofalseto allow CLI-only success when GUI opening is disabled or unavailable.GRETLMCP_ENFORCE_GUI_ONLY: set totrueto reject any headless workflow request.
CLI options:
Tools
gretl_version: checks Gretl availability.gretl_gui_version: checks Gretl GUI availability.gretl_gui_launch: launches the visible Gretl desktop GUI.gretl_capabilities: lists installed Gretl commands, functions, and package help.gretl_run_script: runs a Gretl/Hansl script and requires GUI opening by default.gretl_run_commands: runs raw Gretl command lines and requires GUI opening by default.gretl_run_script_file: runs an existing local.inpfile and requires GUI opening by default.gretl_package: runs nativepkgactions such as install, query, run-sample, unload, remove, and index.gretl_make_package: builds.gfnor.zipfunction packages withmakepkg.gretl_help: returns Gretl help for a command.gretl_dataset_summary: opens a local dataset, returns summary statistics, and requires GUI opening by default.gretl_ols: opens a local dataset, estimates an OLS model, and requires GUI opening by default.
Safety
gretl_run_script, gretl_run_commands, and gretl_run_script_file default to
safeMode: true, which blocks common shell-like commands and absolute file
reads/writes. This is a guardrail, not a complete sandbox. Use safeMode: false
only for trusted local work.
Dataset helper tools reject URLs and require paths to existing local files.
Examples
examples/homework-variance-ftest.inp: Gretl script for a homework-style F test with critical-value and p-value calculations.examples/forecasting-dashboard.inp: Macro forecasting dashboard with AR, ARIMA, VAR, forecast plots, and an RMSE/MAE comparison table.examples/specification-curve-analysis.inp: 32-model robustness sweep for an education coefficient with curve, confidence bands, and histogram plots.
Use Cases
- Econometrics teaching aid with visible Gretl GUI workflows.
- Textbook replication and assignment automation.
- Forecasting dashboards (AR/ARIMA/VAR) with artifact outputs.
- Monte Carlo and stress-testing workflows for research.
- Reproducible research pipelines via saved scripts and Gretl
.inpfiles.
GUI Mode
By default, the workflow tools open their generated Hansl script in the real
Gretl desktop app while also returning structured MCP output. More importantly,
they now treat GUI opening as required outside CI. If the Gretl window does not
open, the tool returns ok: false even when the CLI script itself succeeded.
Set displayInGretl: false and requireGui: false on a tool call, or set
GRETLMCP_OPEN_GUI=false together with GRETLMCP_REQUIRE_GUI=false, to allow
CLI-only automation.
For clients that should never bypass the desktop app, set
GRETLMCP_ENFORCE_GUI_ONLY=true or launch the server with --enforce-gui-only.
In that mode, the workflow tools reject displayInGretl: false and
requireGui: false instead of honoring them.
gretl_gui_launch can also be called directly. It starts the real Gretl desktop
application, opens a local dataset/script file, or writes a prompted Hansl script
and launches Gretl with --run.
This is not full click-by-click GUI control by itself. If you want the agent to observe screenshots, click menus, and make choices exactly like a human, the MCP client also needs desktop automation or computer-use capability. Gretl MCP now provides the Gretl-side launch surface for that workflow.
Local Development
npm run stress drives the built MCP server through broader prompt-style
workflows: macro forecasting, structural breaks, Monte Carlo simulation,
textbook replication, diagnostic automation, NLS, mixed-frequency compaction,
panel models, GARCH graphs, IV simulation, and a reproducible project. The
foreign-language stress case is dependency-gated and requires a real Python,
Rscript, or Octave executable on PATH.
To surface stress outputs for docs or QA snapshots:
Then inspect the reported workspace for generated graphs/tables.
Run the built server:
Publishing
This project is structured for GitHub, npm, and MCP Registry metadata:
- GitHub hosts source code, issues, docs, releases, and CI.
- npm will provide the easiest user install path after publication.
server.jsonis included for registry publish.
Before publishing to npm or the MCP Registry, review docs/publishing.md.
Community
Issues and pull requests are welcome. See CONTRIBUTING.md for contribution
flow and expectations.
來源:README.md,提交 2bafcc0
工具
0版本歷史
1- v0.2.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分