computer

computer

MCP server for AI agents to control a Mac via screen and mouse/keyboard, supporting Anthropic Claude and OpenAI for task automation.

Category
访问服务器

README

@hasna/computer

Open-source computer use for AI agents. Control your Mac with Anthropic Claude or OpenAI.

CLI + MCP Server + REST API + SDK

What it does

An AI model sees your screen (via screenshots) and controls your mouse and keyboard to complete tasks — like a remote human operator, but powered by AI.

# Tell the AI to do something on your Mac
computer run "open Safari and search for 'weather in NYC'"

# Take a screenshot
computer screenshot -o screen.png

# View past sessions
computer sessions

Features

  • Multi-provider — Anthropic (Claude computer use) or OpenAI (CUA)
  • macOS native — Uses screencapture + cliclick for zero-dependency screen control
  • MCP server — Other AI agents can use your computer as a tool
  • REST API — Integrate from any language
  • Session logging — Every action logged in SQLite, fully replayable
  • SDK — Import and use programmatically in TypeScript/Bun

Install

bun install -g @hasna/computer

Prerequisites:

  • macOS (Apple Silicon or Intel)
  • Bun runtime
  • cliclickbrew install cliclick
  • Accessibility permissions (System Settings > Privacy & Security > Accessibility)
  • An API key: ANTHROPIC_API_KEY or OPENAI_API_KEY

CLI

computer run <task>              # Run a computer use task
computer run <task> -p openai    # Use OpenAI instead of Anthropic
computer run <task> -s 30        # Limit to 30 steps
computer open <app> [options]    # Open an app deterministically via its driver
computer apps                    # List app drivers + availability
computer screenshot              # Capture current screen
computer sessions                # List past sessions
computer session <id>            # Show session details + action log
computer stats                   # Usage statistics

Apps

Beyond AI-driven tasks (computer run), computer ships deterministic app drivers that open and arrange desktop apps with zero AI in the loop — windows, tabs, pane grids, and a command per pane.

computer apps                    # List registered drivers and availability
computer open <app> [options]    # Open/orchestrate an app via its driver

Options for computer open:

Option Description
--grid RxC Split the window into R rows x C cols (panes fill row-major: left-to-right, top-to-bottom)
--tabs "spec1,spec2,..." Multiple tabs in one window, each with its own grid (e.g. "2x2,1x2,1x2")
--run <cmd> Command for the next pane in order (repeatable); with --tabs, commands flow across tabs
--all Run the single --run command in every pane
--dir <path> Working directory — every pane cds there first
--max Maximize the new window (not native fullscreen)

Examples:

# 2x2 grid, run codewith in all four panes, maximized
computer open ghostty --grid 2x2 --run "codewith" --all --max

# 2x2 grid with a different command per pane
computer open ghostty --grid 2x2 --run "htop" --run "btop" --run "vim" --run "bun dev"

# Three tabs (2x2, then two 1x2), every pane cd'd into the project
computer open ghostty --tabs "2x2,1x2,1x2" --dir ~/Workspace/myproject

Drivers:

  • ghostty — Ghostty terminal (macOS, Ghostty 1.3+). Uses Ghostty's native AppleScript dictionary for windows, tabs, and splits. Requires /Applications/Ghostty.app (or ghostty on PATH).

Drivers are app-generic: each implements available() (with a reason when unavailable, e.g. on Linux) and open(spec). New drivers register in src/apps/registry.ts.

The same surface is exposed over MCP via computer_open_app (params: app, grid, tabs, run[], all, dir, max — falls back to a plain macOS app launch for apps without a driver) and computer_list_apps.

MCP Server

Add to your Claude Code config:

{
  "mcpServers": {
    "computer": {
      "command": "computer-mcp"
    }
  }
}

HTTP mode

Shared Streamable HTTP transport for multi-agent sessions (stdio remains the default):

computer-mcp --http              # http://127.0.0.1:8806/mcp
MCP_HTTP=1 computer-mcp          # same via env
computer-mcp --http --port 9000    # override port
  • Health: GET http://127.0.0.1:8806/health{"status":"ok","name":"computer"}
  • MCP endpoint is also mounted on computer-serve at /mcp.

Available tools:

  • computer_run_task — Run a full computer use task
  • computer_screenshot — Capture the screen
  • computer_click — Click at coordinates
  • computer_type — Type text
  • computer_key — Press keys
  • computer_scroll — Scroll
  • computer_mouse_move — Move the mouse
  • computer_open_url — Open a URL
  • computer_open_app — Open an app
  • computer_screen_size — Get screen resolution
  • computer_list_sessions — List sessions
  • computer_get_session — Get session details
  • computer_stats — Usage stats

REST API

computer-serve  # Starts on port 19450
# Run a task
curl -X POST localhost:19450/run -d '{"task":"open calculator"}'

# Take a screenshot
curl localhost:19450/screenshot

# Execute a single action
curl -X POST localhost:19450/action -d '{"type":"click","point":{"x":500,"y":300}}'

# List sessions
curl localhost:19450/sessions

SDK

import { runTask, captureScreenshot, createMacDriver } from "@hasna/computer";

// Run a full task
const session = await runTask({
  task: "open Notes and create a new note",
  provider: "anthropic",
  maxSteps: 20,
  onStep: (step, response, result) => {
    console.log(`Step ${step}: ${response.action?.type}`);
  },
});

// Or control manually
const driver = createMacDriver();
const screenshot = await driver.screenshot();
const result = await driver.execute({
  type: "click",
  point: { x: 500, y: 300 },
});

How it works

  1. Screenshots your screen
  2. Sends the screenshot to the AI model (Claude or GPT)
  3. The model analyzes what's on screen and returns an action (click, type, scroll, etc.)
  4. The action is executed on your Mac
  5. A new screenshot is taken
  6. Repeat until the task is done (or max steps reached)

Providers

Provider Model Tool
Anthropic Claude Sonnet 4.5 (default) computer_20250124
OpenAI computer-use-preview CUA Responses API

Data

Sessions and action logs are stored in ~/.hasna/computer/computer.db (SQLite).

Storage Sync

Optional Postgres sync is available through package-local commands:

export HASNA_COMPUTER_DATABASE_URL=postgres://...
computer storage status
computer storage push
computer storage pull
computer storage sync

The MCP server also exposes storage_status, storage_push, storage_pull, and storage_sync.

COMPUTER_DATABASE_URL is accepted as the non-Hasna fallback database URL.

License

Apache-2.0

推荐服务器

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

官方
精选