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.

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

本地 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。
安装前请注意
脚本、命令和 .inp 工具会在 Gretl 中执行代码,并默认打开 GUI 窗口;若窗口未打开,即使脚本成功,工具也会报告失败。safeMode 默认为 true,会拦截常见的类 shell 命令和绝对路径文件读写,但它只是防护措施,并非完整沙箱;仅在可信的本地工作中才应关闭。包工具可以安装、删除和构建包。数据集工具拒绝 URL,只接受已存在的本地文件。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Gretl MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Gretl MCP

[npm version] [GitHub stars]

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.exe and 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 .inp script files.
  • Package tools for pkg and makepkg workflows 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 gretlcli available.
  • An MCP client that supports stdio servers.

Getting Started

One-command install (after npm publish):

powershell
npx -y gretl-mcp@latest --version

Local install from GitHub:

powershell
git clone https://github.com/OndrejLapes/GretlMCP.gitcd GretlMCPnpm installnpm run build

Then point your MCP client at the built server:

json
{  "mcpServers": {    "gretl": {      "command": "node",      "args": ["C:\\Users\\YOUR_USER\\GretlMCP\\dist\\index.js"],      "env": {        "GRETL_CLI": "C:\\Users\\YOUR_USER\\tools\\gretl\\gretlcli.exe",        "GRETL_GUI": "C:\\Users\\YOUR_USER\\tools\\gretl\\gretl.exe"      }    }  }}

Visual Walkthrough

Forecast output example (actual vs forecast):

[Forecast actual vs forecast]

Forecast error panel:

[Forecast errors]

Install Gretl

Windows

Download Gretl from the official page: https://gretl.sourceforge.net/win32/

For a no-admin setup, extract the zip archive to:

text
C:\Users\YOUR_USER\tools\gretl

Verify:

powershell
& C:\Users\YOUR_USER\tools\gretl\gretlcli.exe --version

macOS

Install via Homebrew (if available on your setup) or the Gretl project site:

bash
brew install gretlgretlcli --version

Linux

Install from your distro packages, then verify:

bash
sudo apt-get install gretl    # Debian/Ubuntu examplegretlcli --version

MCP Client Config

Use this JSON config for stdio MCP clients:

json
{  "mcpServers": {    "gretl": {      "command": "node",      "args": ["C:\\Users\\YOUR_USER\\GretlMCP\\dist\\index.js"],      "env": {        "GRETL_CLI": "C:\\Users\\YOUR_USER\\tools\\gretl\\gretlcli.exe",        "GRETL_GUI": "C:\\Users\\YOUR_USER\\tools\\gretl\\gretl.exe"      }    }  }}

After npm publication, the standard MCP config is:

json
{  "mcpServers": {    "gretl": {      "command": "npx",      "args": ["-y", "gretl-mcp@latest"],      "env": {        "GRETL_CLI": "C:\\Users\\YOUR_USER\\tools\\gretl\\gretlcli.exe",        "GRETL_GUI": "C:\\Users\\YOUR_USER\\tools\\gretl\\gretl.exe"      }    }  }}

Client Setup

Claude Code

Local GitHub build:

powershell
claude mcp add gretl node C:\Users\YOUR_USER\GretlMCP\dist\index.js

npm install path:

powershell
claude mcp add gretl npx -y gretl-mcp@latest

Codex

Local GitHub build:

toml
[mcp_servers.gretl]command = "node"args = ["C:\\Users\\YOUR_USER\\GretlMCP\\dist\\index.js"]
[mcp_servers.gretl.env]GRETL_CLI = "C:\\Users\\YOUR_USER\\tools\\gretl\\gretlcli.exe"GRETL_GUI = "C:\\Users\\YOUR_USER\\tools\\gretl\\gretl.exe"

npm install path:

toml
[mcp_servers.gretl]command = "npx"args = ["-y", "gretl-mcp@latest"]
[mcp_servers.gretl.env]GRETL_CLI = "C:\\Users\\YOUR_USER\\tools\\gretl\\gretlcli.exe"GRETL_GUI = "C:\\Users\\YOUR_USER\\tools\\gretl\\gretl.exe"

Cursor, Windsurf, Cline, and similar clients

Use the local JSON config above. If the client asks for a command and args separately, use:

text
command: nodeargs: C:\Users\YOUR_USER\GretlMCP\dist\index.js

VS Code

powershell
code --add-mcp "{\"name\":\"gretl\",\"command\":\"node\",\"args\":[\"C:\\\\Users\\\\YOUR_USER\\\\GretlMCP\\\\dist\\\\index.js\"],\"env\":{\"GRETL_CLI\":\"C:\\\\Users\\\\YOUR_USER\\\\tools\\\\gretl\\\\gretlcli.exe\",\"GRETL_GUI\":\"C:\\\\Users\\\\YOUR_USER\\\\tools\\\\gretl\\\\gretl.exe\"}}"

Try It Quickly

Ask your agent:

text
Run a Gretl forecasting dashboard with AR, ARIMA, and VAR. Save plots and compare RMSE/MAE.

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 to gretlcli or gretlcli.exe.
  • GRETL_GUI: optional path to gretl or gretl.exe.
  • GRETLMCP_WORKSPACE_DIR: optional directory for Gretl run workspaces.
  • GRETLMCP_OPEN_GUI: set to false to stop tools from opening Gretl windows by default.
  • GRETLMCP_REQUIRE_GUI: set to false to allow CLI-only success when GUI opening is disabled or unavailable.
  • GRETLMCP_ENFORCE_GUI_ONLY: set to true to reject any headless workflow request.

CLI options:

powershell
gretl-mcp --gretl-cli C:\Users\YOUR_USER\tools\gretl\gretlcli.exegretl-mcp --gretl-gui C:\Users\YOUR_USER\tools\gretl\gretl.exegretl-mcp --workspace C:\Users\YOUR_USER\gretl-mcp-runsgretl-mcp --enforce-gui-onlygretl-mcp --allow-headlessgretl-mcp --helpgretl-mcp --version

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 .inp file and requires GUI opening by default.
  • gretl_package: runs native pkg actions such as install, query, run-sample, unload, remove, and index.
  • gretl_make_package: builds .gfn or .zip function packages with makepkg.
  • 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 .inp files.

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

powershell
npm installnpm run typechecknpm testnpm run buildnpm run smokenpm run stress

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:

powershell
npm run stress

Then inspect the reported workspace for generated graphs/tables.

Run the built server:

powershell
node dist/index.js

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.json is 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
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.2.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分