使用说明
CUA MCP服务器
一 能动性 模型上下文协议(MCP)服务器 CUA云 -将桌面自动化任务委托给基于视觉的自主代理。图像永远不会离开服务器;只返回文本摘要。
生产URL: https://cua-mcp-server.vercel.app/mcp
CUA是什么?
CUA(计算机使用代理) 提供AI代理可以控制的基于云的虚拟机沙盒。此MCP服务器通过干净的任务授权API展示CUA的功能:
- 创建和管理虚拟机 (Linux、Windows、macOS)
- 委派任务 -“打开Chrome浏览器并导航到google.com”
- 获取文本摘要 -上下文窗口中没有图像
- 查询屏幕状态 -基于视觉的描述,不采取行动
建筑
Claude Code (Orchestrator)
│
│ run_task("Open Chrome and go to google.com")
▼
┌─────────────────────────────────────────────────────────────┐
│ CUA MCP Server (Agentic) │
│ ┌───────────────────────────────────────────────────────┐ │
│ │ Internal Agent Loop │ │
│ │ 1. screenshot() → CUA sandbox │ │
│ │ 2. screenshot → Claude API (computer_use tool) │ │
│ │ 3. Claude returns: click(x,y) / type("text") / done │ │
│ │ 4. Execute action on sandbox │ │
│ │ 5. Loop until complete │ │
│ └───────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
{ success: true, summary: "Opened Chrome...", steps_taken: 5 }
(TEXT ONLY - no images)
项目结构
api/mcp.ts # MCP protocol handler
lib/
├── agent/ # Modular agent architecture
│ ├── index.ts # Public exports
│ ├── types.ts # Type definitions
│ ├── config.ts # Model configurations
│ ├── validation.ts # Coordinate validation helpers
│ ├── execute.ts # Main agent loop
│ ├── describe.ts # Screen description
│ ├── progress.ts # Progress tracking
│ ├── utils.ts # Utilities (sleep, generateTaskId)
│ └── actions/ # Action handler registry (16 handlers)
├── cua-client.ts # CUA Cloud API client
└── tool-schemas.ts # MCP tool definitions
可用工具(共9个)
沙盒管理(5个工具)
| 工具 | 说明 |
|---|---|
list_sandboxes |
列出所有CUA云沙盒及其当前状态 |
get_sandbox |
获取特定沙箱的详细信息,包括API URL |
start_sandbox |
启动已停止的沙盒 |
stop_sandbox |
停止正在运行的沙盒 |
restart_sandbox |
重新启动沙盒 |
注: 通过创建和删除沙盒 CUA仪表板 -云API不公开这些操作。
代理工具(4个工具)
| 工具 | 说明 |
|---|---|
describe_screen |
使用视觉AI获取当前屏幕状态的文本描述。未采取任何行动。 |
run_task |
自主执行计算机任务。立即返回task_id进行轮询。 |
get_task_progress |
轮询正在运行的任务的进度。返回当前步骤、上次操作和推理。 |
get_task_history |
按ID检索以前执行的任务的结果 |
快速开始
1.获取CUA API密钥
- 首选 cua.ai/签名
- 引导到 仪表板>API键>新的API键
- 复制API密钥(以开头
sk_cua-api01_...)
2.配置克劳德代码
添加到您的 ~/.claude.json:
{
"mcpServers": {
"cua": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://cua-mcp-server.vercel.app/mcp"]
}
}
}
3.使用克劳德代码
You: "List my CUA sandboxes"
Claude: [Uses list_sandboxes tool]
You: "Start my-sandbox"
Claude: [Uses start_sandbox tool]
You: "Open Firefox and go to google.com on my-sandbox"
Claude: [Uses run_task with task="Open Firefox and navigate to google.com"]
→ Returns: { success: true, summary: "Opened Firefox, navigated to google.com", steps_taken: 4 }
You: "What's currently on the screen?"
Claude: [Uses describe_screen tool]
→ Returns: { description: "Firefox browser showing Google homepage with search box..." }
使用示例
自动化Web任务
You: "On my-sandbox, open Chrome, go to github.com, and search for 'mcp server'"
Claude uses run_task:
- task: "Open Chrome browser, navigate to github.com, find the search box, type 'mcp server' and press Enter"
- Returns summary of what happened (no screenshots in your context)
检查屏幕状态
You: "What's on the screen right now?"
Claude uses describe_screen:
- focus: "ui" (or "text" or "full")
- Returns text description of UI elements, buttons, text content
提出具体问题
You: "Is there a login button visible?"
Claude uses describe_screen:
- question: "Is there a login button visible?"
- Returns: "Yes, there is a blue 'Sign In' button in the top right corner..."
自我寄宿
先决条件
- Vercel帐户与Pro计划(800秒功能超时)
- Vercel Blob存储
- 无烟煤API键
部署您自己的实例
# Clone the repository
git clone https://github.com/anthropics/cua-mcp-server.git
cd cua-mcp-server
# Install dependencies
npm install
# Deploy to Vercel
vercel --prod
环境变量
| 变量 | 描述 | 必填 |
|---|---|---|
CUA_API_KEY |
您的CUA Cloud API密钥 | 是 |
ANTHROPIC_API_KEY |
用于视觉处理的Anthropic API密钥 | 是 |
BLOB_READ_WRITE_TOKEN |
Vercel Blob令牌(自动添加) | 是 |
CUA_API_BASE |
自定义API基本URL(默认值:https://api.cua.ai) | 没有 |
CUA_MODEL |
要使用的模型: claude-opus-4-5 (默认)或 claude-sonnet-4-5 |
没有 |
设置Vercel Blob
- 转到您的Vercel项目控制面板
- 引导到 存储 → 创建 → 二进制大对象
- 这
BLOB_READ_WRITE_TOKEN将自动添加
通过API密钥请求
如果您不想在服务器上存储CUA API密钥:
{
"mcpServers": {
"cua": {
"command": "npx",
"args": [
"-y", "mcp-remote",
"https://your-deployment.vercel.app/mcp",
"--header", "X-CUA-API-Key: sk_cua-api01_your-key-here"
]
}
}
}
API 参考
MCP端点
网址: POST /mcp
内容类型: application/json
示例:运行任务
{
"jsonrpc": "2.0",
"method": "tools/call",
"id": 1,
"params": {
"name": "run_task",
"arguments": {
"sandbox_name": "s-linux-abc123",
"task": "Open Firefox and navigate to google.com",
"max_steps": 30,
"timeout_seconds": 120
}
}
}
答复:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [{
"type": "text",
"text": "{\"task_id\":\"task_123...\",\"success\":true,\"summary\":\"Opened Firefox, navigated to google.com\",\"steps_taken\":4,\"duration_ms\":8500}"
}]
}
}
示例:描述屏幕
{
"jsonrpc": "2.0",
"method": "tools/call",
"id": 2,
"params": {
"name": "describe_screen",
"arguments": {
"sandbox_name": "s-linux-abc123",
"focus": "ui",
"question": "Is there a search box visible?"
}
}
}
模型支撑
| 模型 | 环境变量 | 工具版本 | 功能 |
|---|---|---|---|
| 克劳德作品4.5(默认) | CUA_MODEL=claude-opus-4-5 |
computer_20251124 |
变焦支持,精度更高 |
| 克劳德·十四行诗4.5 | CUA_MODEL=claude-sonnet-4-5 |
computer_20250124 |
更快、更低的成本 |
支持的计算机操作
代理可以自主执行以下操作:
UI操作:
screenshot-捕获当前屏幕left_click,right_click,double_click,triple_click,middle_click-鼠标点击坐标mouse_move-将光标移动到坐标left_click_drag-从起点坐标到终点坐标单击并拖动left_mouse_down,left_mouse_up-按下/松开鼠标按钮scroll-向上/向下/向左/向右滚动wait-暂停执行zoom-以全分辨率查看特定屏幕区域(仅限Opus 4.5,如果没有坐标,默认为居中)
键盘:
type-键入文本key-按键或组合键(例如“ctrl+c”)hold_key-按住修饰键(下一步操作后自动释放)
约束条件
| 约束 | 值 |
|---|---|
| 功能超时 | 800秒(Vercel Pro) |
| 每项任务的最大步数 | 100 |
| 默认步数 | 100 |
| 默认超时 | 750秒 |
| 任务历史TTL | 24小时 |
| 显示分辨率 | 动态(默认1024x768) |
沙盒类型
| 操作系统 | 大小 | CPU | RAM | 用例 |
|---|---|---|---|---|
| Linux | 小型 | 2 | 4GB | 开发、测试 |
| Linux | 中等 | 4 | 8GB | 构建任务,CI/CD |
| Linux | 大型 | 8 | 16GB | 繁重的工作负载 |
| Windows | 小 | 2 | 4GB | 基本Windows应用程序 |
| Windows | 中 | 4 | 8GB | Office,开发 |
| Windows | 大 | 8 | 16GB | 企业应用程序 |
| macOS | 小型 | 2 | 4GB | iOS开发 |
| macOS | 中等 | 4 | 8GB | Xcode版本 |
| macOS | 大 | 8 | 16GB | 大量编译 |
区域
north-america-美国东部(美国用户延迟最低)europe-欧盟西部asia-亚太地区
故障排除
“需要CUA API密钥”
集 CUA_API_KEY Vercel或pass via中的环境变量 X-CUA-API-Key 头球
“未配置ANTHROPIC_API_KEY”
服务器需要用于视觉处理的Anthropic API密钥。将其添加到Vercel环境变量中。
任务超时
- 默认超时为750秒
- 降低任务复杂性或分解为更小的步骤
- 检查沙盒是否响应
describe_screen
任务超过最大步数
- 默认值为100步(最多100步)
- 将复杂任务分解为更小的子任务
- 使用更具体的任务描述
资源
许可证
麻省理工学院