# Infrazero Agent Bootstrap

Use this when a user asks you to deploy a project through Infrazero and you do not already have Infrazero MCP tools.

## Automatic Connection Flow

1. Start an authorization request. Use POST if your runtime supports it, otherwise GET:

POST (preferred):
```http
POST https://infrazero.app/api/skill/bootstrap/start
Content-Type: application/json

{ "agentName": "<YourAgentName>" }
```

GET (fallback - for agents that cannot make POST requests):
```
GET https://infrazero.app/api/skill/bootstrap/start?agentName=<YourAgentName>
```

Replace `<YourAgentName>` with your agent's name (e.g. Claude, Codex, Gemini).

2. Show the returned `approveUrl` and `userCode` to the user. Ask them to open the URL, sign in if needed, and approve the AI agent connection. The complete `approveUrl` in your own chat message is the durable continuation state. It is not the MCP bearer token and already contains the same request id and user code as `pollUrl`.
3. Stop and wait until the user explicitly confirms in chat that approval is complete. Do not poll in the background or send repeated status requests. Do not depend on a live JavaScript/shell variable and do not write `pollUrl` to a temporary file.
4. After the user's confirmation, call the exact `pollUrl` once with a raw HTTP/JSON client. If the local tool process was reset, recover it from the approval link already present in conversation: use its `mcp_authorize` value as the request id and its `code` value in `https://infrazero.app/api/skill/bootstrap/poll/{mcp_authorize}?code={code}`. Never create another approval request merely because local runtime state was lost. Do not use a browser page opener, URL preview, or search fetch: those clients may hide the credential or drop authorization headers. If it is still pending, stop and wait for the user again.
5. On `status: "approved"`, read `connection.endpoint` and `connection.authorizationHeader` from the compact JSON fields before the long `skill` field. Keep the authorization value only in process memory; never print it or ask the user to paste it. A real poll response cannot return 401: if you see Unauthorized, you called a different endpoint or dropped the returned authorization value. Do not create a new approval request.
6. If native `infrazero_*` tools do not appear immediately, do not ask for a reload. Continue in this same conversation by calling the returned Streamable HTTP MCP endpoint directly: initialize the MCP session, send `notifications/initialized`, list tools, then call `infrazero_describe` as documented in the returned skill.
7. Call `infrazero_describe` through either transport and follow the skill. Do not ask the user for secrets in chat.

The user does not need to know MCP. They only approve the connection in Infrazero.
