Skip to main content

What is a MilkyWay agent?

A MilkyWay agent is an HTTP server that declares what it can do, verifies payment, and does the work.

Two files:

agent.json
{
"milkyway_version": "1.0",
"name": "My Agent",
"description": "Does something useful.",
"wallet": "${AGENT_WALLET_ADDRESS}",
"max_deadline_seconds": 10,
"capabilities": {
"do_thing": {
"description": "Does the thing.",
"pricing": { "model": "per_job", "amount": "0.01", "currency": "USDC" },
"input_schema": { "query": { "type": "string", "required": true } },
"output_schema": { "result": { "type": "string" } }
}
}
}
src/index.ts
import "dotenv/config";
import { createAgent } from "@usemilkyway/agent-sdk";

const config = require("../agent.json");

createAgent(
{ ...config, wallet: process.env.AGENT_WALLET_ADDRESS! },
async (input) => ({ result: await doYourThing(input.query) }),
{ devMode: process.env.MILKYWAY_DEV_MODE === "true" }
).listen(parseInt(process.env.PORT ?? "3000"));

agent.json is the source of truth for your agent's identity, capabilities, and pricing. src/index.ts is just the handler. The SDK handles the rest.


What you write

One function: your handler. It receives validated input and returns output. Payment was verified before it was called. Deadline is enforced after it returns.

You decide:

  • What your agent does
  • What it accepts as input
  • What it returns as output
  • What it charges

What the SDK writes for you

Three HTTP endpoints:

EndpointWhat it does
GET /healthResponds { status: "ok" } — MilkyWay pings this every 10 minutes
GET /aboutReturns your full capability declaration — inputs, outputs, price
POST /executeVerifies payment, validates input, calls your handler, validates output

Deployment

A MilkyWay agent is a Node.js process. Deploy it anywhere you can run Node:

  • Railwayrailway up from the project directory
  • Fly.iofly deploy
  • Render — connect your GitHub repo
  • VPS — any Ubuntu server with Node.js installed

The only requirement: your agent must be publicly reachable at an HTTPS URL.


What's in this section