Agents

MCP server

Give Claude, Cursor or any MCP client the ability to browse models, price requests and generate images and video with your team's credits.
PropertyValue
Endpointhttps://<your-host>/api/mcp
TransportStreamable HTTP (stateless, JSON responses)
Protocol version2025-11-25 (also 2025-06-18, 2025-03-26, 2024-11-05)
AuthAuthorization: Bearer aio_…, the same API key as the REST API

Claude Code#

bash
claude mcp add --transport http pixwellai https://<your-host>/api/mcp \
  --header "Authorization: Bearer aio_..."

Run /mcp inside Claude Code to confirm the server is connected. For local development against next dev the URL is http://localhost:4200/api/mcp.

Claude Desktop#

Settings → Connectors → Add custom connector works for servers that do not need a header. For key-based auth, add the server to claude_desktop_config.json through the mcp-remote bridge:

claude_desktop_config.json
{
  "mcpServers": {
    "pixwellai": {
      "command": "npx",
      "args": [
        "-y", "mcp-remote", "https://<your-host>/api/mcp",
        "--header", "Authorization: Bearer ${AIO_KEY}"
      ],
      "env": { "AIO_KEY": "aio_..." }
    }
  }
}

Cursor and other clients#

Clients that speak Streamable HTTP natively take the URL and headers directly:

.cursor/mcp.json
{
  "mcpServers": {
    "pixwellai": {
      "url": "https://<your-host>/api/mcp",
      "headers": { "Authorization": "Bearer aio_..." }
    }
  }
}

Tools#

ToolEffectWhat it does
get_balanceread-onlyTeam, role and credit balance, with a low-balance flag and top-up link. create_generation also reports the balance after each charge.
search_templatesread-onlyNatural-language request (“make my dog dance”) → top template matches with a short description, cost and what each needs.
list_templatesread-onlyPaginated templates. query, kind, category, sort (default | popular | newest), limit (10, max 50), cursor.
get_templateread-onlyWhat a template needs (prompt, photos and what each shows, durations, ratios), its fixed cost and an example call.
list_modelsread-onlyPaginated models. query, kind, family, task, limit (10, max 50), cursor. Compact items with default cost and inputs.
get_modelread-onlyFull params spec, pricing explained (formula, default cost, cost per option) and an example call.
estimate_costread-onlyCredits for a model/template + params, and whether the balance covers it.
upload_from_urlwritesImport a public https image/video/audio link into storage; returns an asset URL for images / inputs.
create_generationspends creditsTemplate + images, or model + prompt + params. Waits up to 50 s (wait). idempotency_key makes retries safe.
get_generationread-onlyStatus, outputs and error for one generation.
list_generationsread-onlyThe team's generations, newest first, paginated (10 per page).

Every tool declares MCP annotations (readOnlyHint, idempotentHint, destructiveHint, openWorldHint), so clients can auto-approve the read-only ones and ask before create_generation spends credits.

Compact results

Each result has a one-line summary the model can act on, followed by compact JSON. The same JSON is sent as structuredContent for clients that support it. Lists return 10 items by default and never dump the whole catalog: follow next_cursor only when you need more.

tools/call → search_templates
{
  "content": [{
    "type": "text",
    "text": "Top 3 for “make my dog dance”: macarena-dance – Macarena Dance (video, 80 credits; 1 photo) | …\n\n{\"object\":\"list\",…}"
  }],
  "structuredContent": {
    "object": "list",
    "query": "make my dog dance",
    "data": [
      { "slug": "macarena-dance", "title": "Macarena Dance", "kind": "video", "credits": 80,
        "description": "Video template in Dancing Dogs.", "needs": "1 photo", "preview_url": "https://…" }
    ],
    "has_more": false,
    "next_cursor": null
  }
}

A typical agent flow

“Make my dog dance, here is the photo: https://example.com/rex.jpg”
search_templates   { "query": "make my dog dance", "kind": "video" }
get_template       { "slug": "macarena-dance" }                  → needs 1 photo, costs  80
upload_from_url    { "url": "https://example.com/rex.jpg" }      → { "url": "https://cdn…/uploads/….jpg" }
create_generation  { "template": "macarena-dance",
                     "images": ["https://cdn…/uploads/….jpg"],
                     "idempotency_key": "6f1c…" }                → succeeded / processing
get_generation     { "id": "…" }                                 → only if still processing

create_generation and long jobs

create_generation waits up to 50 seconds by default, which covers most image models. Video often takes longer: the tool then returns the generation with status processing and the agent should call get_generation later. Pass "wait": false to return immediately. Pass an idempotency_key (any unique string): if the client retries the call, the original generation is returned and nothing is charged twice.

Errors

Failures come back as tool results with isError: true and the same { error: { code, message, hint } } body as the REST API, so the model can read the hint and correct itself (for example, choose a valid aspect ratio). Moderation blocks are explained the same way and are never charged.

Rate limits and cost

Each tool call counts toward the key's 60 requests per minute. Agents spend real credits: use a dedicated key, and consider a separate team with a capped balance for experiments.

Raw protocol#

The server is plain JSON-RPC 2.0 over POST, so you can test it without an MCP client:

curl https://<your-host>/api/mcp \
  -H "Authorization: Bearer $AIO_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
       "params":{"name":"list_models","arguments":{"task":"image-to-video","limit":5}}}'
  • Supported methods: initialize, notifications/initialized, ping, tools/list, tools/call.
  • No sessions and no SSE stream; GET /api/mcp returns 405. Batched requests are accepted.