Skip to main content

Computer Use Protocol

Python SDK for the Computer Use Protocol


PyPI MIT License Spec

The official Python SDK for the Computer Use Protocol (CUP) — a universal protocol for AI agents to perceive and interact with any desktop UI. This package provides tree capture, action execution, semantic search, and an MCP server for AI agent integration.

Installation

pip install computeruseprotocol

# Linux additionally requires system packages
sudo apt install python3-gi gir1.2-atspi-2.0

# Web adapter (Chrome DevTools Protocol, works on any OS)
pip install computeruseprotocol[web]

# Screenshot support (mss; not needed on macOS)
pip install computeruseprotocol[screenshot]

# MCP server for AI agent integration
pip install computeruseprotocol[mcp]

Quick start

import cup

# Snapshot the foreground window — optimized for LLM context windows
screen = cup.snapshot()
print(screen)

# All windows
screen = cup.snapshot("full")

# Structured CUP envelope (dict) instead of compact text
envelope = cup.snapshot_raw()

Output:

# CUP 0.1.0 | windows | 2560x1440
# app: Spotify
# 63 nodes (280 before pruning)

[e0] win "Spotify" 120,40 1680x1020
  [e1] doc "Spotify" 120,40 1680x1020
    [e2] btn "Back" 132,52 32x32 [clk]
    [e3] btn "Forward" 170,52 32x32 {dis} [clk]
    [e7] nav "Main" 120,88 240x972
      [e8] lnk "Home" 132,100 216x40 {sel} [clk]
      [e9] lnk "Search" 132,148 216x40 [clk]

CLI

# Print the foreground window tree (default)
python -m cup

# Filter by app name
python -m cup --scope full --app Discord

# Save JSON envelope to file
python -m cup --json-out tree.json

# Capture from Chrome via CDP
python -m cup --platform web --cdp-port 9222

# Include diagnostics (timing, role distribution, sizes)
python -m cup --verbose

Platform support

Platform Adapter Tree Capture Actions
Windows UIA COM (comtypes) Stable Stable
macOS AXUIElement (pyobjc) Stable Stable
Linux AT-SPI2 (PyGObject) Stable Stable
Web Chrome DevTools Protocol Stable Stable
Android Planned Planned
iOS Planned Planned

CUP auto-detects your platform. Platform-specific dependencies (comtypes on Windows, pyobjc on macOS) are installed automatically.

Architecture

cup/
├── __init__.py                 # Public API: snapshot, action, find, ...
├── __main__.py                 # CLI entry point
├── _base.py                    # Abstract PlatformAdapter interface
├── _router.py                  # Platform detection & adapter dispatch
├── format.py                   # Envelope builder, compact serializer, tree pruning
├── search.py                   # Semantic element search with fuzzy matching
├── actions/                    # Action execution layer
│   ├── executor.py             # ActionExecutor orchestrator
│   ├── _handler.py             # Abstract ActionHandler interface
│   ├── _keys.py                # Key name mapping utilities
│   ├── _windows.py             # Windows UIA actions
│   ├── _web.py                 # Chrome CDP actions
│   ├── _macos.py               # macOS actions (Quartz CGEvents + AX)
│   └── _linux.py               # Linux actions (XTest + AT-SPI2)
├── platforms/                  # Platform-specific tree capture
│   ├── windows.py              # Windows UIA adapter
│   ├── macos.py                # macOS AXUIElement adapter
│   ├── linux.py                # Linux AT-SPI2 adapter
│   └── web.py                  # Chrome CDP adapter
└── mcp/                        # MCP server integration
    ├── __main__.py             # python -m cup.mcp entry point
    └── server.py               # MCP protocol server

Adding a new platform means implementing PlatformAdapter — see cup/_base.py for the interface.

MCP Server

CUP ships an MCP server for integration with AI agents (Claude, Copilot, etc.).

# Run directly
cup-mcp

# Or via Python
python -m cup.mcp

Add to your MCP client config (e.g., .mcp.json for Claude Code):

{
    "mcpServers": {
        "cup": {
            "command": "cup-mcp",
            "args": []
        }
    }
}

Tools: snapshot, snapshot_app, overview, snapshot_desktop, find, action, open_app, screenshot

Contributing

CUP is in early development (v0.1.0). Contributions welcome — especially:

  • Android adapter (cup/platforms/android.py)
  • iOS adapter (cup/platforms/ios.py)
  • Tests — especially cross-platform integration tests
  • Documentation and examples

For protocol or schema changes, please contribute to computeruseprotocol.

See CONTRIBUTING.md for setup instructions and guidelines.

Documentation

License

MIT

Metadata

Release files for computeruseprotocol 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for computeruseprotocol 0.1.0
File Size Uploaded
computeruseprotocol-0.1.0.tar.gz 227.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for computeruseprotocol 0.1.0
File Interpreter ABI Platform
computeruseprotocol-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 323.4 kB

Release files / computeruseprotocol-0.1.0.tar.gz

Download URL computeruseprotocol-0.1.0.tar.gz
Size 227.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0e827cde128468e1194e0b1c0f72b263311687250ceebf96c601093eb3dcf32d
BLAKE2b-256 checksum
How to use checksums
ba00d7341c42e9ddc8fcc2e215445ed63ba9611ac2ba2faf3fecc80fcfa39469
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.

Transparency log

Release files / computeruseprotocol-0.1.0-py3-none-any.whl

Download URL computeruseprotocol-0.1.0-py3-none-any.whl
Size 96.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cda1aea98e77830b129a0b8c5bd56a6a78b8488a3a16c29f378658d32b3b855
BLAKE2b-256 checksum
How to use checksums
c5020d2c33a78052be91456b7eb8d98ba0245dd634283c15e5ef3132448eecf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page