# Host and publish

> Run your server wherever you like, connect it to your account, publish a priced version, and test it end to end.

Source: https://www.nexus402.dev/docs/creators/build-a-server/publish/

This is part two of [Build a Server](https://www.nexus402.dev/docs/creators/build-a-server/). You have an endpoint that answers the hello and returns a result with a proof; now it goes online and into the catalogue. We host nothing, so the first step is yours.

## Deployment and hosting

Any host works if it meets four conditions:

1. **HTTPS on port 443** with a valid certificate, at a hostname whose every address is public. One private address in the DNS answer and the gateway refuses to dial.
2. **Fast first bytes.** Response headers within 5 seconds of the request, and no silence longer than 5 seconds; the whole call within 120.
3. **The raw request body** reaches your code unchanged, because the signature covers its exact bytes. Do not let a framework parse and re-serialise JSON before you verify.
4. **`/.well-known/` at the root of the host is served as is**, with no redirect, for the one-time host proof.

| Option | Fits when | Watch for |
| --- | --- | --- |
| A virtual server with a reverse proxy that obtains certificates (Caddy, nginx with Let's Encrypt) | You want full control and steady latency | Keep the proxy from buffering or rewriting the body, and forward `/.well-known/` |
| A container platform (Cloud Run, Fly.io, Render, Railway, App Runner) | You want HTTPS and scaling handled for you | Scale-to-zero cold starts can exceed the 5-second header limit; keep one instance warm |
| A serverless function (Vercel, Netlify, AWS Lambda behind a function URL) | Traffic is bursty and calls are short | Wrap the same logic in the platform's handler; read the body as raw bytes; mind cold starts and the platform's own time limit |

Whatever you choose, the gateway sees one URL. To move hosts later, publish a new version at the new URL: a published version's endpoint never changes.

## Connect your account

1. **Sign in** to the app with Google, GitHub or Apple and choose the creator role. There is no password.
2. **Claim a handle** in Creator settings: 3 to 39 characters of lowercase letters, digits and `-`, starting with a letter or digit. One per account, and it is never released, so nobody can later take your name and the calls meant for you.
3. **Save the creator key** from the claim answer, `nx_crt_…`. It is shown once; we keep only a derived value. If you lose it, rotate it in Creator settings, where we email you a code to confirm it is you. The gateway sends the new key within 30 seconds, so calls fail until your server accepts it: deploy it straight away, and accept the previous key too for a minute after.
4. **Set `NEXUS_CREATOR_KEY`** and `NEXUS_PUBLIC_KEY` on your server and deploy it.

## Register and publish a version

Open **Publish a version** in the app. The wizard has five steps, and checks each one with the server's own rules before you continue:

| Step | What you set |
| --- | --- |
| Basics | The server and tool names, the version (`v` and digits, such as `v1`), and a category |
| Endpoint | The HTTPS URL of your server, up to 2,048 characters |
| Pricing | The price per call, more than $0 and up to $5.00 by default, and, for a new tool, any free calls |
| Schema and docs | A description (up to 4,096 characters), the input schema as a JSON object, example arguments, an optional example output, and what changed |
| Review | Everything once more. Nothing here can change after publishing |

The example output is optional: a JSON object of up to 16 KiB showing what one call with your example arguments returns, such as `{"content":[{"type":"text","text":"..."}]}`. It is shown on your tool's page as text, beside the example arguments, and is never run.

When you confirm, the server checks, in this order:

1. **Host proof**, the first time you publish at a host. The answer is `403 host_proof_required` with a URL and a line of text: serve that text as the whole body at that URL, then publish again. Once a version is live at the host, the file can go. Details are on [the quickstart](https://www.nexus402.dev/docs/creators/quickstart/#host-proof).
2. **Publish code**, only when you move an existing tool to a host it has never used: a code is emailed to you, so a stolen session cannot redirect your tool's calls.
3. **The hello**: one signed, empty-body request to your endpoint, which must answer `2xx` with the proof.

The version is then published, and gateways pick it up within about five minutes. A price more than twice what unpinned callers were paying waits seven days before unpinned callers reach it; developers who pin the version reach it at once.

> **A version is permanent**
>
> Its price, endpoint and text never change. A fix or a new price ships as `v2`; `v1` keeps routing for anyone pinned to it until you retire it, and retiring stops its calls. See [Versions are immutable](https://www.nexus402.dev/docs/creators/versions/).

## Free calls

Give every account a number of free calls of a tool per UTC day, week or month, from 0 (off, the default) to 1,000. Set it on the pricing step when you publish a new tool, or later on the tool's page; it belongs to the tool, so every version shares it and a new version keeps it. You earn nothing on a free call, and it reaches your endpoint exactly like a paid one. A new account that has never paid can take free calls only while it holds trial credit, so one person making many accounts cannot drain your allowance. Your dashboard shows the free calls each tool served in the last 30 days.

## Testing

1. **Before publishing**, test `runTool` on its own with ordinary unit tests: the signature cannot be produced without the gateway's private key, so the network path is tested from the gateway.
2. **Send test request** on the tool's page in the app sends your endpoint the hello and then one signed `tools/call` with your example arguments and `X-Nexus-Test: 1`, and shows what came back. Nobody is charged. It runs at most ten times an hour.
3. **A real call**: make a developer key on your own account and call the tool as a developer would. It is a real charge at your price, and earnings from your own account are held longer than others.

**Call your published tool as a developer**

```bash
curl -s https://api.nexus402.dev/v1/mcp \
  -H "X-Nexus-Api-Key: $NEXUS402_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
       "params":{"name":"acme/text/word_count","arguments":{"text":"we add the meter"}}}'
```

Then watch the tool's page: [endpoint health](https://www.nexus402.dev/docs/creators/endpoint-health/) shows failures and the last call delivered, and your dashboard shows calls served.

## Debugging and troubleshooting

Your own logs are the first place to look: the samples log why they refused a request, and never say why in the answer.

| What you see | Cause | Fix |
| --- | --- | --- |
| `403 host_proof_required` on publish | First publish at this host | Serve the challenge text at the challenge URL, then publish again |
| `422 endpoint_hello_failed` | Your endpoint did not answer the empty-body hello with `2xx` and the proof. Most often: the key check ran first and refused it | Answer an empty body before the key check, as the samples do. Check the URL and that the server is up |
| `409 endpoint_taken` | Another creator already publishes at that host | Use a hostname of your own; a subdomain is enough |
| `409 listed_name_taken` | MCP clients see tools as `handle_server_tool`, and another tool already has this one's, ignoring case. The message names it | Choose a different server or tool name |
| `409 version_exists` | That version is already published | Publish the next version |
| `400 price_above_ceiling` | The price is over the per-call ceiling ($5.00 by default) | Lower the price |
| Log: "signature does not verify" | Verifying against the inbound `Host`, a re-serialised body, or an old public key | Use the published host, the raw body bytes, and every key from `/v1/signing-key` |
| Log: "timestamp outside the 60-second window" | Your clock is wrong | Run time synchronisation (NTP) |
| Log: "creator key mismatch" | An old or mistyped key, often after a rotation | Deploy the current key; accept the previous one during the overlap |
| Developers get `502 Upstream_Unavailable` | A timeout, a `5xx`, a refused dial, or a `2xx` without a valid proof | Check response time and the proof header; they were not charged |
| The version disappeared from the catalogue | Twenty failures in a row de-list it | Fix the endpoint, then publish the same version with the same price and endpoint to restore it |

> **Getting paid**
>
> Calls settle in five-minute rollups. To withdraw, connect Stripe in the app; see [When you earn](https://www.nexus402.dev/docs/creators/settlement/) and [Payouts](https://www.nexus402.dev/docs/creators/payouts/).
