Skip to main content
Glama

Web2Actions

将网站变成你的 AI 智能体可以使用的 MCP 服务器——无需 API。

Web2Actions 会观察网站的浏览器流量,逆向工程出网站真实的网络端点,并将它们打包成一组干净、命名的工具,供你的 AI 智能体通过 Model Context Protocol (MCP) 调用。无需公共 API。

工作原理

  1. 捕获 — 在网站上登录一次;浏览器流量会被记录。

  2. 生成 — 一个 LLM 将捕获的流量转换为连接器定义:干净、命名的工具,包含输入、输出和风险标签。

  3. 验证 — 每个工具都会针对实时网站进行冒烟测试。

  4. 服务 — 验证后的连接器作为标准 MCP 服务器暴露。

捕获是人工驱动的,而非自动的。 我们不会猜测每个按钮或替你点击网站。一个真实的浏览器会在你的机器上打开;你 登录并执行你想要变成工具的操作,我们记录这些流量。托管产品也遵循同样的理念——它是一个由你驱动的弹出式浏览器。CLI 只是为你运行那个浏览器。

Related MCP server: Clarity MCP Server

安装

pip install -e .

命令

每个命令都是 web2actions <command> [options]。

model — 选择你的 LLM 提供商和模型(持久化)

web2actions model                       # show current
web2actions model google/gemini-2.5-flash   # set default model (persisted)
web2actions model --provider openrouter # set default provider
web2actions model --alias sonnet=anthropic/claude-sonnet-4  # alias
web2actions model --aliases             # list aliases

capture — 记录网站的流量

打开浏览器到该 URL,记录你登录和点击时产生的网络流量,然后写出一个 JSON 转储。

# Open the site; log in and click around manually; press Enter when done.
web2actions capture https://app.example.com

# Filter out analytics/static noise and save to a chosen file.
web2actions capture https://app.example.com --filter -o dump.json

# Automate a simple form login (fill + submit), then continue capturing.
web2actions capture https://app.example.com --login \
  --username you@example.com --password "..." \
  --username-selector "#username" --password-selector "#password" \
  --submit-selector "#submit-btn" --success-indicator "#dashboard"

选项:--login、--username、--password、--username-selector、--password-selector、--submit-selector、--success-indicator、--filter、--output/-o。

generate — 将捕获的流量转换为连接器定义

web2actions generate dump.json --model claude-sonnet-4 -o connector.json

选项:--model(或 WEB2ACTIONS_MODEL 环境变量)、--output/-o。

validate — 根据模式检查连接器

web2actions validate connector.json
# -> VALID

serve — 将连接器作为 MCP 服务器暴露(stdio)

web2actions serve connector.json

通过 stdio 将连接器连接到你的 AI 智能体的 MCP 客户端。

端到端示例

web2actions capture https://example.com --filter -o dump.json
web2actions generate dump.json --model claude-sonnet-4 -o connector.json
web2actions validate connector.json
web2actions serve connector.json

从现有示例开始(无需捕获)

web2actions validate connector-spec/examples/simple-crm.json
web2actions serve connector-spec/examples/simple-crm.json

自带 LLM(BYOK)

Web2Actions 使用 litellm,它通过一个 OpenAI 兼容接口连接到 100+ 提供商。你可以通过简单的命令选择提供商和模型——无需修改代码,并且该选择会在后续运行中记住。

支持的提供商

litellm 支持 100+ 提供商,包括 OpenAI、Anthropic、Google Gemini、OpenRouter、DeepSeek、Groq、xAI、Mistral、OpenAI 兼容的本地服务器(Ollama / llama.cpp / vLLM)、Bedrock、Azure 等。

每个提供商读取其标准的 API 密钥环境变量(例如 OPENAI_API_KEY、ANTHROPIC_API_KEY、GEMINI_API_KEY、OPENROUTER_API_KEY、DEEPSEEK_API_KEY、GROQ_API_KEY、XAI_API_KEY),或者对于本地服务器,根本不需要密钥。

用简单命令设置默认模型

# Pick a provider + model once; it is remembered (saved to ~/.web2actions/config.toml)
web2actions model openai/gpt-4o-mini
web2actions model anthropic/claude-sonnet-4
web2actions model gemini/gemini-2.5-flash
web2actions model openrouter/anthropic/claude-sonnet-4
web2actions model deepseek/deepseek-chat

# Show the current model
web2actions model

# Set a default provider
web2actions model --provider openrouter

# Add a short alias, then use it anywhere
web2actions model --alias sonnet=anthropic/claude-sonnet-4
web2actions generate dump.json --model sonnet

# List your aliases
web2actions model --aliases

设置后,generate 会自动使用该模型:

web2actions model google/gemini-2.5-flash
export GEMINI_API_KEY=...            # only needed the first time, per provider
web2actions generate dump.json       # uses gemini-2.5-flash

每次运行覆盖

传递 --model 以在单个命令中使用不同的提供商/模型,或设置 WEB2ACTIONS_MODEL 环境变量。优先级:--model > WEB2ACTIONS_MODEL > 已保存的配置。

web2actions generate dump.json --model openai/gpt-4o-mini

如果未设置密钥

generate 会优雅地失败,并告诉你需要设置哪个密钥——它绝不会以原始堆栈跟踪崩溃。

仓库布局

  • connector-spec/ — 连接器定义模式 + 验证器

  • capture/ — 浏览器会话 + 流量记录 + 噪声过滤

  • generate/ — LLM 提取(廉价路径)+ 沙盒回退

  • validate/ — 实时工具冒烟测试 + 风险标记

  • mcp-runtime/ — 提供任何连接器的共享 MCP 服务器

  • cli/ — web2actions 命令行包装器

许可证

Apache-2.0。基于开源 CLI-Anything / CLI-Anything-Web 项目构建。

Related MCP Connectors

Related MCP Servers