Build a Server

Host and publish

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

Sections

This is part two of 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.
OptionFits whenWatch for
A virtual server with a reverse proxy that obtains certificates (Caddy, nginx with Let's Encrypt)You want full control and steady latencyKeep 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 youScale-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 shortWrap 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:

StepWhat you set
BasicsThe server and tool names, the version (v and digits, such as v1), and a category
EndpointThe HTTPS URL of your server, up to 2,048 characters
PricingThe price per call, more than $0 and up to $5.00 by default, and, for a new tool, any free calls
Schema and docsA description (up to 4,096 characters), the input schema as a JSON object, example arguments, an optional example output, and what changed
ReviewEverything 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.
  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.

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 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 seeCauseFix
403 host_proof_required on publishFirst publish at this hostServe the challenge text at the challenge URL, then publish again
422 endpoint_hello_failedYour endpoint did not answer the empty-body hello with 2xx and the proof. Most often: the key check ran first and refused itAnswer an empty body before the key check, as the samples do. Check the URL and that the server is up
409 endpoint_takenAnother creator already publishes at that hostUse a hostname of your own; a subdomain is enough
409 listed_name_takenMCP clients see tools as handle_server_tool, and another tool already has this one's, ignoring case. The message names itChoose a different server or tool name
409 version_existsThat version is already publishedPublish the next version
400 price_above_ceilingThe 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 keyUse the published host, the raw body bytes, and every key from /v1/signing-key
Log: "timestamp outside the 60-second window"Your clock is wrongRun time synchronisation (NTP)
Log: "creator key mismatch"An old or mistyped key, often after a rotationDeploy the current key; accept the previous one during the overlap
Developers get 502 Upstream_UnavailableA timeout, a 5xx, a refused dial, or a 2xx without a valid proofCheck response time and the proof header; they were not charged
The version disappeared from the catalogueTwenty failures in a row de-list itFix the endpoint, then publish the same version with the same price and endpoint to restore it

Install agent tools

Help your coding agent stay on track when building with Nexus402. Learn more

Paste this into Claude Code, Codex or Cursor. Your agent connects itself to Nexus402 and adds the skills, for whichever tool it is.

Prompt for your agent text
Set up Nexus402 for me in this coding agent.
1. Read https://www.nexus402.dev/docs/agents.md and work out which tool you are (Claude Code, Codex or Cursor).
2. Add the Nexus402 MCP server https://api.nexus402.dev/v1/mcp the way that page shows for your tool, sending the X-Nexus-Api-Key header from the NEXUS402_API_KEY environment variable.
3. Install the skills listed at https://www.nexus402.dev/.well-known/skills/index.json where your tool keeps skills or rules.
Never write my key into a file, a commit or a reply. If NEXUS402_API_KEY is not set, stop and tell me to set it.
Then check the connection lists tools, and tell me what you changed.

Connect the gateway, then add the two skills.

Terminal bash
claude mcp add --transport http --scope user nexus402 https://api.nexus402.dev/v1/mcp \
  --header "X-Nexus-Api-Key: $NEXUS402_API_KEY"

mkdir -p ~/.claude/skills/nexus402-tools && curl -fsSL https://www.nexus402.dev/.well-known/skills/nexus402-tools/SKILL.md -o ~/.claude/skills/nexus402-tools/SKILL.md
mkdir -p ~/.claude/skills/nexus402-endpoint && curl -fsSL https://www.nexus402.dev/.well-known/skills/nexus402-endpoint/SKILL.md -o ~/.claude/skills/nexus402-endpoint/SKILL.md

Add the gateway to ~/.codex/config.toml, then add the skills with npx skills add https://www.nexus402.dev.

~/.codex/config.toml toml
[mcp_servers.nexus402]
url = "https://api.nexus402.dev/v1/mcp"
env_http_headers = { "X-Nexus-Api-Key" = "NEXUS402_API_KEY" }
tool_timeout_sec = 130
Add to Cursor

Opens Cursor and asks to add the gateway. Your key is read from NEXUS402_API_KEY.

Or add it by hand to ~/.cursor/mcp.json. Then add the skills with npx skills add https://www.nexus402.dev.

~/.cursor/mcp.json json
{
  "mcpServers": {
    "nexus402": {
      "url": "https://api.nexus402.dev/v1/mcp",
      "headers": {
        "X-Nexus-Api-Key": "${env:NEXUS402_API_KEY}"
      }
    }
  }
}

Skills-only installs don't update automatically.

Terminal bash
npx skills add https://www.nexus402.dev

Every option reads your key from NEXUS402_API_KEY; none writes it into a file. Learn more