# From any agent

`mcp.mjs` serves Praecise Control to whatever agent is asking. The agent is given the
apps as tools: `computer_control_accounts`, `computer_control_elements`,
`computer_control_screen`, `computer_control_record` and `computer_control_open`. A
screenshot arrives as an image. Everything is still held to each app's mode.

Set it up once, in a folder of its own:

```sh
cp -r node_modules/@praecise/harness-environments/computer-control/app praecise-control && cd praecise-control
npm install
export PRAECISE_CONTROL_APPS="TextEdit,Numbers"
npx praecise computer-control doctor
npx praecise computer-control connect && npx praecise computer-control sync
npx praecise computer-control mode textedit draft
```

`<front>` below is `node <folder>/node_modules/@praecise/harness-environments/computer-control/mcp.mjs <folder>`.

Three kinds of agent are served from the one app, and none of them is told apart by
name: each is answered by how it asks.

| The agent | How it asks | What it is given |
|---|---|---|
| Speaks the current revision of MCP (2026-07-28): praecise-harness, a Tenzro node, which say so with every request and open with `server/discover` | `<front>`, or `<front> --http` | Each request handed to the app exactly as it came |
| Opens with the earlier handshake: Claude Code, Claude Desktop, Codex, Cursor, VS Code, Gemini CLI | `<front>`, or `<front> --http` | The handshake answered, and each request put to the app in the app's revision |
| Calls functions the OpenAI way and is no MCP client: a loop over Chat Completions or Responses, a Tenzro node's `/v1/chat/completions` among them | `<front> --tools openai` for the definitions, `<front> --call <tool> '<arguments>'` for each call its model makes | The tools as function definitions, and each result as text and pictures |

Over HTTP it listens on this machine only, at `http://127.0.0.1:17346/mcp`. It refuses a
request from a web page, and wants the token it keeps in
`<folder>/.praecise/control-http.token` as a bearer. Nothing is pushed: a request is
POSTed and answered.

Each client's own way of being told, from its documentation as read on 26 Nov 2026:

| Client | How |
|---|---|
| Claude Code | `claude mcp add --env PRAECISE_CONTROL_APPS=TextEdit,Numbers praecise-control -- <front>`, or over HTTP: `claude mcp add --transport http praecise-control http://127.0.0.1:17346/mcp --header "Authorization: Bearer <token>"`. Both tried with 2.1.323; the first with 2.1.332 as well: connected |
| Codex | `codex mcp add praecise-control --env PRAECISE_CONTROL_APPS=TextEdit,Numbers -- <front>`, or `[mcp_servers.praecise-control]` with `command`, `args` and an `env` table in `~/.codex/config.toml`. Not tried |
| Cursor | `.cursor/mcp.json` or `~/.cursor/mcp.json`: `{"mcpServers":{"praecise-control":{"command":"node","args":["<path>/mcp.mjs","<folder>"],"env":{"PRAECISE_CONTROL_APPS":"TextEdit,Numbers"}}}}`. Not tried |
| VS Code | "MCP: Add Server" in the Command Palette, then "Command (stdio)". Not tried |
| Gemini CLI | `gemini mcp add -e PRAECISE_CONTROL_APPS=TextEdit,Numbers praecise-control node <path>/mcp.mjs <folder>`, or the same `mcpServers` shape in `~/.gemini/settings.json`. Not tried |
| A Tenzro node, or anything else on the current revision | `<front>` or `<front> --http`. Tried with requests made the way that revision makes them, not with a Tenzro node |
| ChatGPT, and any assistant that calls from somewhere else | The public route, below: the assistant is given `https://praecise-control.app.praecise.cloud/mcp` and the person signs in with their Praecise account. Not tried with ChatGPT itself |

Why there is a file for this at all: praecise-harness speaks the current revision of
MCP and no earlier one, and most clients still open with the earlier handshake. Claude
Code 2.1.332, the latest on the day, was refused by `praecise mcp` and connected through
`mcp.mjs`. `mcp.mjs` answers the handshake and passes each request to the app
unchanged; the harness is as it was.

## The public route

For an assistant that is not on the computer, nothing is opened on the computer. The
computer connects out to a relay and stays connected, the assistant calls the relay,
and the relay passes each request to that computer and the answer back.

```sh
<front> --cloud
```

That signs the person in with their Praecise account, in their own browser, and
connects this computer to `https://praecise-control.app.praecise.cloud`. Stopping the
program ends it. The sign-in is kept in the keychain on a Mac, or in a sealed file
under `PRAECISE_VAULT_KEY` anywhere else.

The assistant is then given `https://praecise-control.app.praecise.cloud/mcp`. It finds
where to send its person from there, the person signs in to their Praecise account,
and the consent page lists that person's connected computers. The one they pick is
the only one that assistant's token is good for.

What holds it:

- **The person's account decides.** An assistant has a token the person gave it, for
  one computer. The computer has a token of the person's own. The relay checks both
  against the account service's keys, and passes nothing between two different people.
- **The relay keeps nothing.** No request, answer or picture is written anywhere on it,
  and when the computer disconnects there is nothing of it left there.
- **The app still decides.** A request that arrives this way is held to each app's mode
  exactly as one made on the computer is.
- **It ends where the person ends it:** stopping the program, or ending the assistant's
  connection on their account page.

The relay is `relay/server.mjs`, with nothing to install beside Node, and runs as the
site `praecise-control` on Praecise Cloud. The account service knows it as the service
"Praecise Control". Anyone can run a relay of their own against an account service of
their own: it needs its address, the account service's, and a secret the two share.

Tried: the whole route against a stand-in for the account service
(`tests/control-relay.test.ts`), and the account service's own consent flow with the
relay's question (its tests). The live relay answers the account service's signed
question and refuses an unsigned one, and the live account service leads the
computer's program to its sign-in. Not tried: a person signing in and an assistant
reaching their computer through the live route, and ChatGPT itself.

A press that needs a person is refused over MCP with a line saying so. The harness does
not take an approval over MCP, on purpose: a message from a client must not be what
approves something. Where the client itself asks its person before each tool call, an
app's sending and publishing can be waived for that app, by a person:

```sh
npx praecise computer-control waive textedit publish send
npx praecise computer-control waive textedit none
```

Removing and paying cannot be waived, and once a window has been read in a conversation
everything that commits waits for a person whatever is waived. `waive` needs a harness
later than 1.2.1.
