computer-use-mcp
A framework-agnostic computer-use MCP server that exposes core desktop operations (screen capture, mouse, keyboard, and file access) as standard MCP tools, enabling any MCP-compatible agent to drive a computer.
README
computer-use-mcp
A framework-agnostic computer-use Model Context Protocol (MCP) server. It exposes core desktop operations — screen capture, mouse, keyboard, and file access — as standard MCP tools, so any MCP-compatible agent framework (Claude Desktop, LangChain, AutoGen, a custom client, …) can drive a computer without being tied to a specific agent runtime.
Built on @modelcontextprotocol/sdk,
@cfworker/json-schema, and
zod, written in TypeScript with full type definitions.
Features
- Standard MCP interface — speaks MCP over stdio (
initialize,tools/list,tools/call), decoupled from any agent framework. - Core computer operations as MCP tools —
screenshot,mouse_click,mouse_double_click,mouse_move,mouse_drag,mouse_scroll,keyboard_type,key_press,read_file,write_file,list_directory. - Zod +
@cfworker/json-schema— Zod is the single source of truth for input shapes and coercion;z.toJSONSchema()derives the wire JSON Schema, and@cfworker/json-schemavalidates incoming arguments before dispatch. - TypeScript — complete type definitions throughout (
src/core/backend.ts,src/tools/base.ts, …). - Extensible — tools and the automation engine are both pluggable behind stable interfaces.
Requirements
- Node.js ≥ 18 (or Bun).
- Platform automation tools for screen/input (the default driver uses OS facilities):
- Windows: PowerShell + .NET (built in).
- Linux:
scrot(screenshot) andxdotool(mouse/keyboard). - macOS:
screencapture+ AppleScript (osascript);cliclickfor move/drag.
Install & run
bun install # or: npm install
bun start # or: npm start (runs src/index.ts via tsx)
The server reads JSON-RPC over stdio and is meant to be launched by an MCP client. Example client config:
{
"mcpServers": {
"computer-use": {
"command": "bun",
"args": ["/path/to/computer-use/src/index.ts"]
}
}
}
Architecture
src/
index.ts Entry point: wires the default backend to the server.
server.ts ComputerUseServer — MCP protocol handling (tools/list, tools/call).
schema/json-schema.ts Zod -> JSON Schema, and a @cfworker/json-schema validator factory.
core/
backend.ts ComputerUseBackend — the operation contract (the extension seam).
native-driver.ts NativeDriver — low-level screen/input primitives.
local-backend.ts LocalComputerUseBackend — filesystem + injected NativeDriver.
system-driver.ts Default per-platform NativeDriver (Windows / Linux / macOS).
pi-backend.ts PiComputerUseBackend — bridges the pi-computer-use native helper.
engines/
pi-types.ts Structural subset of the pi-computer-use backend contract.
pi-helper.ts PiHelperDriver — bridges pi-helper observe/act to NativeDriver.
robotjs.ts RobotJsDriver — bridges the robotjs package.
playwright.ts PlaywrightDriver — bridges a Playwright Page.
index.ts createAutomationEngine — selects an engine.
tools/
base.ts ToolDefinition + ToolResult types.
screenshot.ts, mouse.ts, keyboard.ts, file.ts
window.ts get_window_title — foreground window title + owning process.
pi.ts pi_observe / pi_act / pi_list_apps / pi_list_roots / pi_get_frontmost.
index.ts defaultTools (the built-in tool set) + piTools.
Request flow for a tool call
- The client sends
tools/callwitharguments. - The server validates
argumentsagainst the tool's JSON Schema using@cfworker/json-schema(defense-in-depth wire contract). Invalid input returns a clearisErrormessage. - Zod parses/coerces the arguments into a typed object (applies defaults, int coercion, …).
- The tool handler runs against the injected
ComputerUseBackend.
Extending
Add a custom tool
Create a ToolDefinition and register it:
import { z } from "zod";
import type { ToolDefinition } from "./tools/base.ts";
const myTool: ToolDefinition<{ url: string }> = {
name: "open_url",
description: "Open a URL in the default browser.",
inputSchema: z.object({ url: z.string().url() }),
async handler({ url }, { backend }) {
// ...use backend or any side-effect...
return { content: [{ type: "text", text: `Opened ${url}` }] };
},
};
// pass `tools: [...defaultTools, myTool]` to ComputerUseServer, or call server.register(myTool).
Swap the automation engine
The plugin ships a pluggable automation engine layer. Pick one via the
COMPUTER_USE_ENGINE environment variable, or construct it programmatically with
createAutomationEngine — no tool or server code changes:
| Engine | Backed by | Extra tools |
|---|---|---|
system |
OS facilities (PowerShell/.NET, scrot+xdotool, …) |
the 11 built-in tools |
pi-helper |
pi-computer-use native helper |
built-ins + pi_* semantic tools |
robotjs |
the robotjs npm package (mouse/keyboard) |
the 11 built-in tools |
playwright |
a Playwright Page (browser automation) |
the 11 built-in tools |
COMPUTER_USE_ENGINE=pi-helper bun start # use the pi-computer-use native helper
COMPUTER_USE_ENGINE=robotjs bun start # use robotjs for input
import { createAutomationEngine } from "./engines/index.ts";
import { ComputerUseServer } from "./server.ts";
// programmatic selection (e.g. to drive a Playwright page):
const { backend, tools } = await createAutomationEngine({
engine: "playwright",
playwrightPage: page, // a real Playwright Page
});
const server = new ComputerUseServer({ backend, tools });
Engines degrade gracefully: if an optional package (e.g. robotjs,
@injaneity/pi-computer-use) is not installed, the engine throws a clear
UnsupportedOperationError describing how to enable it.
Bridge to pi-computer-use
The pi-helper engine maps our operations onto the pi-computer-use
ComputerUsePlatformBackend:
- Screen capture →
observe({ includeImage: true }); mouse/keyboard →act(...)with coordinate targets and the baselinelookId. - On top of the 11 built-ins it exposes the helper's richer semantic tools:
pi_observe(screen + accessibility outline),pi_list_apps,pi_list_roots,pi_get_frontmost, andpi_act(perform aclick/typeText/keypress/scroll/drag/moveMousetargeted by an element ref frompi_observeor by coordinates).
The bridge depends only on a structural subset of the pi backend
(src/engines/pi-types.ts), so it does not pull in the pi package's native build
or peer dependencies. Provide a custom loader if your pi backend lives elsewhere:
createAutomationEngine({
engine: "pi-helper",
piBackendLoader: () => myPiPlatformBackend,
});
Add a custom tool
Create a ToolDefinition and register it:
import { z } from "zod";
import type { ToolDefinition } from "./tools/base.ts";
const myTool: ToolDefinition<{ url: string }> = {
name: "open_url",
description: "Open a URL in the default browser.",
inputSchema: z.object({ url: z.string().url() }),
async handler({ url }, { backend }) {
// ...use backend or any side-effect...
return { content: [{ type: "text", text: `Opened ${url}` }] };
},
};
// pass `tools: [...defaultTools, myTool]` to ComputerUseServer, or call server.register(myTool).
Notes & limitations
- The default system driver is a dependency-light, best-effort reference implementation. For production
input automation on macOS (scroll/middle-click) or locked-down environments, provide a custom
NativeDriver. - Screen capture and input require the OS to grant the process screen-recording / accessibility permissions where applicable.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.