Skip to main content
Glama
GeoGebra MCP Server
by 123pc

GeoGebra MCP Server

让 Claude Code、Codex 和其他 MCP 客户端操控 GeoGebra——绘制几何构造、函数图像、3D 图形、动态机构,保存 .ggb,导出 .png。默认使用 Web Runtime,无需安装 GeoGebra 桌面版。

本项目不是要替代 GeoGebra,而是把 GeoGebra 变成 AI 可以可靠调用的数学可视化后端。


能做什么

场景

示例

函数图像

f(x)=sin(x), g(x)=cos(x), 交点, 切线

平面几何

三角形, 外接圆, 角平分线, 轨迹, 位似变换

3D 图形

空间曲线, 平面, 球面, 多面体

机构简图

曲柄摇杆, 曲柄滑块, 四连杆, 缩放机构

数据图表

条形图, 直方图, 回归曲线

动态动画

滑块驱动旋转, 轨迹追踪, 自动播放


Related MCP server: freecad-mcp

架构


环境要求

  • Python 3.10+

  • Node.js v16+ 和 npm

  • 支持 MCP stdio 的 AI 客户端(Claude Code / Codex / …)

  • 首次使用 Web Runtime 需要网络访问 GeoGebra CDN;Puppeteer 会自动下载 Chromium

Windows、macOS、Linux 均可使用。

**可选:**如需使用桌面版后端(GEOGEBRA_BACKEND=desktop),则需要 GeoGebra Classic 6。

默认 Web Runtime

GeoGebra Classic 6 桌面版不再是必需的。 默认情况下,MCP Server 会自动启动 Chromium,加载 GeoGebra 网页版,通过 GeoGebra Apps API 控制绘图。用户无需安装或配置任何 GeoGebra 桌面软件。

GEOGEBRA_BACKEND=auto   # 默认:优先 Web,失败时回落 desktop
GEOGEBRA_BACKEND=web    # 仅使用 Web Runtime
GEOGEBRA_BACKEND=desktop # 仅使用 Classic 6 CDP 桌面版
GEOGEBRA_WEB_HEADLESS=1 # 无头模式(默认);=0 显示浏览器窗口
GEOGEBRA_WEB_BUNDLE=cdn # 默认:从 GeoGebra CDN 加载;=local 使用离线 bundle

首次使用 Puppeteer 会自动下载 Chromium。
离线模式使用 GeoGebra 官方 web bundle。发布包含该 bundle 的软件包前,请查阅 GeoGebra 许可证。

离线 Web Runtime

下载 GeoGebra Math Apps Bundle 到本地缓存,实现完全离线运行:

# 下载离线 bundle
python scripts/setup_geogebra_web_bundle.py

# 验证 bundle 完整性
python scripts/setup_geogebra_web_bundle.py --check

使用离线模式:

# Windows
$env:GEOGEBRA_BACKEND="web"
$env:GEOGEBRA_WEB_BUNDLE="local"
geogebra-mcp-doctor

# macOS / Linux
GEOGEBRA_BACKEND=web GEOGEBRA_WEB_BUNDLE=local geogebra-mcp-doctor

适合学校机房、离线机器或网络受限环境。普通用户无需下载 bundle,默认 CDN 模式即可。


快速开始

1. 自然语言自动安装(推荐)

仿照 MATLAB Agentic Toolkit 的方式,普通用户可以不手动编辑 MCP JSON/TOML。

git clone https://github.com/123pc/Geogebra_mcp.git
cd Geogebra_mcp

然后在这个目录里启动 Claude Code、Codex 或其他 agent,对它说:

Set up GeoGebra MCP

agent 会根据 AGENTS.md 和 skills/geogebra-setup 的指导运行:

python scripts/setup_geogebra_mcp.py

这个脚本会自动完成:

  • 安装 Node 依赖:npm install

  • 安装 Python 包:python -m pip install -e .

  • 写入 Claude Code 全局 MCP 配置

  • 写入 Codex 全局 MCP 配置

  • 注册本仓库提供的 skills

  • 运行 geogebra-mcp-doctor 做环境诊断

完成后重启 agent,并在任意项目目录中验证:

Use GeoGebra MCP to check status and draw a triangle.

如果只想配置某一个客户端:

python scripts/setup_geogebra_mcp.py --agent claude
python scripts/setup_geogebra_mcp.py --agent codex

2. 手动安装

git clone https://github.com/123pc/Geogebra_mcp.git
cd Geogebra_mcp
npm install                  # Node 依赖(puppeteer,含 Chromium)
python -m pip install -e .   # Python 依赖 + 暴露 CLI 命令

npm install 不可省略——Node 守护进程依赖 puppeteer(自动管理 Chromium 浏览器)。
也可运行 python install_wizard.py 进行交互式安装向导。

3. 环境诊断

geogebra-mcp-doctor
# 如果命令不在 PATH 中,改用:
python -m geogebra_mcp.doctor

预期输出(Web Runtime 默认):

[OK] python: 3.13.5
[OK] node: v22.17.1
[OK] npm
[OK] daemon_js: .../geogebra_mcp/geogebra_daemon.js
[OK] package_json: .../geogebra_mcp/package.json
[OK] backend: auto
[OK] web_assets: .../geogebra_mcp
[OK] puppeteer: installed
[SKIP] geogebra_install: not required for backend=auto
[SKIP] cdp_port: not required for backend=auto

geogebra_install 和 cdp_port 被跳过是正常的——Web Runtime 不需要 GeoGebra 桌面版。

4. 可选:Desktop 后端(GeoGebra Classic 6 CDP)

仅当设置 GEOGEBRA_BACKEND=desktop 时才需要以下步骤。Web Runtime 用户可跳过。

每次使用前需要以调试模式启动 GeoGebra Classic 6:

Windows: 双击 start_geogebra.bat,或在终端中执行:

CMD:

for /d %v in ("%LOCALAPPDATA%\GeoGebra_6\app-*") do start "" "%~fv\GeoGebra.exe" --remote-debugging-port=9222

PowerShell:

$ggb = Get-ChildItem "$env:LOCALAPPDATA\GeoGebra_6\app-*\GeoGebra.exe" | Sort-Object -Descending | Select-Object -First 1; Start-Process $ggb.FullName "--remote-debugging-port=9222"

macOS:

open -a "GeoGebra Classic 6" --args --remote-debugging-port=9222

Linux:

geogebra-classic --remote-debugging-port=9222

5. 配置 AI 客户端

推荐:运行自动配置脚本(无需手动编辑 JSON):

python scripts/setup_geogebra_mcp.py

该脚本自动完成:安装依赖 → 写入 MCP 配置 → 注册 skills → 运行诊断。
--agent claude 仅配置 Claude Code,--agent codex 仅配置 Codex。

手动配置: 在你的 MCP 配置文件中加入:

{
  "mcpServers": {
    "geogebra": {
      "command": "python",
      "args": ["-m", "geogebra_mcp.server"]
    }
  }
}

python -m geogebra_mcp.server 在任何目录都能运行,不依赖仓库路径。
pip install -e . 后也可直接用 geogebra-mcp-server(如果 Scripts 目录在 PATH 中)。

Claude Code 用户还需在 settings.json 中添加:

{ "enabledMcpjsonServers": ["geogebra"] }

重启客户端后生效。


MCP 工具

连接与状态

工具

说明

geogebra_status

检查 GeoGebra 连接状态

geogebra_version

查看 MCP Server 版本

geogebra_help

获取命令/机构/动画参考(topic="commands"|"mechanisms"|"animation")

命令执行

工具

推荐度

说明

geogebra_run_commands

推荐

结构化数组执行,适合 AI 客户端

geogebra_create_construction

推荐

结构化对象执行,带样式和动画

geogebra_exec

备选

单条命令执行

geogebra_batch

兼容

JSON 字符串批量执行,兼容旧客户端

geogebra_draw_mechanism

兼容

JSON 字符串机构绘制,兼容旧客户端

视图与外观

工具

说明

geogebra_new_construction

清空当前构造

geogebra_set_view

设置视图:G(几何)、AG(代数+几何)、3D、T(表格)

geogebra_set_appearance

颜色、线宽、点大小、标签可见性

geogebra_animate

启动/停止滑块动画,设置速度

geogebra_get_objects

获取当前构造对象列表(用于自验收)

输出

工具

说明

geogebra_save

保存为 .ggb 文件

geogebra_export_png

导出当前视图为 .png


给 AI 的调用流程

AI 在处理绘图请求时应遵循以下步骤:

  1. 确认输出路径 — 如果用户没指定保存位置,先问「文件保存在哪里?」

  2. 检查连接 — geogebra_status

  3. 未连接时提示 — Web Runtime 会自动启动 Chromium;Desktop 后端需告知用户双击 start_geogebra.bat 启动 GeoGebra

  4. 设置视图 — geogebra_set_view

  5. 清空画布(如需) — geogebra_new_construction

  6. 发送命令 — 用 geogebra_run_commands 或 geogebra_create_construction

  7. 自验收 — geogebra_get_objects,确认对象数 >= 3

  8. 动画(如需) — geogebra_set_appearance 使滑块可见 + geogebra_animate 自动播放

  9. 保存 — geogebra_save


示例

用自然语言

"画 y=sin(x) 和 y=cos(x),标出交点,导出到 D:/output/sin_cos.png"

曲柄摇杆机构

{
  "name": "crank_rocker",
  "design": {
    "perspective": "G",
    "commands": [
      "O1=(0,0)", "O2=(6,0)", "alpha=30 deg",
      "A=O1+(2*cos(alpha),2*sin(alpha))",
      "c1=Circle(A,5)", "c2=Circle(O2,4)",
      "B=Intersect(c1,c2,1)",
      "crank=Segment(O1,A)", "coupler=Segment(A,B)",
      "rocker=Segment(B,O2)", "ground=Segment(O1,O2)"
    ],
    "styles": [
      {"label":"alpha","visible":true,"label_visible":true},
      {"label":"crank","color":[1,0,0],"thickness":6},
      {"label":"coupler","color":[0,0.2,1],"thickness":6},
      {"label":"rocker","color":[0,0.7,0.2],"thickness":6},
      {"label":"ground","color":[0,0,0],"thickness":5}
    ],
    "animate": "alpha",
    "speed": 0.5
  },
  "output_dir": "D:/output"
}

推荐使用 ASCII 标签(alpha 而非 α),避免不同客户端间的编码问题。


Skills

仓库附带三套 skill,教 AI 更稳定地使用本 MCP:

Skill

用途

skills/geogebra-master

教 AI 像 GeoGebra 专家一样作图——强制滑块可见、自动播放动画、自验收

skills/use-geogebra-mcp

教 AI 部署、配置、诊断本 MCP,以及离线 bundle 的使用

skills/geogebra-setup

教 AI 一键安装和配置本 MCP(python scripts/setup_geogebra_mcp.py)


环境变量

变量

默认值

说明

GEOGEBRA_BACKEND

auto

后端选择:auto(优先 Web)、web、desktop

GEOGEBRA_WEB_HEADLESS

1

Web Runtime 无头模式:1=是,0=显示浏览器窗口

GEOGEBRA_WEB_WIDTH

1200

Web Runtime 视口宽度

GEOGEBRA_WEB_HEIGHT

800

Web Runtime 视口高度

GEOGEBRA_WEB_BUNDLE

cdn

Web Runtime 资源加载方式:cdn(在线)或 local(离线 bundle)

GEOGEBRA_WEB_BUNDLE_PATH

平台默认

离线 bundle 缓存目录(覆盖默认路径)

GEOGEBRA_CDP_PORT

9222

Desktop 后端 CDP 远程调试端口

GEOGEBRA_RESTART_EXISTING

0

Desktop 后端:设为 1 允许自动重启已有的 GeoGebra


常见问题

connected: false

Web Runtime(默认): 检查网络是否能访问 GeoGebra CDN,Puppeteer/Chromium 是否已安装。运行 node scripts/smoke_web_runtime.js 进行诊断。如果 CDN 不可达(如学校机房、离线环境),下载离线 bundle 后设置 GEOGEBRA_WEB_BUNDLE=local 即可(见离线 Web Runtime)。

Desktop 后端(GEOGEBRA_BACKEND=desktop): GeoGebra 未以调试模式运行。确保已用 --remote-debugging-port=9222 启动(见快速开始第 4 步)。

动画不动

检查三点:

  1. 是否创建了角度滑块(alpha=30 deg)

  2. 运动点是否依赖滑块(A=O+(2*cos(alpha),2*sin(alpha)))

  3. 是否调用了 geogebra_set_appearance 使滑块可见 + geogebra_animate(label="alpha", animate=true)

  4. 使用 geogebra_create_construction 可自动处理以上步骤

AI 画的图和实际不符 / 空白

让 AI 调用 geogebra_get_objects 自验收。如果对象数为 0,AI 应重试而非声称"完成"。

已经打开的 GeoGebra 能接管吗?

**Desktop 后端:**不能。必须关闭后以 --remote-debugging-port=9222 重新启动。Web Runtime 不受此限制,它会自动启动独立的 Chromium 实例。

能在 macOS / Linux 上用吗?

可以。三平台均已适配。

为什么要用 alpha 而非 α?

希腊字母在部分客户端、终端或 JSON 日志中可能出现编码异常。推荐默认使用 ASCII 名称以提高普适性。


更新

在项目目录下运行:

python update.py

该脚本自动执行 git pull → npm install → pip install -e . → 同步 MCP 配置和 skills,无需重新 clone。


开发

# 运行测试
python -m pytest -q                     # Python (64 tests)
node tests/test_daemon_protocol.js      # Node (27 tests)

# Web Runtime 冒烟测试
node scripts/smoke_web_runtime.js                    # CDN 模式
GEOGEBRA_WEB_BUNDLE=local node scripts/smoke_web_runtime.js  # 离线模式

# 离线 bundle 管理
python scripts/setup_geogebra_web_bundle.py          # 下载
python scripts/setup_geogebra_web_bundle.py --check  # 验证

# 构建 wheel
python -m build --wheel

贡献

欢迎所有形式的贡献!

  • 在 Issues 中报告 bug 或提出功能建议

  • 提交 Pull Request 改进代码、文档或 skill

  • 测试并适配更多 AI 客户端(Codex、DeepSeek TUI 等)

  • 分享你用它绘制的有趣构造

当前适配状态

客户端

状态

Claude Code

已测试

Codex

适配中

DeepSeek TUI

计划中

其他 MCP 客户端

欢迎测试反馈


许可证

MIT © 2026 GeoGebra MCP contributors

Available Tools

15 tools
geogebra_animateA

设置动画——让滑块控制的机构动起来。

Args: label: 滑块标签, 如 "α" animate: 是否启动动画 speed: 速度 (0.1-10)

Inputs: label (required), animate, speed. Returns: result

geogebra_batchB

在 GeoGebra 中批量执行多条命令。适合一次性构建完整机构。

Args: commands_json: JSON 数组格式的命令列表, 如 '["A=(0,0)","B=(6,0)","Segment(A,B)"]'

Inputs: commands_json (required). Returns: result

geogebra_create_constructionA

Create a construction from a structured design dict. Preferred over geogebra_draw_mechanism for AI clients — no JSON string wrapping needed.

design dict format: {"perspective":"G", "animate":"α", "speed":0.5, "commands":["O1=(0,0)","O2=(6,0)","α=45°",...], "styles":[{"label":"A","color":[1,0,0],"point_size":5},...]}

Auto-behavior (no manual steps needed):

  • Auxiliary circles named c1, c2, c3... are automatically hidden.

  • The animation slider is auto-made visible and set to play.

  • Construction must use 'c1', 'c2' etc. for circles to be auto-hidden.

Args: name: Output filename stem design: Dict with perspective, commands, styles, animate, and speed output_dir: Output directory (default: cwd)

Inputs: name (required), design (required), output_dir. Returns: result

geogebra_draw_mechanismA

Create a complete mechanism: new construction → commands → styles → save .ggb + PNG. Use geogebra_batch for commands instead of this tool unless you need one-step save.

── MECHANISM TEMPLATES ──

Crank-Rocker (曲柄摇杆): O1=(0,0) O2=(d,0) α=angle° crank_len=r coupler_len=L rocker_len=R A = O1 + (rcos(α), rsin(α)) c1 = Circle(A, L) c2 = Circle(O2, R) B = Intersect(c1, c2, 1) Segment(O1, A) Segment(A, B) Segment(B, O2) Animate: StartAnimation(α) Style: thick segments, colored points

Slider-Crank (曲柄滑块): O=(0,0) α=angle° r=crank L=coupler A = O + (rcos(α), rsin(α)) c = Circle(A, L) guide = Line((0,-r), (10,-r)) B = Intersect(c, guide, 1) Segment(O, A) Segment(A, B) Circle(B, 0.1) Animate: StartAnimation(α)

Double-Crank / Drag-Link: O1=(0,0) O2=(d,0) α=angle° r1,r2=crank lengths L=coupler A = O1 + (r1cos(α), r1sin(α)) B = O2 + (r2cos(α+offset), r2sin(α+offset)) Segment(O1,A) Segment(A,B) Segment(B,O2) Animate: StartAnimation(α)

Four-Bar Linkage (general): Same as crank-rocker but adjust lengths. Valid if shortest+longest ≤ sum of other two.

── design_json FORMAT ── { "perspective": "G", "animate": "α", "speed": 0.5, "commands": ["O1=(0,0)", "O2=(6,0)", "α=45°", ...], "styles": [ {"label": "A", "color": [1,0,0], "point_size": 5}, {"label": "Segment(O1,A)", "thickness": 5}, {"label": "O1", "point_size": 6, "color": [0,0,0]} ] }

── WORKFLOW ──

  1. New construction (automatic)

  2. Execute commands in order

  3. Apply styles (colors, thickness, point sizes)

  4. Start animation on the angle slider

  5. Auto-zoom and save .ggb + .png

Args: name: Mechanism name (used for filename) design_json: JSON string with design (see format above) output_dir: Output directory (default: current working directory)

Inputs: name (required), design_json (required), output_dir. Returns: result

geogebra_execA

Execute a GeoGebra command. To make a mechanism MOVE (animate), you MUST create an angle slider and define points that depend on it.

── COMMAND REFERENCE ──

POINTS: A = (x, y) — free point A = (3, 4) M = Midpoint(A, B) — midpoint P = Point(c, 0.5) — point on curve c at parameter 0..1

ANGLE SLIDER (the KEY to animation): α = 30° — creates an angle slider. ALWAYS start with this β = 60° — for mechanisms needing a second angle These become sliders. Use StartAnimation(α) to drive motion.

DEPENDENT POINTS (formulas using the angle): A = O1 + (rcos(α), rsin(α)) A = (rcos(α), rsin(α)) — same when O1 is origin X = (acos(α), bsin(α)) — ellipse motion These points MOVE when α changes. This is how animation works.

LINES & SEGMENTS: Line(A, B) — infinite line through A,B Segment(A, B) — segment between A,B Ray(A, B) — ray from A through B PerpendicularLine(A, l)— line through A ⟂ l ParallelLine(A, l) — line through A ∥ l

CIRCLES & ARCS: Circle(O, r) — circle center O radius r Circle(O, A) — circle center O through point A c = Circle(O1, 2) — name it 'c' to reuse

INTERSECTIONS (critical for mechanisms): P = Intersect(c1, c2) — all intersections P = Intersect(c1, c2, 1) — FIRST intersection (use 1 or 2) P = Intersect(c1, c2, 2) — SECOND intersection P = Intersect(Segment(A,B), c) — segment-circle intersection

ANGLES: Angle(A, O, B) — ∠AOB in degrees

SLIDER (numeric): r = 2 — creates a numeric slider if value is a plain number r = Slider(0, 5, 0.1) — explicit slider(min, max, step)

TRANSFORMATIONS: Rotate(A, α, O) — rotate A around O by angle α Dilate(A, s, O) — dilate A from O by factor s Translate(A, v) — translate A by vector v

ANIMATION: StartAnimation(α) — start the slider α animating StartAnimation() — start all sliders StopAnimation() — stop all animations SetAnimationSpeed(α, s) — set speed (0.1–10) After building the mechanism, always call StartAnimation(angle_label) and then geogebra_animate() for speed control.

MISC: ZoomIn(1) — zoom ZoomOut(1) — un-zoom Pan(x, y) — pan view

── CRITICAL RULES ──

  1. ALWAYS create an angle slider (eg α=30°) FIRST before dependent points

  2. Dependent points use cos(α), sin(α) — they move when α animates

  3. For linkages, define fixed pivots → slider → dependent points → segments

  4. Intersect() with index 1 or 2 picks WHICH intersection to use

  5. After all commands, call geogebra_animate() to start motion

Args: command: GeoGebra command string (see reference above)

Inputs: command (required). Returns: result

geogebra_export_pngB

导出当前 GeoGebra 视图为 PNG 截图。

Args: filepath: 保存路径, 如 "D:/tool/screenshot.png" scale: 缩放因子 (1-4, 默认2)

Inputs: filepath (required), scale. Returns: result

geogebra_get_objectsA

获取当前构造中所有对象的名称列表。

Inputs: no named parameters. Returns: result

geogebra_helpA

获取 GeoGebra 命令和机构设计的帮助。在构建机构之前先调用此工具。

Args: topic: "commands"=命令参考, "mechanisms"=机构模板, "animation"=动画, "all"=全部

Inputs: topic. Returns: result

geogebra_new_constructionA

新建空白 GeoGebra 构造,清除当前所有对象。

Inputs: no named parameters. Returns: result

geogebra_run_commandsA

Execute multiple GeoGebra commands from a structured list. Preferred over geogebra_batch for AI clients — no JSON string wrapping needed.

Args: commands: Ordered GeoGebra commands, e.g. ["A=(0,0)", "B=(6,0)", "Segment(A,B)"]

Inputs: commands (required). Returns: result

geogebra_saveB

保存当前 GeoGebra 构造为 .ggb 文件。

Args: filepath: 保存路径, 如 "D:/tool/my_mechanism.ggb"

Inputs: filepath (required). Returns: result

geogebra_set_appearanceB

设置对象外观(颜色、线宽、点大小、可见性)。

Args: label: 对象标签名 color_r/g/b: RGB 颜色 0-1 (-1 不修改) thickness: 线宽 1-13 point_size: 点大小 1-9 visible: 是否可见 label_visible: 是否显示标签

Inputs: label (required), color_r, color_g, color_b, +4 more. Returns: result

geogebra_set_viewA

设置 GeoGebra 视图模式。

Args: perspective: "G"=几何, "A"=代数, "T"=表格, "3D"=三维, "AG"=代数+几何

Inputs: perspective. Returns: result

geogebra_statusA

检查 GeoGebra 连接状态和当前构造信息。

Inputs: no named parameters. Returns: result

geogebra_versionA

返回 MCP Server 版本号。

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 15 tools

    Disambiguation3/5

    Multiple tools (geogebra_batch, geogebra_create_construction, geogebra_draw_mechanism, geogebra_exec, geogebra_run_commands) overlap in executing commands, though descriptions guide preferred usage. This can cause confusion for agents.

    Naming Consistency4/5

    All tools share the 'geogebra_' prefix and mostly follow verb_noun pattern (e.g., create_construction, export_png). Some are single verbs (animate, exec, status), which is a minor inconsistency.

    Tool Count5/5

    15 tools is well-scoped for the domain of creating and animating GeoGebra constructions. Each tool serves a clear purpose without redundancy or excessive specialization.

    Completeness4/5

    Covers core workflows: creation, command execution, styling, animation, saving, and export. Minor gaps include no delete/undo tool and limited object querying beyond names.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables to control FreeCAD from Claude Desktop through MCP, allowing CAD operations like creating and editing objects, taking screenshots, and executing Python code.
      11
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables AI to interact with GeoGebra for mathematical visualization, offering over 25 tools for geometry, functions, algebra, and more.
      MIT