arthur

arthur

Enables AI agents to control a headless Chromium browser through a persistent Python REPL, providing navigation, interaction, snapshotting, and media control via the Model Context Protocol.

Category
访问服务器

README

<div align="center">

Arthur

Lightweight Headless Chromium Runtime & MCP Server for AI Agents

License: MIT Python 3.10+ MCP Standard Built with uv

<p align="center"> Direct CDP WebSockets • Semantic Ref-ID Snapshots • Persistent Python REPL • FastMCP Server </p>

</div>


What is Arthur?

Arthur is a single-command headless browser runtime and Model Context Protocol (MCP) server for AI agents.

It connects directly to Chromium via Chrome DevTools Protocol (CDP) WebSockets without requiring browser extensions, virtual displays (X11/VNC), or heavy automation drivers. One command launches the MCP server, boots an isolated headless Chromium process, and provides your AI agent with full procedural browser control.

Agent / MCP Client
       │
       ▼  execute_python(code)
FastMCP Server (stdio / Streamable HTTP)
       │
       ▼
Python REPL Session (stateful memory & auto-snapshots)
       │
       ▼
Arthur Browser API (synchronous facade)
       │
       ▼  CDP WebSockets
Headless Chromium (--headless=new)

Quickstart

You don't need to clone the repository or install dependencies manually. Arthur runs instantly via uvx.

1. Local Desktop (Claude Desktop, Cursor, Goose)

Add Arthur to your MCP settings file (e.g. claude_desktop_config.json):

{
  "mcpServers": {
    "arthur": {
      "command": "uvx",
      "args": ["arthur-runtime", "mcp"]
    }
  }
}

When your AI agent calls the browser, Arthur automatically discovers local Chrome/Chromium, starts the headless browser, executes actions, and cleans up when finished.


2. Docker Container (Self-Contained Streamable HTTP)

Run Arthur in a lightweight, self-contained Debian Slim container with headless Chromium, tini PID 1 process management, and native multi-arch support (amd64 / arm64):

Run via Docker:

docker run -d \
  --name arthur \
  -p 8000:8000 \
  --shm-size=1g \
  --restart unless-stopped \
  sh7vansh/arthur:latest

Or Run via Docker Compose:

docker compose up -d

Connect Your MCP Client:

{
  "mcpServers": {
    "arthur": {
      "url": "http://localhost:8000/mcp"
    }
  }
}

3. Remote Server / Cloud (Direct Python via uvx)

To run Arthur on a remote VM, VPS, or cloud server without Docker:

Start the Server:

uvx arthur-runtime mcp --transport streamable-http --stateless --host 0.0.0.0 --port 8000

Connect Your MCP Client:

{
  "mcpServers": {
    "arthur": {
      "url": "http://YOUR_SERVER_IP:8000/mcp"
    }
  }
}

Stateless Streamable HTTP is resilient to network drops and works seamlessly behind Nginx, Cloudflare Tunnels, and AWS ALBs while keeping browser tabs and Python variables in server memory.


4. Interactive Terminal Shell (For Testing)

Test the browser directly from your terminal:

uvx arthur-runtime repl
Arthur Interactive REPL (Type 'exit()' or press Ctrl+D to exit)
Global 'browser' instance is available.
arthur> browser.navigate('https://example.com')
arthur> print(browser.snapshot())
arthur> browser.click(1)

How It Works

Arthur handles the entire browser lifecycle in a single self-contained process:

  1. Automatic Discovery: Locates installed Chrome, Chromium, Brave, or Edge on Linux, macOS, or Windows.
  2. Ephemeral Sandbox: Boots Chromium with --headless=new and an isolated temporary user-data directory.
  3. CDP WebSockets: Communicates directly over local WebSockets for low-latency element targeting and input simulation.
  4. Automatic Teardown: Gracefully shuts down the Chromium subprocess and purges temporary files when the session ends.

Python API Reference

When your AI agent uses the execute_python tool, the synchronous browser instance is pre-injected:

# Navigation & Page State
browser.navigate("https://example.com", timeout=30.0)
print(browser.snapshot())                # Semantic Ref-ID outline ([#1], [#2])
print(browser.url, browser.title)

# Interactions (Ref-ID, String Ref, or CSS Selector)
browser.click(1)                         # Click Ref-ID #1
browser.click("button.submit-btn")       # CSS selector fallback
browser.type(2, "search query", press_enter=True)
browser.select(3, "Option Value")
browser.hover(1)
browser.scroll(x=0, y=500)

# Waiting & Synchronization
browser.wait_for(1, state="visible", timeout=10.0)
browser.wait_for_url(r"^https://example\.com/dashboard", timeout=15.0)

# Page Evaluation, Forms & Extraction
result = browser.eval_js("window.innerWidth")
items = browser.extract_items("article.post", {"title": "h2", "link": "a@href"})
browser.fill_form({"Email": "test@test.com"}, submit="Sign In")
png_bytes = browser.screenshot()
text = browser.get_text(1)
attr = browser.get_attribute(1, "data-custom")

# Fast Native Media Control (Zero-DOM)
state = browser.media.status()           # HTML5 media state & player metadata
browser.media.toggle()                   # Toggle play/pause
browser.media.play()                     # Resume playback
browser.media.pause()                    # Pause playback
browser.media.seek(15.0)                 # Seek relative seconds (+15s / -10s)
browser.media.set_volume(0.8)            # Set volume level (0.0 to 1.0)

# Multi-Tab Control & Help
new_tab = browser.new_tab("https://google.com")
all_tabs = browser.tabs
active = browser.active_tab
browser.close_tab(2)
print(browser.help())                    # Built-in formatted SDK quick reference

Key Features

  • Semantic Ref-ID Snapshots: Generates compact, token-efficient accessible DOM trees with assigned numbers ([#1], [#2]), avoiding brittle XPath or long CSS selectors.
  • Fast Media Controller (browser.media): Zero-DOM media playback manipulation that penetrates open Shadow DOM roots without expensive snapshot recalculation.
  • Persistent Python REPL: State, variables, imports, and custom functions persist across agent tool calls.
  • Single-Turn Self-Healing: Automatically attaches a diagnostic DOM snapshot ([diagnostic_auto_snapshot]) and fuzzy suggestions whenever an error occurs, allowing agents to self-heal in a single turn.
  • MCP Resources & Prompts: Built-in MCP resources (arthur://docs/api, arthur://docs/workflow) and structured prompts (browser_automation, media_control) for intelligent agent onboarding.
  • Token Budgeting & Defanging: Truncates large outputs to prevent context window explosion and sanitizes tracking image beacons ([IMAGE_BLOCKED]).

Local Development

If you want to contribute or build from source:

# Clone and install dependencies
git clone https://github.com/sh7vansh/arthur.git
cd arthur
uv sync --all-extras

# Run tests
uv run pytest

# Run type checker
uv run mypy src

License

This project is licensed under the MIT License — see the LICENSE file for details.

推荐服务器

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

官方
精选