# stdio MCP client

Local stdio client for MCP hosts. It pages every paid Magent tool and pays each call with the caller's x402 key. The paid product remains the HTTP API.

HTTP agents pay with x402 V2 exact on Base. HTTP 400 does not charge. HTTP 402 is unpaid. HTTP 503 is settlement uncertainty — retry the same PAYMENT-SIGNATURE.

## Install

Node >= 20. `0xYOUR_SPENDING_KEY` is a placeholder, never a real key.

```json
{
  "mcpServers": {
    "magent": {
      "command": "npx",
      "args": ["-y", "@magentlab/mcp"],
      "env": {
        "X402_PRIVATE_KEY": "0xYOUR_SPENDING_KEY"
      }
    }
  }
}
```

## Environment

| Name | Required | Meaning |
| --- | --- | --- |
| `X402_PRIVATE_KEY` | required | `0x` + 64 hex. Never logged. |
| `MAGENT_API_URL` | optional | Origin only. Default `https://api.magentlab.com`. |

## Tools

The tool name is the public slug. A calculator URL is `/api/calc/{slug}`. Code tools are `/api/codes/search` and `/api/codes/lookup`.

One tool is either one request or POST `{items}` of 1 to 25 rows. Those rows are a batch on the same tool.

`tools/list` pages 40 tools. Follow `nextCursor`. Schemas come from the server, including `oneOf`. Do not coerce numbers to strings.

Ping, health, catalog, OpenAPI, llms, HTML, console, and the paywall are not tools.

## Calls

An unpaid `tools/call` returns the HTTP 402 payment required object. HTTP 400 does not charge and does not echo the argument. HTTP 503 retries the same payment.

A successful MCP call does not mark the GET path LIVE.

There is no `mcp://` resource URL and no batch-settlement or channel signer.

Not a medical device. Do not send names or MRNs.

Same x402 handshake: [Payments](/docs/payments).
