# JSON-RPC

Call Abazi's six agent tools with plain JSON-RPC 2.0 POST requests, without an MCP client or a session, from any language with an HTTP client.

Abazi's MCP endpoint is stateless streamable HTTP with JSON responses. That makes it a plain JSON-RPC 2.0 endpoint as well: one POST carries one request, one JSON body comes back, and no session id is kept between calls. An agent that has no MCP client calls the same six tools, with the same arguments and results, using only an HTTP library.

## Endpoint and authentication [#endpoint-and-authentication]

| Setting | Value |
| --- | --- |
| URL | `https://api.52-28-238-205.sslip.io/mcp` |
| Method | `POST`, one JSON-RPC 2.0 request per body |
| `Authorization` | `Bearer agk_test_...`, on every request |
| `Content-Type` | `application/json` |
| `Accept` | `application/json, text/event-stream` |
| Session | None. No `initialize` handshake is required before a call, and no session header comes back. |
| Response | `200` with `Content-Type: application/json` |

The `Accept` header must list both types, as the MCP transport requires. The server answers with plain JSON, never a stream. Keep the credential in a secret manager or in an environment variable such as `ABAZI_AGENT_KEY`; it identifies the agent and carries no spending power on its own. See [Get an agent credential](/docs/agents#get-an-agent-credential).

## Call a tool [#call-a-tool]

`tools/call` runs one tool. This request asks for the agent's spending status:

```bash title="Terminal"
curl -s https://api.52-28-238-205.sslip.io/mcp \
  -H "Authorization: Bearer $ABAZI_AGENT_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_spending_status","arguments":{}}}'
```

<VerifiedSnippet what="tools/call get_spending_status over plain JSON-RPC" exit="200">

```json title="Response"
{"jsonrpc":"2.0","id":3,"result":{"content":[{"type":"text","text":"{\n  \"available\": \"1200000\",\n  \"reserved\": \"100000\",\n  \"spent\": \"700000\",\n  \"limit\": \"2000000\",\n  \"asset\": \"USDC\",\n  \"hard_cap\": \"500000\",\n  \"auto_threshold\": \"100000\",\n  \"plan_hard_cap\": \"1500000\",\n  \"mandate_expires_at\": \"2026-11-28T23:59:59+00:00\",\n  \"mandate_status\": \"active\"\n}"}],"isError":false}}
```

</VerifiedSnippet>

The tool's result is a JSON string in `result.content[0].text`. Parse it a second time:

```json title="result.content[0].text, parsed"
{
  "available": "1200000",
  "reserved": "100000",
  "spent": "700000",
  "limit": "2000000",
  "asset": "USDC",
  "hard_cap": "500000",
  "auto_threshold": "100000",
  "plan_hard_cap": "1500000",
  "mandate_expires_at": "2026-11-28T23:59:59+00:00",
  "mandate_status": "active"
}
```

Amounts are strings in base units of the asset. USDC has 6 decimals, so `1200000` is 1.20 USDC: this agent can still spend 1.20 of a 2.00 limit, with 0.70 spent and 0.10 held for a purchase in flight. A single purchase above 0.50 (`hard_cap`) is denied, and one above 0.10 (`auto_threshold`) waits for approval. Strings keep the arithmetic exact; convert with a decimal type, never a float.

## The other methods [#the-other-methods]

### `initialize` [#initialize]

Optional. It returns the protocol version, the server's capabilities and its name. A script can skip it and call `tools/call` directly.

```bash title="Terminal"
curl -s https://api.52-28-238-205.sslip.io/mcp \
  -H "Authorization: Bearer $ABAZI_AGENT_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"curl","version":"1"}}}'
```

<VerifiedSnippet what="initialize over plain JSON-RPC" exit="200">

```json title="Response"
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-03-26","capabilities":{"experimental":{},"prompts":{"listChanged":false},"resources":{"subscribe":false,"listChanged":false},"tools":{"listChanged":false}},"serverInfo":{"name":"gateway","version":"1.30.0"}}}
```

</VerifiedSnippet>

### `tools/list` [#toolslist]

Returns the six tools, each with a description and a JSON Schema for its arguments. Read it once to build your own function definitions for a non-MCP agent framework.

```bash title="Request body"
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
```

```json title="Response (shortened)"
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "tools": [
      {
        "name": "search_catalog",
        "description": "Find paid services you can buy, with price, networks and merchant trust tier. ...",
        "inputSchema": { "type": "object", "required": ["query"], "properties": { "query": { "type": "string" }, "category": { "...": "..." }, "max_price_base_units": { "...": "..." }, "limit": { "type": "integer", "default": 10, "minimum": 1, "maximum": 20 } } }
      },
      { "name": "request_purchase", "description": "Buy one paid resource by service_id or url. ...", "inputSchema": { "...": "..." } }
    ]
  }
}
```

### `tools/call` for search and purchase [#toolscall-for-search-and-purchase]

The body has the same shape for every tool: `params.name` is the tool and `params.arguments` its input. Arguments and results are the ones documented in the [MCP tool reference](/docs/mcp).

```json title="search_catalog"
{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"search_catalog","arguments":{"query":"forecast","limit":5}}}
```

```json title="request_purchase"
{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"request_purchase","arguments":{"service_id":"svc_...","task_id":"weekly-report-42","idempotency_key":"weekly-report-42-forecast","purpose":"Weather forecast for the logistics summary"}}}
```

The result of `request_purchase` is in `result.content[0].text`, with a `status` of `paid`, `submitted`, `awaiting_approval` or `free`. See [`search_catalog`](/docs/mcp/search-catalog), [`request_purchase`](/docs/mcp/request-purchase) and [`get_spending_status`](/docs/mcp/get-spending-status) for every field.

## Errors [#errors]

Two kinds of failure come back, and they look different.

**JSON-RPC error object.** A request the protocol cannot parse or route, such as malformed JSON or an unknown method, returns an `error` member with a numeric `code` and a `message` instead of a `result`. Fix the request; nothing was attempted.

**Tool result with `isError: true`.** A request that reached a tool and failed returns a normal `result` with `isError` set to `true`. The text block is JSON with a reason code and the next step:

```json title="result.content[0].text when isError is true"
{ "error_code": "POLICY_DENIED", "reason_code": "BUDGET_EXCEEDED", "message": "...", "retryable": false, "next_action": "Call get_spending_status.", "intent_id": "pi_..." }
```

This covers policy denials, invalid arguments (`VALIDATION_ERROR`) and a missing, rotated or revoked credential (<ReasonCode code="AGENT_CREDENTIAL_INVALID" />). The HTTP status is still `200`, so check `isError` on every call. Act on `retryable` and `next_action`, and never retry a denial with a new idempotency key. Every reason code is in the [reason code reference](/docs/api/errors-and-reason-codes).

## When to choose JSON-RPC [#when-to-choose-json-rpc]

| Choose | When |
| --- | --- |
| [An MCP client](/docs/agents/any-mcp-client) | Your agent already runs in an MCP host. The client discovers the tools and handles the protocol for you. |
| JSON-RPC | There is no MCP client: a script, a cron job, an agent framework without MCP support, or any language with an HTTP client. You get the same six tools with the same semantics as MCP clients, without an MCP library. |
| [REST](/docs/agents/http-api) | You need more than the six agent tools. REST covers the full API surface, with resource URLs, `Idempotency-Key` headers and an OpenAPI contract for typed clients. |

## Next steps [#next-steps]

<Cards>
  <Card title="MCP tools" href="/docs/mcp" description="Inputs, results and errors of the six tools." />
  <Card title="Any MCP client" href="/docs/agents/any-mcp-client" description="Connect an MCP host or your own MCP agent." />
  <Card title="Plain HTTP" href="/docs/agents/http-api" description="The same operations over the REST API." />
</Cards>

