nicegui-llm-bridge
Enables LLMs to drive NiceGUI apps by exposing an interactive element tree via MCP tools for clicking and filling form values.
README
nicegui-llm-bridge
Drive any NiceGUI 3.x app from an LLM. No browser. No DOM. Pure wire.
[!CAUTION] v0.0.1-alpha — YOLO ship, single overnight build, only smoke-tested against the bundled
examples/gallery.pyand one probe against livenicegui.io. No unit tests beyond the round-trip E2E. Wire protocol is NiceGUI-3.x-specific and will break on major-version drift. Feedback from agent operators welcome — see issue #1 for the questions we'd most like answered.
This is the third member of the nicegui-tui / nicegui-wire / nicegui-llm-bridge trio. It treats NiceGUI's Client abstraction as exactly what it is — a consumer of an outbox — and adds an LLM-shaped rendering target:
nicegui-tui→ renders into a Textual TUI in-processnicegui-wire→ renders into Textual / framebuffer over the networknicegui-llm-bridge→ renders into an LLM's cognition, via MCP
What it does
Connects to a running NiceGUI page via the Socket.IO wire (reusing nicegui-wire's engine), keeps a live element-tree mirror, and exposes it to an LLM as indented bullets:
- div#3
- div#4 text='nicegui-llm-bridge gallery'
- q-tabs#6 model-value='basics' [interactive: update:modelValue]
- q-tab#7 label='Basics', name='basics'
- q-tab-panels#12 model-value='basics' [interactive: update:modelValue]
- q-tab-panel#13 name='basics'
- div#17 text='count: 0'
- q-btn#18 label='Increment' [interactive: click]
- q-btn#19 label='Warn' [interactive: click]
Then the LLM can act: click(18) → page rerenders → LLM sees count: 1.
MCP tools
| Tool | Purpose |
|---|---|
open(url) |
Connect to a NiceGUI page and return the indented-bullet view |
read() |
Re-emit current mirror (no network roundtrip) |
actions() |
JSON list of every interactive element |
click(element_id) |
Fire a click; return post-action view |
fill(element_id, value) |
Set a form value; return post-action view |
choose(element_id, option) |
Pick a radio/select option by visible label |
All element references are raw integer IDs (#18), surfaced inline so the LLM can never guess — it must read before it acts.
Why indented bullets
For tree-shaped data, indentation column = depth. No pointer chasing, no global indices to cross-reference, matches the training distribution (READMEs, file trees, doc outlines). Edge lists, JSON, and adjacency lists are all worse for LLM tree reading — see arXiv 2511.10234 (Lost in Serialization) for the empirics.
Snapshot-on-demand
The background wire connection ingests every server update into a local mirror. The LLM never sees the firehose — it only sees what read() / click() / fill() return. A ui.log tailing at 10 Hz is invisible until the LLM asks.
Try it
# 1. Set up venv + install (one-time)
python3 -m venv .venv
.venv/bin/pip install -e .
# 2. Launch the gallery (terminal A)
.venv/bin/python examples/gallery.py
# 3. Drive it (terminal B)
.venv/bin/python examples/smoke.py # CLI demo, prints transcript
.venv/bin/python tests/test_mcp_e2e.py # full MCP round-trip
Use from Claude Code
Add to ~/.claude.json mcpServers (or use the bundled .mcp.json if you launch Claude Code from this repo):
{
"mcpServers": {
"nicegui-bridge": {
"command": "/Users/evnchn/nicegui-llm-bridge/.venv/bin/python",
"args": ["-m", "nicegui_llm_bridge.mcp_server"]
}
}
}
Then in Claude Code: open a NiceGUI app (examples/gallery.py in another terminal), and ask Claude to drive it. Claude will call open → actions → click/fill like a screen reader would.
Architecture
NiceGUI server ──Socket.IO──> nicegui-wire (tree decode, event encode)
│
▼
ElementTree mirror
│
▼
serialize.render() → bullets
│
▼
Session (snapshot-on-demand)
│
▼
FastMCP tools (stdio)
│
▼
LLM consumer
Status
v0.0.1-alpha, YOLO-shipped 2026-06-03 ~10:30 HKT. Works against NiceGUI 3.12.x. Probed against https://nicegui.io (380 elements in 1.22 s, 15 KB YAML view, 42 actionable elements surfaced).
Known limitations:
ui.htmland arbitrary Vue components → render as opaque entries (nicegui-html#39with no inner content)ui.aggrid/ui.echart→ schema only, not data- Page navigation (multi-route apps) → not yet;
open()reconnects from scratch - Quasar client-side toggles (q-drawer / q-menu burgers) don't roundtrip the wire — they live in DOM, not the outbox
q-btncontent nested innicegui-htmllooks empty to the LLM until we surfaceinnerHTML(planned)- Wire protocol is NiceGUI 3.x specific; major-version drift will break
Credits
Wire decoding lifted from nicegui-wire. Gallery example adapted from nicegui-tui.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。