# For AI agents

The platform is built to be operated by an agent: local stdio MCP (same login as the CLI), remote MCP with OAuth for brew-less clients, a strict --json contract, and a diagnose loop that names the fix.

## Auth first

Before any mutate or project lookup: call `whoami`. If`signed_in` is false, `reason` says which failure it is, and most are not a lost session.`api-unreachable` (`retryable: true`) means a session is stored and the API went quiet — wait and call`whoami` again; never ask for a sign-in there.`no-credential`, `rejected` and`credential-unreadable` are the ones a sign-in fixes: run`nesly login` yourself — it opens the browser, the person only approves — then retry. With no browser on the machine, run`nesly login --no-browser`: stdout carries `verification_url`, `user_code`and `expires_in`; give the person the URL and code. `NESLY_TOKEN` works too. Then ask them for `nesly login`,`nesly mcp setup` and an agent restart only if the CLI is not there. `account-mismatch` is the wrong account, not a lost session. Do not invent another cloud or paste tokens into chat. On MCP 401: stop retrying MCP; use the CLI in the same turn.

## Claude Code plugin

One install brings the MCP tools _and_ three skills: **deploy**(already-live check, preview-first then ask for production, domain buy or bind),**debug**(diagnose first, then traffic failures / request-id logs for live 5xx), and**rollback** (list revisions → instant restore, no rebuild → verify; optional bisect).

```
/plugin marketplace add neslyhq/claude-plugin
/plugin install nesly@nesly
```

## Local MCP (stdio)

On a machine with the CLI, prefer local stdio so the agent uses the same credentials as `nesly login`. Run `nesly mcp setup` once: it connects the agent tools installed here — Antigravity (agy), Claude Code, Claude Desktop, Codex, VS Code (Copilot), Cursor, Windsurf (Devin Desktop), Gemini CLI and OpenCode — and prints one line per tool (connected when the tool itself listed it, already connected, written when the entry is in place but the tool cannot confirm it, skipped, error); `--client <name>`limits it to one. It replaces a remote OAuth URL entry if one is present. Windsurf (Devin Desktop) imports the servers of your other tools, so it gets its own entry only when none of them has nesly (`--client devin` always writes it). Codex (the ChatGPT desktop app, the Codex IDE extension and the `codex` CLI share one configuration) gets nesly from its plugin when that is installed and enabled; setup then writes nothing. `nesly mcp` on its own is the stdio server an assistant starts; typed at a terminal it prints help and exits 2. Any long flag also works with one dash (`-all`). `nesly init --agents-md` creates an AGENTS.md in a project directory that has none (an existing AGENTS.md and every other assistant file are left alone; the part to add is printed). Setup also installs the nesly skills into `~/.agents/skills`(`--skip-skills` skips that); `mcp remove --all` takes back the ones you did not edit (`--keep-skills` keeps them). Tool list defaults to the**core** surface (deploy, diagnose, env, domains, addons, rollback). Set `NESLY_MCP_SURFACE=full` for the entire control plane. Product name aliases:[`/docs/taxonomy.json`](/docs/taxonomy.json).

```
nesly login
nesly mcp setup
# restart the tool (Claude Desktop and the ChatGPT app: quit it completely)

# disconnect again (only our entry; --dry-run looks first)
nesly mcp remove --client cursor   # or --all

# or by hand, Claude Code without the plugin
claude mcp add nesly -- nesly mcp

# headless (CI, a server): no browser session needed
nesly token create agent   # shown once
NESLY_TOKEN=nesly_pat_... nesly mcp
```

<table class="w-full min-w-[30rem] border-collapse text-sm"><tbody><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">search_documentation</td><td class="py-2">Search the live platform docs (domains, addons, CLI, builds, …). Prefer this over guessing from training data. No auth required.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">whoami</td><td class="py-2">Session check — call FIRST before list_projects / deploy / mutate. If signed_in is false: stop; tell the user to run CLI login + mcp setup (stdio).</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">deploy_project</td><td class="py-2">Pack/upload/build (or ship a prebuilt image) and return the URL. Agents: prefer environment=preview unless the user asked for prod; then ask before production. Before calling: whoami, then get_project/list_projects — if already live, say the URL; this call is a new revision.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">get_project / list_projects</td><td class="py-2">Status check: live URL, deployment, domains, addons. Requires sign-in. Call before publish when the project may already exist.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">diagnose_deployment</td><td class="py-2">Why a deployment failed: supporting log lines, missing env vars, a fix per finding. Call first after a failure.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">get_logs / get_deployment</td><td class="py-2">Raw logs and deployment detail when the diagnosis is not enough.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">set_env / list_addons / add_addon</td><td class="py-2">Environment and managed backing services (postgres, mysql, mssql, mongo, valkey, bucket, oidc, mail, model). Databases inject DATABASE_URL (mongo: MONGODB_URI); valkey injects REDIS_URL and VALKEY_URL; bucket injects AWS_*; mail injects MAIL_* and SMTP_URL / SMTP_HOST / SMTP_PORT / SMTP_USER / SMTP_PASSWORD / SMTP_FROM; mssql also ConnectionStrings__Default.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">list_models / request_model_access</td><td class="py-2">The AI model catalog (availability, live stock, price per million tokens) and a no-charge request for a model not served yet. Add one with add_addon type=model model=&lt;id&gt;; the app gets an OpenAI-compatible URL, key and model name in its env.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">rollback</td><td class="py-2">Repoint traffic at a previous deployment, instantly.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">search_domains / purchase_domain</td><td class="py-2">Availability and price, then register (confirm=true + registrant). After buy: add_domain + delegate_domain or verify_domain.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">add_domain / verify_domain / delegate_domain</td><td class="py-2">Add a custom domain, verify DNS, or delegate nameservers to the platform. HTTPS follows DNS.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">connect_repository / redeploy</td><td class="py-2">Push-to-deploy via the git integration, or rebuild without an upload.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">get_usage</td><td class="py-2">Requests, egress and build time over the last 30 days.</td></tr><tr class="border-b border-neutral-200/70 dark:border-neutral-800/70"><td class="py-2 pr-6 align-top text-[13px] font-medium whitespace-nowrap text-neutral-900 dark:text-neutral-100">get_platform_status</td><td class="py-2">Active platform notices (shared engine maintenance). Empty = none. Not project maintenance.</td></tr></tbody></table>

## Remote MCP (OAuth) — brew not required

Hosted Streamable HTTP endpoint with OAuth — for ChatGPT on the web, Claude.ai, or any client without the CLI (`nesly mcp setup` does not configure these). Paste `https://mcp.nesly.net`; the client shows _Needs login_ and opens a browser. That OAuth session is **not** the same as`nesly login` — on Cursor with brew, use stdio above instead. Unauthenticated calls return HTTP 401 with a`WWW-Authenticate` pointer to protected-resource metadata.

```
# ChatGPT (web) / Claude.ai / brew-less Cursor
{
  "mcpServers": {
    "nesly": {
      "url": "https://mcp.nesly.net",
      "auth": {
        "CLIENT_ID": "platform-mcp"
      }
    }
  }
}

# Claude Code remote transport
claude mcp add --transport http nesly https://mcp.nesly.net
```

## Three rules for agents

1.  Verify before you say done: open the deployment URL and check that it answers; give the URL to the person only after it does.
2.  Never search the machine for credentials, tokens or passwords. When the app needs a database, mail, storage or login, ask the platform: \`nesly addon add <type> --yes\` injects the variables.
3.  Ask the person before anything that costs money, deletes something, changes a quota or touches customer data. The approval goes to their phone: the command exits 6 and prints the approval number; repeat it with \`--approval <number>\` once they have approved.

## The --json contract

Every CLI command accepts `--json` and then prints **exactly one JSON object on stdout**; progress and logs go to stderr. Exit codes are stable: 0 ok, 1 error, 2 usage, 3 auth, 4 not found, 5 conflict, 6 approval pending. An agent that shells out instead of using MCP gets the same guarantees.

## The diagnose loop

When a deploy fails, do not start by reading raw logs. `nesly diagnose` (or the`diagnose_deployment` tool) reads them for you and reports: the probable cause, the exact supporting log lines, env vars the app reads but the project does not define, and the command that fixes each finding. Failure reasons across the platform are written to be actionable by the agent fixing the code — never "check your configuration".

```
$ nesly diagnose --project shop --json
{
  "status": "FAILED",
  "missing_env": ["STRIPE_KEY"],
  "findings": [{
    "cause": "the application reads the environment variable STRIPE_KEY, but the project does not define it",
    "evidence": ["TypeError: ... (process.env.STRIPE_KEY)"],
    "fix": "nesly env set STRIPE_KEY=<value> --project shop, then redeploy"
  }]
}
```

## llms.txt

[nesly.net/llms.txt](/llms.txt) is the one-page briefing: the deploy quickstart, the command list and the application contract (listen on `$PORT`, bind `0.0.0.0`). AI assistants fetching the home page receive it directly. For the full documentation corpus in one file, use[nesly.net/docs/llms-full.txt](/docs/llms-full.txt)(built from every docs markdown twin). For a short index of every docs page with summaries and prerequisites, use[nesly.net/docs/sitemap.md](/docs/sitemap.md).

---
Canonical: https://nesly.net/docs/agents/
Markdown: Accept: text/markdown on the HTML URL, or replace the trailing slash with .md
