Netlify for Coding Agents: Build and Ship a Full App
A reference for AI coding agents building on Netlify: how to publish and update a live site with the CLI, add a database and background jobs, call models through the AI Gateway, and connect the Netlify MCP server, all non-interactively.
An agent that writes an app can also provision its backend and ship it, without a human clicking through a dashboard. Netlify exposes each primitive through a CLI command, an SDK, or the MCP server, and every step returns structured output an agent can parse. This reference maps the full build-and-ship flow: authenticate, publish, add data and compute, call models, and connect the MCP server so an agent can drive Netlify directly.
It assumes you have read Publishing and updating live sites with the Netlify CLI, which covers the deploy loop in detail. This page is the wider map: what else an agent can reach, and how.
Authenticate once, non-interactively
Generate a personal access token and pass it as an environment variable so every command runs without a browser login:
export NETLIFY_AUTH_TOKEN=your_token_valueScope the token to the narrowest access the task needs rather than reusing a full-access token across agents.
Publish and update a live site
Build your output, then deploy the folder and read the URL back as JSON:
URL=$(netlify deploy --dir=dist --no-build --prod --json | jq -r '.url // .deploy_url')Re-running the same command against the same site ships a revision to the same URL. Each deploy is an immutable snapshot, so a bad revision rolls back instantly. For throwaway output, netlify deploy --allow-anonymous returns a claimable URL with no account, though Netlify removes unclaimed sites after one hour. The CLI publishing guide covers the stateless patterns an agent needs.
Add a database
Provision managed Postgres with one command:
netlify db initThat installs @netlify/database and scaffolds migrations under netlify/database/migrations/ (add --boilerplate=drizzle for a Drizzle starter). Netlify provisions the instance and applies migrations on deploy. Each agent run gets its own database branch off production data, so you can change schema and data in isolation before you publish. See Netlify Database.
Add request and background compute
Write request handlers as Netlify Functions (JavaScript, TypeScript, or Go) with a Web-standard Request/Response signature and a config.path. For work that should outlive a request, reach for Async Workloads: an event-triggered function with durable, retryable steps. An agent building a checkout flow can put the API in a Function and the charge-fulfill-notify sequence in a workload, with no queue to stand up. Object storage comes from Netlify Blobs with zero setup.
Call models through the AI Gateway
The AI Gateway lets your code call OpenAI, Anthropic, and Google models through their official SDKs with no provider keys. Netlify injects OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, and the matching base URLs into every compute context, and bills token usage to your Netlify credits:
import OpenAI from 'openai';const openai = new OpenAI(); // credentials injected by the AI Gateway
const reply = await openai.chat.completions.create({ model: 'gpt-5', messages: [{ role: 'user', content: prompt }],});The Gateway activates after the first production deploy. An agent that generates an app calling a model can therefore ship it without ever handling a secret.
Connect the MCP server
The Netlify MCP server gives an AI assistant direct access to Netlify: creating deploys, managing Functions and Edge Functions, provisioning Blobs and Netlify Database, editing netlify.toml, setting environment variables, and calling the AI Gateway. Add the remote server:
npx -y add-mcp https://netlify-mcp.netlify.app/mcpOne-click installers exist for Cursor, LM Studio, and VS Code. With the MCP server connected, an agent runs Netlify operations as tool calls instead of shelling out to the CLI.
Or hand the whole task to an Agent Runner
Netlify can also host the agent. Agent Runners run Claude Code, OpenAI Codex, or Google Gemini against your project with its context, environment variables, and build settings already in scope. Start one from the CLI:
netlify create agentsEach run works on its own branch, gets a Deploy Preview and an isolated database branch, and lets you review changes before they reach production. Agent Runners need a GitHub-connected repository for continuous deployment; GitLab, Bitbucket, and Azure DevOps are not supported for that path.
The full loop
An agent can take a task from prompt to production entirely through these interfaces:
- Provision:
netlify db initfor data, Functions and Async Workloads for compute, Blobs for storage. - Build: generate the app; call models through the AI Gateway with no keys.
- Ship:
netlify deploy --prod --jsonand hand the URL back. - Revise: rebuild and redeploy to the same URL; roll back if needed.
Every step is a command or an SDK call with structured output, which is what makes Netlify legible to an agent rather than a series of dashboard screens.