Skip to content

Instructions for coding agents

This page is written for a coding agent that a person has asked to put a project online with Tori: Claude Code, Codex, Cursor, Gemini CLI, or any other. It does not depend on which one you are. The guides linked from it say more; this page says what to do, in order.

To hand it to an agent, paste this:

Read https://docs.tori.host/agents.md and put this project online with Tori.

That address serves this page as Markdown.

Tori has two clients over the same API. Use whichever you already have.

  • You can run shell commands. Use the CLI. npx tori.host needs Node.js 20 or newer and nothing installed. Everything on this page can be done this way.
  • You already have tools whose names start with tori_. Tori’s MCP server is connected. Use the tools; MCP for coding agents says what each input means.

If your host speaks MCP and the server is not connected, you may add it, when the person asked for that or agrees to it: a stdio server named tori, command npx, arguments -y, tori.host, mcp. Connect a host has the exact command or file for the hosts that document one. Most hosts start a new server only after a restart or a reload, so say so, and deploy with the CLI now instead of waiting. The MCP interface is a preview.

This is about the CLI. The MCP server signs in on its own: it uses TORI_TOKEN from its own environment if the host set one, and the CLI’s saved sign-in otherwise. So what whoami prints in your shell is not always the account the tools act on, and a host with no shell cannot run it at all: there, tori_account reports the account the tools act on. With MCP, a tool that is refused for lack of a token says so; Authenticate has the two ways the person can fix that.

With the CLI, check first:

Terminal window
npx tori.host whoami

It prints the account’s email and plan, then what the plan allows, or exits 1 and says why, usually not signed in. Check before deploying: a deploy with nobody signed in starts the same sign-in and waits for it.

Two refusals are not a missing sign-in, and login repairs neither, because TORI_TOKEN is used before a saved sign-in.

If whoami says the API refused TORI_TOKEN, the token was revoked, has expired or is wrong. Tell the person, who replaces it or unsets it. Do not sign in: the token in the environment would still be sent.

If TORI_TOKEN holds a deploy token, whoami is refused and says that such a token cannot read the account. That token deploys the one app in tori.json and reads its deploys, and nothing else on these pages. Go on with that deploy; do not sign in over it or ask for a wider token.

If nobody is signed in, run:

Terminal window
npx tori.host login

On the person’s own machine it opens their browser, and they sign in there. It also prints a link with a short code in it; anywhere without a browser it prints only the link and the code. Give the person both exactly as printed and tell them the command is waiting: they open the link on a device where they are signed in to the console, check that the code matches, and approve. Signing up is the same step, because a person with no account creates one on that page.

The command waits five minutes. If your shell stops commands sooner than that, run it in the background or with a longer limit, or the approval arrives after the command is gone.

  • Only the person signs in or approves. Do not open the link yourself.
  • Never ask for a token in the conversation, and never print one. No tool or command on this page takes a token as an argument.
  • Where nobody can approve (CI, a sandbox with no person), the person sets TORI_TOKEN in the environment. Sign in describes the tokens.

An app is a static site or a service. A static site can later become a service, keeping its address and domains, but only when you say so (--convert, or convert: true in MCP), and a service never becomes a static site. Decide before the first deploy.

  • Static site: files, nothing runs. Build first, then deploy the output directory, the one that holds index.html:

    Terminal window
    npm run build
    npx tori.host deploy --static ./dist
  • Service: a container Tori runs. Once you have decided it is a service, say so:

    Terminal window
    npx tori.host deploy --service

    Plain npx tori.host also builds a Dockerfile or a server framework it recognises, but where the project holds a static site as well it will not guess, and with no terminal to ask on it stops. Two things make a service fail to start that are easy to miss:

    • The port. The process must listen on 8080, or on the port the deploy names. --port 3000 names it for that one deploy only; a later deploy without it expects 8080 again. So after the first deploy, add "port": 3000 to the tori.json it wrote. Every later CLI deploy uses it, and so does an MCP deploy from source; an MCP deploy of an image reads nothing from that file, so pass port each time.
    • The user. A Dockerfile, or an image you bring, must declare a numeric non-root USER, for example USER 1000. A build Tori detects without a Dockerfile is arranged that way for you.

Never publish as static files a directory that holds server code or a .env file. The CLI refuses the cases it can see and prints the command to run instead; run that one, and do not work around the refusal.

You are not at a terminal, so the CLI does not ask questions. Where it would ask, it stops and prints the choices as commands.

tori.json is how the CLI remembers which app a project is. The first CLI deploy writes it. If it exists, the project already has an app, and a CLI deploy updates that app. Leave the file in place and suggest committing it.

The MCP tools do not take the app from that file and do not write it. tori_deploy creates a new app every time app is left out. So with MCP:

  • If tori.json exists, pass its slug as app.
  • After a first deploy, keep the app the result returns and pass it to every later call. That holds for a first deploy that failed too: the app was created before the deploy ran, and the error names its slug. Retry with that slug as app, or the retry creates a second app. Write it to tori.json as { "slug": "<that slug>" }, so that a later CLI deploy, and the CLI commands on the task pages, find the same app and do not create another.

Deploy a static site and Deploy a container service cover the details, including environment variables, release commands and ports.

A deploy waits until the app serves. Run from a shell that is not a terminal, as yours is, its last line is:

✓ live: https://plucky-wren.tori.cloud (8s)

On a terminal the same line reads [oo it's live. } and then the address. With MCP, the result’s status is live and url is the address. Report the address Tori gave, not one you composed.

One success is not the end state. If the CLI says the deploy went live, and has already been replaced by a newer deploy, or the MCP result’s status is superseded, somebody deployed after you. The address now serves their deploy and not yours. Say that, and do not report your changes as what is online. If the deploy failed, the CLI prints the stored reason; pass it on as it is, then fix the cause and deploy again. Deploy status and recovery lists the states.

  • Create a second app when the project already has a tori.json, or deploy to a different slug than the one in it.
  • Delete anything. That includes a managed database or a restored copy of one.
  • Free room on a full plan. A deploy that would exceed the plan is refused with app limit reached and names the limit. Which app to give up, or whether to change the plan, is the person’s decision.
  • Spend money. A plan change, a domain purchase and a renewal are the person’s decisions. Do not start one unless they asked for exactly that, and leave the paying to them.
  • Set a secret. npx tori.host env set KEY=VALUE stores an environment variable for a service. Ask for the value to be set by the person, or use one already in the project’s environment; do not echo it back.

Each of these has a page of its own, with the same shape as this one: when it applies, the steps, how to check, what to ask first. Read the page before you start the task, not instead of asking.

When Read
The app has to keep data, and is a service A Postgres database
The person wants the app at a hostname they own A custom domain

After a first successful deploy you may offer the custom domain once, in one sentence. Propose a database when the code needs one. Do neither until the person agrees.

  • Apps run in the EU (Prague). There is no other location.
  • An idle service sleeps, and the first request after a nap waits for it to wake, unless it is always-on. Always-on (tori_always_on, tori always-on) is available on plans that include it, and a switch-on can be refused (the plan’s count, the region’s capacity), in which case the tool says why and nothing changes. Switch it on only when the person asks.
  • The MCP interface is a preview. What is available is the list to quote from.
  • In the upcoming CLI and MCP release, npx tori.host whoami and tori_account will report a billing hold. If you see one, tell the person before deploying. Share what the hold already restricts and the date of the next change, if reported. Direct them to Settings → Billing in the console and leave payment and any other billing action to them.
  • Quote the plan’s limits only from what npx tori.host whoami or the tori_account tool printed for this account (from tori.host 0.21.2), never from memory or from a pricing page. They are limits, not usage: neither counts the apps or domains the account already holds, so “the plan allows 10” does not mean there is room for one more. When they say the limits are not available, say that you do not know them. A refusal still has the last word: if the API refuses with a limit, relay that sentence, even if it disagrees with what whoami printed.