Getting started

3-minute quickstart

Connect Server4Agent to the AI assistant you already use. It writes the app; Server4Agent gives it a persistent server to run it on and publishes it at a live URL, private until you share it. Your account budget cap keeps spending in check.

Endpoints. REST API at https://api.server4agent.com. MCP at https://mcp.server4agent.com (a dedicated subdomain, not a path under the API host).

0. Connect MCP

Add Server4Agent to your MCP-compatible host with one config block. Use a scoped API key from your dashboard, then keep the same endpoint across clients.

mcp.config.json
{
  "mcpServers": {
    "server4agent": {
      "url": "https://mcp.server4agent.com",
      "headers": {
        "Authorization": "Bearer $SERVER4AGENT_API_KEY"
      }
    }
  }
}

1. Get a server

Your assistant asks for a server. Over MCP it's a single tool call; over HTTP it's one request authenticated by its API key. There is no plan to choose, and one server holds several projects.

agent → MCP tool
// Your assistant calls the create_server MCP tool (no arguments, no plan)
{ "tool": "create_server", "arguments": {} }

// → { "id": "srv_2k9", "tier": "small", "status": "running", "url": null }
//   A new server takes about a minute to start the first time:
//   get_server reads provisioning "ready" once it is up.
provision.sh
# Or provision over HTTP, authenticated by the agent's API key
curl -X POST https://api.server4agent.com/servers \
  -H "Authorization: Bearer $SERVER4AGENT_API_KEY"

# → { "id": "srv_2k9", "url": null, "status": "running", "tier": "small" }

2. Put the app on it

Your assistant builds the app the way it always does. Then it makes a project on the server, writes the files into it, and starts the app on the project's port. start_app keeps it running after the chat ends and brings it back after a restart. The project stays private while you look it over.

assistant → MCP tools
// The assistant makes a project on the server for the app...
{ "tool": "create_project",
  "arguments": { "server_id": "srv_2k9", "name": "waitlist" } }
// → { "id": "proj_9f2", "slug": "waitlist-9f2", "visibility": "private", "url": null }

// ...writes the files it built into the project's folder...
{ "tool": "write_file",
  "arguments": { "server_id": "srv_2k9", "project_id": "proj_9f2",
                 "path": "public/index.html", "content": "<!doctype html>…" } }

// ...and starts the app on the project's port, where it keeps running.
{ "tool": "start_app",
  "arguments": { "project_id": "proj_9f2",
                 "command": "python3 -m http.server $PORT --bind 0.0.0.0 --directory public" } }
// → { "status": "running", "listening": true, "url": null }

3. Publish it

deploy checks the app is answering, makes the project public, and returns its live URL at *.apps.server4agent.app with managed TLS. To hear about it from your own systems, subscribe to the deployment.live webhook.

assistant → MCP tool
// One call puts it online.
{ "tool": "deploy",
  "arguments": { "server_id": "srv_2k9", "project_id": "proj_9f2" } }

// → { "url": "https://waitlist-9f2.apps.server4agent.app",
//     "status": "live", "project_id": "proj_9f2" }

4. It keeps running

The server keeps its workspace, its files and the running app between sessions, so the next conversation picks up where this one left off. When it is idle, it scales to zero; the next request wakes it again.

Or hand the build to the agent on the server

Rather not write the code in your assistant? A task (prompt over MCP) hands a plain-language goal to an agent that runs on the server, which plans the app, writes it, and starts it. It spends your account's AI budget, so it is there when you ask for it rather than the default path.

task.sh
# Hand a goal to the agent on the server: it plans, writes the code, and starts it
curl -X POST https://api.server4agent.com/servers/srv_2k9/tasks \
  -H "Authorization: Bearer $SERVER4AGENT_API_KEY" \
  -d '{ "goal": "Build a landing page with a waitlist form and serve it on $PORT." }'

# → { "task_id": "tsk_71a", "status": "running" }
# When it finishes, deploy the project to publish it, as in step 3.

Start from your own code

Already have the code in a repository? Seed a project from a git repo or an uploaded archive. Server4Agent clones or unpacks it, then the on-server agent installs dependencies, starts the app, and confirms the service is up: you supply the code, it figures out how to run it. Watch init_phase move to ready. Pass any env the code needs as secrets (write-only); anything it needs that you didn't provide pauses bring-up at awaiting_secrets with the list of keys.

import.sh
# Or seed a project from your own repo and let it come up on its own
curl -X POST https://api.server4agent.com/servers/srv_2k9/projects \
  -H "Authorization: Bearer $SERVER4AGENT_API_KEY" \
  -d '{ "name": "checkout-service",
        "source": { "kind": "git",
                    "git_url": "https://github.com/your-org/checkout-service" },
        "secrets": [ { "key": "DATABASE_URL", "value": "postgres://…" } ] }'

# → { "id": "proj_9f2", "init_run_id": "tsk_c40", "init_phase": "seeding" }
# The on-server agent installs, starts, and healthchecks it. Poll
# GET /projects/proj_9f2 until init_phase = "ready". The service is then
# up on its project URL.
#
# If the code needs env you didn't provide, it stops at "awaiting_secrets"
# with a required_secrets list. Supply them, then resume bring-up:
#   PUT  /projects/proj_9f2/secrets   { "secrets": [ { "key": "...", "value": "..." } ] }
#   POST /projects/proj_9f2/init
# Setting secrets alone does not restart it.

More examples

The Examples page takes these steps further: publishing a whole app, running a function, importing a repo, the same flow over plain HTTP, and handing a build to the agent on the server.

Next: MCP server→

Connect an agent

Create a key, paste the MCP config, and your assistant can publish what it builds at a live URL that keeps running.