Shader
Use the MCP server

DocsGuides21 of 35 · 6 min read

Use the MCP server

Connect an MCP client with an agent token to rent, generate and read receipts as tools, or with no token to rent a GPU over x402 from a wallet.

Shader runs an MCP server at https://api.shader.win/mcp, over stateless streamable HTTP. A client signs in with an agent token and gets eight tools. You need a key made in Create an agent key and credits in its wallet. Each tool calls the same service as the matching API route, so headroom, the key's caps and the errors are the same as over HTTP.

#Connect a client

  1. Make a key

    Create an agent key on Agents and copy its token.

  2. Add the server

    Add the server to your MCP client's configuration, with the token in the Authorization header:

    {
      "mcpServers": {
        "shader": {
          "url": "https://api.shader.win/mcp",
          "headers": {
            "Authorization": "Bearer shdr_<YOUR_AGENT_TOKEN>"
          }
        }
      }
    }

    The Agents page shows the same snippet. The server takes agent tokens only, not wallet sessions; a request without one answers 401 with WWW-Authenticate: Bearer realm="shader".

#The tools

A tool answers with one text item holding the JSON of its result. A failed call answers with isError: true and the API error body, so an agent sees CREDITS_TOO_LOW or AGENT_CAP_EXCEEDED with the same fields as over HTTP.

#list_gpus

Every GPU model with its id, price and free machines. Result: GpuCatalog.

No arguments.

#rent_gpu

Launches a GPU, like POST /instances. Result: InstanceDetail.

ArgumentTypeMeaning
gpustringCatalog id, such as h100-sxm-80gb.
ssh_public_key (optional)stringYour SSH public key. Without one, a password is generated.

#get_instance

One instance with its meter, connection details and last settlement. Result: InstanceDetail.

ArgumentTypeMeaning
instance_idstringInstance id from rent_gpu.

#stop_gpu

Stops an instance; the last stretch settles. Result: StopInstanceResponse.

ArgumentTypeMeaning
instance_idstringInstance id from rent_gpu.

#get_balance

The credit balance, plus agentKey with the key's address, both caps and spentTodayBaseUnits. Result: CreditBalance.

No arguments.

#generate

Starts a generation, like POST /jobs. For voice, prompt is the text to speak. A video without outputSeconds in options runs for 4 seconds. Result: Job.

ArgumentTypeMeaning
kindone of "image", "video", "voice", "asset3d"image, video, voice or asset3d; for list_receipts, a receipt kind.
promptstringWhat to generate, or the text to speak for voice.
options (optional)object (free form)The kind's options, as in the generation request.

#get_job

One job with its progress, file and receipt. Result: Job.

ArgumentTypeMeaning
job_idstringJob id from generate.

#list_receipts

The wallet's receipts, newest first, 24 unless limit says otherwise. Result: ReceiptPage.

ArgumentTypeMeaning
kind (optional)one of "deposit", "rental_settle", "generation", "x402"Only receipts of this kind: deposit, rental_settle, generation or x402.
limit (optional)integerHow many, 1 to 100.

#Work with the tools

  1. Check what it can spend

    get_balance returns the credit balance and the key's per-request cap, per-day cap and what it spent today.

  2. Rent

    list_gpus gives the models and their ids. rent_gpu with a gpu id and, optionally, an SSH public key launches one. The answer carries the instance id, its state and, once it is running, the SSH command and the Jupyter link.

  3. Watch and stop

    get_instance reads the meter and the last settlement. stop_gpu stops the machine and settles the last stretch.

  4. Generate

    generate with a kind and a prompt starts a job. For voice, prompt is the text to speak. get_job reads its progress, and once it is done, the file and its receipt.

  5. Account for it

    list_receipts returns what the key's wallet was charged, newest first.

#Rent with no token

An MCP client that can pay x402 can rent a GPU with nothing but a wallet holding USDC, following the x402 MCP transport. With no token the server lists only the tools below.

  1. Connect without a token

    Add the server with its URL alone:

    {
      "mcpServers": {
        "shader": {
          "url": "https://api.shader.win/mcp"
        }
      }
    }
  2. Ask for the rental

    Call rent_gpu with gpu and max_seconds. The result has isError: true and the PaymentRequired quote in structuredContent, with the same JSON in content[0].text: the locked rate, the ceiling and the memo, as in Rent a GPU over x402.

  3. Pay

    Sign the channel open for that ceiling, then call rent_gpu again with the payment in _meta["x402/payment"].

  4. Use and stop it

    The result carries the instance with SSH and Jupyter, the stop token, and the settlement in _meta["x402/payment-response"]. Read it with get_instance, add time with extend_gpu, and end it with stop_gpu, each with instance_id and stop_token.

#list_gpus (no token)

The GPU catalog.

No arguments.

#rent_gpu (no token)

Rents a GPU over x402. Called without payment it returns isError: true with the PaymentRequired quote; called again with the payment in _meta["x402/payment"] it launches and returns the instance, the stop token and _meta["x402/payment-response"].

ArgumentTypeMeaning
gpustringCatalog id, such as h100-sxm-80gb.
ssh_public_key (optional)stringYour SSH public key. Without one, a password is generated.
max_seconds (optional)integerLongest the rental may run, in seconds.

#extend_gpu (no token)

Extends an x402 rental with another channel at its locked rate, paid the same way as rent_gpu.

ArgumentTypeMeaning
instance_idstringInstance id from rent_gpu.
stop_tokenstringThe rental's stop token, shdrstop_….
secondsintegerSeconds to add.

#stop_gpu (no token)

Stops an x402 rental with its stop token; the answer has each channel's charge and refund.

ArgumentTypeMeaning
instance_idstringInstance id from rent_gpu.
stop_tokenstringThe rental's stop token, shdrstop_….

#get_instance (no token)

One x402 rental, read with its stop token.

ArgumentTypeMeaning
instance_idstringInstance id from rent_gpu.
stop_tokenstringThe rental's stop token, shdrstop_….

#What happened

  1. The call

    Each tool call ran the same service as the matching API route, under the key's wallet.

  2. Admission

    A rental or a generation was checked against the key's caps before it started.

  3. Settlement

    A rental settled every 60 seconds with the key named on each line; a generation settled once when its file was ready.

#The receipt

Every charge is a Receipt event naming the key. list_receipts returns them; on Receipts, filter by the key. Receipts explains the fields.

#If it fails

What you seeWhyNext
HTTP 401 with WWW-AuthenticateNo agent token, or a wallet session tokenSend Authorization: Bearer shdr_…
isError with AGENT_CAP_EXCEEDEDThe job's cost, or a rental's rate for 1 hour, is above the per-request capPick a smaller job or GPU, or raise the cap
isError with AGENT_DAILY_CAP_EXCEEDEDNot enough of the day's cap is leftWait for 00:00 UTC or raise the cap
isError with CREDITS_TOO_LOWThe wallet's credits do not cover headroom or the estimateThe wallet owner adds credits
isError with AGENT_TOKEN_REVOKED or AGENT_KEY_REVOKEDThe key was revokedMake a new key