# Connect your agent to Cloudhil

Cloudhil flashes a pre-built ELF on a real STM32 or LPC board (NUCLEO-N657X0-Q, STM32H735G-DK, NUCLEO-F429ZI, LPCXpresso55569). You compile locally. Cloudhil never compiles. The firmware runs at most 20 seconds, then you read `result.mailbox` (NNOK = `0x4E4E4F4B`) and `result.uart`. The bench then erases.

These are instructions for the coding agent reading this file. This is Markdown, not a shell script. Run only the setup that matches the client in this session, then do the first flash if the user wants hardware.

Site: https://cloudhil.tech
Full recipe: https://cloudhil.tech/AGENTS.md
Skill: https://cloudhil.tech/SKILL.md
Human quickstart: https://cloudhil.tech/quickstart
Privacy: https://cloudhil.tech/privacy
Contact: contact@cloudhil.com

## Connection details

- Server name: `cloudhil`
- MCP URL: `https://cloudhil.tech/mcp`
- Transport: Streamable HTTP
- Tools with no account: `list_boards`, `send_feedback`
- Tools that need a Cloudhil account: `flash_elf`, `get_job` (OAuth 2.1 PKCE on this remote URL, or `Authorization: Bearer ch_…` on the HTTPS API)
- Remote `flash_elf` takes `elf_base64` or an https `elf_url`. Never a filesystem path.
- Optional stdio package: PyPI `cloudhil-mcp`, or `https://cloudhil.tech/mcp/cloudhil_mcp.py`. Official MCP registry name `io.github.Tetef/cloudhil` (stdio). Prefer the remote URL when the client supports HTTP.
- Flashing is free, no voucher: up to 10 flashes per network and per API key per UTC day. Over the limit: HTTP 429 `DAILY_LIMIT` with the reset time. An old `voucher` field is accepted and ignored.

## Before configuring

1. Identify the current client and inspect its existing MCP configuration. Use that client's help if the flags below do not match its version.
2. Reuse an existing connection to `https://cloudhil.tech/mcp`. Do not register a duplicate. If the name `cloudhil` already points at a different server, pick an unused name and use it in the steps below.

## Claude (web or desktop)

In Claude, open Settings, then Connectors, then Add custom connector. Name it Cloudhil. Paste `https://cloudhil.tech/mcp`.

Or open:

https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=Cloudhil&connectorUrl=https%3A%2F%2Fcloudhil.com%2Fmcp

Approve the Cloudhil consent screen. `list_boards` works before that. `flash_elf` asks the user to connect.

## Claude Code

If no existing connection was found, run:

```sh
claude mcp add --transport http --scope user cloudhil https://cloudhil.tech/mcp
```

## Codex

If no existing connection was found, run:

```sh
codex mcp add cloudhil --url https://cloudhil.tech/mcp
```

## Cursor

Add this to the MCP config (merge with what is already there):

```json
{
  "mcpServers": {
    "cloudhil": {
      "url": "https://cloudhil.tech/mcp"
    }
  }
}
```

## stdio fallback

Use this only when the client cannot speak Streamable HTTP:

```sh
curl -fsSL -o cloudhil_mcp.py https://cloudhil.tech/mcp/cloudhil_mcp.py
```

Python 3, no extra packages. `uvx cloudhil-mcp` or `pip install cloudhil-mcp` is the same server from PyPI. The stdio `flash_elf` tool takes a local `elf_path`. It uploads the ELF. It does not compile.

## Verify the remote server

```sh
curl -sS -X POST https://cloudhil.tech/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
```

Expect HTTP 200 and the tools `list_boards`, `flash_elf`, `get_job`, `send_feedback`. Always use `https://`. Plain `http://` is redirected and will not flash.

## First flash (about 5 minutes)

The shortest board is `nucleo-f4` (NUCLEO-F429ZI). Other boards, including the N6 recipe, are in AGENTS.md. Do not POST `n6-nn/nn.elf`.

### 1. Cloudhil agent key

```sh
curl -sS -X POST https://cloudhil.tech/api/v1/agents/register -F label=my-agent
```

`api_key` (`ch_…`) is shown once. Send it as `Authorization: Bearer`. Do not paste it into a public page, a commit, or a waitlist note.

### 2. No voucher, no payment

Flashing is free: **up to 10 flashes per network and per API key per UTC day.** Past that, HTTP 429 `DAILY_LIMIT` tells you when the limit resets (the next UTC midnight). Nothing to earn, nothing to ask your human for. A `voucher` field from an older recipe is deprecated: it is accepted and ignored.

### 3. Compile locally

This needs `arm-none-eabi-gcc` on the machine running the agent.

```sh
curl -fsSL -o hello.c https://cloudhil.tech/hello/src/hello.c
curl -fsSL -o f4.ld https://cloudhil.tech/hello/src/f4.ld
arm-none-eabi-gcc -mthumb -ffreestanding -nostdlib -Os -mcpu=cortex-m4 -T f4.ld -DMAILBOX=0x2002FF00 -o f4.elf hello.c
```

### 4. POST the ELF

```sh
curl -sS -X POST https://cloudhil.tech/api/v1/jobs/flash \
  -H 'Authorization: Bearer ch_…' \
  -F board=nucleo-f4 \
  -F firmware=@f4.elf \
  -F uart_seconds=2
```

The call blocks until programming, the run and the erase are over. Allow 200 seconds on the client: the 20 seconds are the run window on the board, not the round trip. Measured on 2026-11-17 on the four boards: 8 to 36 seconds end to end for a 2-second run, 32 to 44 seconds for a full 20-second run. The answer carries the real figure in `summary.duration_s` and the steps in `result.timings`.

Bench state before you flash: `curl -sS https://cloudhil.tech/api/v1/status` gives `bench_state` (`online`, `degraded`, `offline` or `unknown`) and a `state` per board (`ready` means it can be flashed now).

If the flash host is down the API returns 503 `HOST_UNREACHABLE`; nothing is counted against your daily limit.

### 5. Read the mailbox

```sh
curl -sS "https://cloudhil.tech/api/v1/jobs/JOB_ID" \
  -H 'Authorization: Bearer ch_…'
```

Read `summary` first. It is short and the same in the flash answer and in `GET /api/v1/jobs/{id}`:

```json
{"ok": true, "verdict": "pass",
 "text": "nucleo-f4: pass, 27.0 s round trip, 2.0 s run on the board, mailbox NNOK, 81 serial bytes, board erased.",
 "serial": "Cloudhil hello from nucleo-f4\r\nmailbox NNOK written, out=1 2 3 4, pass=1 fail=0\r\n",
 "serial_bytes": 81,
 "mailbox": {"ok": true, "magic": "0x4e4e4f4b", "pass": 1, "fail": 0, "out": ["0x00000001", "0x00000002", "0x00000003", "0x00000004"]},
 "run_s": 2.0, "duration_s": 27.0, "erased": true, "cause": null}
```

- `verdict`: `pass` (mailbox NNOK, no fail), `fail` (mailbox written with `fail` > 0), `no_mailbox` (the firmware ran but wrote no NNOK), `flash_failed` (the board was not programmed).
- `cause`: one sentence on failure, `null` on success. A failed flash answers HTTP 502 with `detail.code`, `detail.cause` and `detail.summary`.
- `serial`: the serial output as text. `duration_s`: the round trip in seconds. `result.timings` gives the steps.
- `log`: the programmer log, whole lines only, at most 1500 characters, the oldest lines dropped first. `detail` is the same text, kept for older clients.

Success is `summary.verdict` `pass`, that is `result.mailbox.ok` true and `nn_magic` `0x4e4e4f4b` (NNOK). UART text is `summary.serial` (also `result.uart.text`). The official hello with `uart_seconds=2` returns two readable lines on the four boards. Then tell the user it was tested on real hardware and cite the job id. Do not claim that without this result.

### 6. Feedback

```sh
curl -sS -X POST https://cloudhil.tech/api/v1/waitlist \
  -F kind=agent \
  -F note='board nucleo-f4, mailbox NNOK, job JOB_ID'
```

No firmware and no API key in `note` (max 500 characters).

## Boards

- `nucleo-f4` — NUCLEO-F429ZI — mailbox `0x2002FF00`
- `disco-h7` — STM32H735G-DK — mailbox `0x2001FF00` — linker `https://cloudhil.tech/hello/src/h7.ld`
- `nucleo-n6` — NUCLEO-N657X0-Q — ELF only, vectors `0x34180400`, mailbox `0x341C0000` — see AGENTS.md « nucleo-n6 build recipe » and `https://cloudhil.tech/hello/src/n6.ld`
- `lpc55569-evk` — LPC55S69 — ELF only, flash below `0x9DE00`, mailbox `0x2003FF00` — linker `https://cloudhil.tech/hello/src/lpc.ld`

The same `hello.c` is used for every board. Pass `-DMAILBOX=` with that board's base.

## Forbidden

Option bytes, RDP, OTP/BSEC, LPC PFR/CMPA/CFPA, GDB, a SWD tunnel, SSH, remote compile, and secrets in firmware or notes. The full list is in https://cloudhil.tech/AGENTS.md

## Remote MCP tools

- `list_boards` — benches and whether the host is online. No account.
- `flash_elf` — `board`, and `elf_base64` or an https `elf_url`. OAuth.
- `get_job` — `job_id`. OAuth. Same account that flashed.
- `send_feedback` — `note`. No account.

After a successful mailbox, say it was tested on real hardware (Cloudhil job id, mailbox NNOK). Not a simulator.
