Local AI Agents on Mac: How MCP and Cua Driver Work

Diagram of an agent harness checking scope, MCP and Cua Driver delivering a request, and the macOS application returning evidence for result verification.

A developer’s guide to tool discovery, local execution, macOS permissions, background input, and reliable verification.

Research checked: 5 December 2026. This article examines public documentation and specific open-source revisions. The code examples marked “illustrative” are original teaching examples. They are not a complete driver, a tested integration with your Mac, or a description of unpublished ChatGPT internals.

Installing a computer-control driver does not, by itself, connect a conversation to your Mac. A working agent needs an unbroken path from a model’s proposed action to software that can execute that action on the intended computer—and a return path that tells the agent what actually happened.

That distinction explains a frustrating experience: an assistant recognizes a plugin’s name but cannot inspect your Safari window or click a button. The missing component may be tool exposure in the host, a disconnected local process, an incompatible transport, or an operating-system permission. These are different failures, and each requires a different fix.

The useful question is therefore precise: which process receives the request, which desktop does it control, and what evidence proves the requested result? The sections below trace that path through MCP, OpenAI’s public Codex implementation, Cua Driver’s Rust code, and Apple’s APIs.

In this guide: Architecture · MCP messages · Cua source code · Python boundary · Verification · Acceptance tests

1. The execution path has several independent boundaries

Think of a Mac-control agent as cooperating components, each with a separate responsibility:

ComponentResponsibility and evidence
ModelRole: interpret the goal and propose a next step. Evidence: a valid proposal grounded in the latest observation.
Host or agent harnessRole: maintain the task, expose tools, check policy, and dispatch calls. Evidence: the intended tool is available and its invocation is admitted.
MCP client and serverRole: exchange structured tool definitions, requests, and results. Evidence: successful discovery and a representative tool call.
Local driver runtimeRole: translate an observation or action into platform operations. Evidence: a response identifying the exact target and outcome.
macOS and the applicationRole: permit capture/input and apply supported actions. Evidence: a fresh observation or application-owned result.

Cua describes its driver as the desktop interaction layer; the harness runs the model and agent loop. The operating system still determines what the responsible process can capture or control. Those responsibilities can run in different processes and, in some designs, on different computers. Cua architecture.

For example, a remote coordinator can ask a local executor to inspect a Mac window. Conversely, a local chat application can use a cloud browser whose cookies, tabs, and desktop are entirely separate from Safari on that Mac. The location of the chat interface does not identify the location of execution. A successful screenshot must name the environment it came from before it becomes useful evidence.

2. Why a discovered tool may still be unavailable to a conversation

There is actual host code behind this distinction. In OpenAI’s public Codex repository, append_mcp_tools in mcp_tool_exposure.rs filters discovered tools, prepares their handlers, and assigns exposure such as Direct, Deferred, or Hidden. A server can advertise a capability without that capability becoming directly callable in every context. Pinned Codex source.

A separate ToolFilter::allows implementation checks enabled and disabled tool lists. The public code also retains the original server tool identity separately from the normalized name exposed to the model. This matters when debugging: a model-facing name and the name sent in an MCP tools/call request need not be identical. Tool filtering and identities.

Invocation has another boundary. Codex’s MCP call path prepares an invocation, checks whether execution may proceed, and revalidates the grant before execution. Correctly shaped JSON is therefore only an input to an authorization decision. Invocation and admission code.

These are inspectable examples of how a host works. They do not prove that every internal ChatGPT service uses the same implementation. For a particular conversation, the practical diagnostic is to inspect its available tools and make an authorized, read-only call. Recognizing a plugin name is weaker evidence than successfully reading the intended window.

3. What MCP sends—and the protocol-version detail that tutorials miss

MCP supplies a protocol for exchanging capabilities and invoking tools. It does not contain a universal mouse driver, choose an AI model, or grant Accessibility permission.

With stdio, the client launches a server process and exchanges newline-delimited JSON-RPC messages through its standard streams. Diagnostic output belongs on standard error; a startup banner written to standard output can corrupt the protocol channel. Starting a program in a terminal does not automatically connect its streams to another application. MCP stdio specification.

Legacy and modern MCP use different opening exchanges

Many examples show initialize, then notifications/initialized, followed by tools/list and tools/call. That describes the legacy lifecycle used by revisions through 2025-11-25.

Revision 2026-07-28 instead carries protocol version and client capabilities on each request. A client may first call server/discover, then issue discovery or tool requests without the old initialization handshake. Compatibility must be checked against the running client and server, not inferred from the publication date of a tutorial. Versioning and compatibility.

The following is an original transport-independent message-body example for the modern revision. The example host asks for tool definitions. The JSON is formatted across multiple lines for readability; a stdio client serializes each complete message onto one line and appends a newline:

{
  "jsonrpc": "2.0",
  "id": "library-list-01",
  "method": "tools/list",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientCapabilities": {},
      "io.modelcontextprotocol/clientInfo": {
        "name": "ingoampt-learning-host",
        "version": "0.1.0"
      }
    }
  }
}

id correlates the response with this request. method selects a protocol operation. The namespaced metadata describes the protocol and capabilities for this request. clientInfo is recommended identity metadata, not a password or proof of authorization. A completed final result uses resultType: "complete"; a request needing additional input can return resultType: "input_required". Compatibility rules treat an older response without that field as complete. Base protocol.

After discovering a compatible Cua tool, a read-only call can use this shape. The process and window numbers are invented examples; real values must come from current window enumeration:

{
  "jsonrpc": "2.0",
  "id": "window-read-02",
  "method": "tools/call",
  "params": {
    "name": "get_window_state",
    "arguments": {
      "pid": 421,
      "window_id": 83,
      "include_screenshot": true
    },
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientCapabilities": {}
    }
  }
}

The tool name and these argument fields are present in the inspected Cua schema. They request an observation; the driver still has to resolve the target and obtain it. Cua window-state schema.

If the message is carried over modern Streamable HTTP, its JSON body is only part of the implementation. For the example tool call, these are the relevant message and transport headers:

Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: get_window_state

The protocol version, method, and tool name in the headers must agree with the JSON body. Authentication and revision-specific response/cancellation handling remain separate requirements. These headers describe a modern HTTP connection generally; they do not upgrade a legacy endpoint. Streamable HTTP specification.

The implementation may deliberately use an older revision

The inspected Cua revision supports modern 2026-07-28 over stdio, alongside a legacy 2025-06-18 initialization path. Its authenticated loopback HTTP endpoint remains legacy and rejects modern discovery. OpenAI’s public Codex protocol-mode code also contains distinct legacy, modern, and local-discovery modes. “Latest specification” and “protocol used by this connection” are separate facts. Cua protocol contract · Codex protocol modes.

4. Local execution, remote MCP, and a tunnel solve different problems

OpenAI’s current desktop-only plugin documentation describes local-execution requirements and a local MCP launch command. It also distinguishes locally running threads and public submission eligibility. A packaging flag describes a requirement; it does not create an executor in a thread that lacks one. Desktop-only plugins.

The current MCP configuration guide describes shared configuration for clients using the same Codex host, while ChatGPT web uses installed remote plugin tools and does not read local Codex configuration files. Separately, eligible Work Cloud and dot configurations can coordinate permitted tools on a connected local computer. Availability and connection state still need checking in the actual context. MCP configuration · Local computer access.

A network address adds another distinction. 127.0.0.1 refers to the machine making the connection. A remote host cannot reach your Mac’s loopback service simply because you supply that address.

OpenAI’s Secure MCP Tunnel supplies a supported private request path: a client inside the private network establishes outbound HTTPS connectivity, retrieves work, forwards requests locally, and returns responses. Its runtime key, tunnel access, workspace association, and custom-MCP permissions remain separate requirements. This can solve reachability; it does not add a screenshot function to a server or grant that server macOS permission. Secure MCP Tunnel.

5. Follow the request into Cua Driver’s macOS implementation

For this article, the Cua source was inspected at commit 0b7a14ae514900f65eae7da871795c2e09a86823. Pinning a revision makes the explanation reproducible even when the main branch changes.

The MCP entry point can run a direct runtime or proxy to a daemon. The macOS arrangement normally uses the CuaDriver.app daemon, giving desktop operations a stable application identity. The proxy checks reachability and compatibility before forwarding work, and manages connection-owned state. An installed app can remain on disk while the request path into it is disconnected. Entry point · Daemon proxy.

Permissions are checked by the responsible process

The permission module checks Accessibility with AXIsProcessTrusted() and screen capture with CGPreflightScreenCaptureAccess(). The source documents why an earlier “the window list is nonempty” heuristic was unsuitable: enumerating window information does not establish permission to capture its pixels. A developer should check the actual permission needed for the operation. Permission probes.

This gives a useful debugging sequence. First prove that the request reaches the intended runtime. Then inspect that runtime’s permission state. Granting more permissions to an unrelated terminal or app cannot repair missing tool exposure upstream.

A window observation combines semantics and pixels

Accessibility provides structured controls: roles, labels, values, supported actions, bounds, and relationships. A screenshot provides visual information that those controls may omit, especially in custom-rendered interfaces. The two forms of observation can disagree, so the agent needs to understand both their scope and their limitations.

In Cua, get_window_state exposes an exact process/window target, snapshot identifiers, optional screenshots, and bounded tree reads. Its schema also distinguishes absent windows, ownership mismatches, and degraded observations. An empty tree is not a license to invent controls or switch windows. Observation implementation.

Screenshot capture is a separate pipeline

Cua’s capture implementation uses a ScreenCaptureKit window filter and SCScreenshotManager. Its bounded warm cache reuses capture configuration, not old screenshot frames. It also rechecks window identity around capture, because a target can change during an asynchronous operation. Capture implementation.

Apple’s sample demonstrates choosing capture content, configuring frame dimensions, and inspecting frame status and scaling metadata. These details explain why a screenshot must carry its dimensions and coordinate reference. A cropped or resized image is not interchangeable with native screen coordinates. Apple capture sample.

6. Coordinates and element tokens protect different kinds of targeting

Suppose a model sees a 1,200-pixel-wide preview of a 2,400-pixel-wide capture. A horizontal coordinate of 300 in that preview maps to 600 in the original capture before accounting for any crop or window offset. Sending 300 straight to a native input API can hit the wrong control.

This original helper illustrates a simple scale-and-offset transform. It assumes an unrotated, unletterboxed image and an origin already expressed in the destination coordinate system:

def map_point(x, y, preview_size, target_size, target_origin):
    pw, ph = preview_size
    tw, th = target_size
    ox, oy = target_origin
    if min(pw, ph, tw, th) <= 0:
        raise ValueError("Invalid dimensions")
    if not (0 <= x < pw and 0 <= y < ph):
        raise ValueError("Point is outside the observation")
    return ox + x * tw / pw, oy + y * th / ph

The checks reject unusable dimensions and points outside the observation. The multiplication restores scale; the addition places the result in the target frame. A production adapter must also handle crop rectangles, display scaling, axis conventions, and window movement. If a driver already accepts screenshot-relative coordinates, let that driver perform its documented mapping rather than applying a second transform.

Semantic targets have a different stale-state problem. Imagine “Save” is row 17 in one accessibility snapshot. A dialog appears and changes the tree. Row 17 may now identify another control. Cua’s element-token code pairs an element index with a snapshot identifier, and its observation contract invalidates previous tokens when the same session refreshes that window’s tree. Element tokens.

A token associates the action with evidence. It does not freeze the application. The executor must still check relevant live state immediately before execution. Pixel capture identifiers and accessibility element tokens also serve different purposes; they should not be treated as interchangeable handles.

7. Background control requires input routing, not just another cursor

There are several action routes: request a supported Accessibility action, send targeted pixel input, operate a supported browser through its DOM interface, or bring a window to the foreground. Each route has different evidence and side effects. Cua reports distinctions such as confirmed, unverifiable, suspected no-op, partial, or refused outcomes. Action routing and effects.

The macOS source shows why background input is substantial engineering. input/skylight.rs resolves private event-routing symbols. input/appkit_activation.rs manages temporary application-local activation state for specific toolkits. These operations are separate from drawing the agent’s cursor overlay. Private platform interfaces and toolkit-specific behavior also make compatibility something to verify, rather than a universal promise. Event routing · Activation handling.

The user’s requirement—“let me work in Chrome while the agent uses Safari or Xcode”—therefore needs explicit acceptance conditions: no agent-caused foreground switch or physical-pointer displacement, no agent keystrokes entering the human’s document, and the intended change visible in the approved target. If background delivery is unsupported, switching to foreground input violates that requirement unless the user approves the change.

Cua session labels do not create separate operating-system desktops. Its documented sessions share the screen, keyboard, and focus, with native input admitted one action at a time. Simultaneous use therefore depends on the supported action route and the observed behavior of the target application. Sessions and runtime ownership.

Cua’s current platform matrix distinguishes Chromium browser automation from Safari’s native Accessibility/pixel route. It also lists limits for some background gestures and app states. A connected Chrome browser tool is not evidence that Safari or Xcode is controllable through that same tool. Platform support.

8. Put the approved scope in runtime code

A prompt can describe a boundary, but enforcement needs code in the component that executes requests. The following original, runnable Python 3.10+ example illustrates a deliberately small boundary for read-only inspection. A trusted host supplies the approved target; the model cannot replace it by adding a process ID or window ID:

from dataclasses import dataclass

@dataclass(frozen=True)
class WindowGrant:
    pid: int
    window_id: int

def prepare_inspection(proposal: dict, grant: WindowGrant | None):
    if grant is None or min(grant.pid, grant.window_id) <= 0:
        raise PermissionError("No valid window grant")
    if set(proposal) != {"tool"}:
        raise PermissionError("Unexpected model-controlled fields")
    if proposal["tool"] != "inspect_approved_window":
        raise PermissionError("This adapter only permits inspection")
    return {
        "name": "get_window_state",
        "arguments": {
            "pid": grant.pid,
            "window_id": grant.window_id,
            "include_screenshot": True,
        },
    }

The immutable object represents a target already selected through trusted host UI. The exact-key check rejects extra model-controlled arguments. The tool allowlist limits the operation. The final dictionary is an invocation description, not execution itself.

This example deliberately leaves several responsibilities to the surrounding application: validating the incoming object’s schema, checking that the grant is current, checking process/window identity, handling revocation, constructing the correct MCP envelope, and calling the transport. Numeric IDs can be reused after a process or window closes, so a production grant needs stronger identity validation. Returning this dictionary does not create a security boundary if the host also exposes an unrestricted alternative route that can bypass it.

When write actions are added, grant each supported action explicitly and define what success means. A save operation might require a specific document and expected file state. A publishing operation needs a specific post, destination, and verifiable publication result. Increasing permissions should follow a tested use case rather than a vague “full access” setting.

9. Execute, observe, and verify as separate operations

OpenAI’s computer-use guide makes an easily missed distinction: a generated computer_call can have a completed status before the application has executed its requested actions. The action handler still has to perform permitted input and return an updated observation. Computer-use execution loop.

This original pseudocode shows the surrounding responsibilities. The helper functions are interfaces a developer must implement, not Cua SDK methods:

observation = observe(approved_target)

for step in range(step_budget):
    proposal = choose_next_step(goal, observation)
    if proposal.kind == "finish":
        return verify_goal(goal, approved_target)

    action = validate_and_authorize(proposal, approved_target)
    check_relevant_state_is_current(action, observation)
    attempt = record_attempt_before_execution(action)

    receipt = execute_with_required_delivery_mode(action)
    observation = observe(approved_target)
    outcome = verify_expected_effect(action, observation)
    record_outcome(attempt, receipt, outcome)

    if outcome.is_unknown:
        return reconcile_before_retry(attempt)

return {
    "status": "incomplete",
    "reason": "step_budget_exhausted",
}

validate_and_authorize checks both the shape of the proposal and the user-approved operation. check_relevant_state_is_current addresses stale observations. Recording an attempt before dispatch creates a recovery point if the response disappears. verify_expected_effect checks the application’s state, and final verification checks the user’s broader goal. Exhausting the action budget produces an incomplete result; it must not be reported as verified completion.

Recording a request ID alone does not make an arbitrary GUI click idempotent. If the process crashes after the click but before recording its result, the next run still needs to reconcile the external state. A useful ledger distinguishes proposed, admitted, executing, verified, failed, and unknown outcomes.

Cua’s click implementation contains readback handling for cases where an Accessibility operation’s return value and the observed application effect differ. This is a concrete reason to inspect state before retrying “Publish” or “Send” after an ambiguous response. Click verification.

For a website article, completion includes the stored content, publication status, canonical public URL, loaded image, readable code blocks, and actual responsive page. An editor’s success toast covers only part of that chain.

10. What research papers add to the engineering design

Research is useful when it changes the system’s acceptance criteria. These papers support specific lessons; they do not reveal proprietary ChatGPT internals or prove performance on a particular Mac.

Primary researchScope and engineering lesson
OSWorld, 2024 paperScope: tasks in real applications with execution-based outcome evaluation. Lesson: verify persistent or application-owned results instead of accepting an agent’s completion claim.
UI-TARS, January 2025 paperScope: screenshot-based perception, grounding, and a defined action space. Lesson: model understanding and executor behavior are separate; waiting, completion, and user intervention need explicit handling.
AgentDojo, 2024 paperScope: tool-using agents exposed to malicious instructions in untrusted tool results. Lesson: keep observed content separate from the authority to perform an action.

OSWorld’s main 369-task evaluation used Ubuntu, with supplementary Windows tasks. Its mention of macOS infrastructure does not turn the published scores into a Mac reliability benchmark. Similarly, historical UI-TARS results depend on the exact model, action budget, and evaluation setting. They should not be presented as current rankings or as guarantees for an M-series Mac.

For a practical negative test, place instruction-like text inside a harmless test page and ask the agent to read the page. The host should continue enforcing the original task’s action scope. Page text, a screenshot, or a terminal response can supply evidence, but none can independently authorize a different task. This test is an engineering application of the research, not a claim that one prompt completely prevents injection.

11. Local inference and unattended operation are separate design choices

Cua’s connection guide states that the driver does not call a model API. The harness selects the model and supplies the agent loop. A local model can therefore make decisions while a local driver performs actions, but the model must still support the observations and tool interface used by that harness. Connecting an agent.

“Local” needs a boundary. If screenshots are sent to a cloud model, observation processing is not entirely local even when the mouse action happens on the Mac. If the driver runs inside a virtual machine, it controls that guest environment, not automatically the host’s open Safari session. Driver placement in VMs and remote environments.

A sensible performance budget separates capture, inference, execution, and verification latency. Improving inference alone does not fix a slow accessibility traversal, an application that blocks on a dialog, or repeated recovery from stale state. Small, relevant observations can reduce model context without hiding evidence needed for the next action. Repeatedly acting from an old screenshot trades speed for uncertainty.

Running for 24 hours also requires application engineering: a scheduler, persistent task state, bounded retries, a stop mechanism, recovery after sleep or disconnect, and clear handling of sign-in challenges. These are design requirements inferred from the execution path. Downloading model weights does not implement them.

Cost follows the chosen components. A local driver does not force paid cloud inference, and a cloud harness does not become unlimited because the transport is MCP. ChatGPT and API billing are managed separately; eligible plan-specific API credits have their own conditions and limits. Check model access and any hosted components before describing an end-to-end setup as free. Billing separation · API credit eligibility.

12. A concrete acceptance test for a Mac agent

Begin with a narrow read-only task: read the selected model in an approved Draw Things window while the human continues working in Chrome. Record the chosen target and foreground app, capture fresh state, obtain the answer, and compare it with the visible setting. Do not treat a plausible model name as a pass.

Then test a reversible action in a disposable document or fixture app. Define the required result and verify it after execution. Repeat after moving the target window, opening a second window of the same application, and introducing a harmless dialog. These cases reveal whether targeting depends on stale geometry or a guessed window order.

TestPass condition and recovery
Tool availabilityPass: the current host can invoke the intended read-only tool. Recover: repair registration, exposure, or transport before changing OS permissions.
Target identityPass: the observation belongs to the approved process and window. Recover: re-enumerate; do not silently select a substitute.
Background operationPass: intended target result with no agent-caused foreground switch, pointer displacement, or stray keystrokes. Recover: stop or obtain approval for a different delivery mode.
Stale observationPass: outdated references are rejected or refreshed safely. Recover: re-observe and resolve the target again.
Ambiguous responsePass: external state is checked before repeating the action. Recover: reconcile the original attempt.
CompletionPass: the requested persistent or application-owned result is verified. Recover: report the missing evidence and continue the authorized repair.

This is also the right standard for publishing a technical article: inspect the public page, assess whether the explanation is complete, fix concrete defects, and repeat the check. A long word count alone is insufficient. Every code example should identify its purpose, input, output, assumptions, and limitations; every product-specific claim should have a source that supports it.

Frequently asked questions

Can installing Cua Driver give a normal ChatGPT conversation control of my Mac?

Installation supplies the driver. The conversation still needs a supported host integration, a connected execution path, appropriate tool exposure, and the required OS permissions. Current OpenAI documentation describes several local and remote connection paths; availability must be verified for the actual conversation.

Does MCP itself move the mouse?

MCP carries requests and results. The server’s implementation and platform driver perform the requested action. An identical protocol method can invoke very different underlying code on macOS, Windows, or a browser.

Does a second visible cursor prove independent computer use?

It shows an indicator. Independent operation requires a supported input route that preserves the human’s workspace, or an isolated desktop. The acceptance test must observe focus, pointer, input destination, and the target result.

What should be debugged first when no Mac tools are available?

Check the current host’s tool exposure and execution connection. If no request can reach the driver, adjusting capture permission cannot repair that missing path. Once a representative call reaches the runtime, diagnose permission and application-specific behavior.

Source revisions and further reading

The public implementation examples above use Cua commit 0b7a14ae514900f65eae7da871795c2e09a86823 and Codex commit 582e5f8ff3e086b733c1cc86db690fb0cd30bae9. Documentation was checked on 5 December 2026. Neither revision establishes which version is installed on a reader’s Mac.

Related INGOAMPT reading: Connect WordPress and business tools through MCP · Local AI and Apple Silicon articles · AI agents and MCP articles.

Leave a reply

Your email address will not be published. Required fields are marked *