# MCP and A2A

The sandbox is a credentialed MCP server at `https://sandbox.precise.ai/api/mcp` that answers over Streamable HTTP for your company's isolated enclave (`Authorization: Bearer $PRECISE_SANDBOX_KEY` or the URL-scoped endpoint `/api/mcp/$PRECISE_SANDBOX_KEY`). The unified Access deployment serves the product tools, four embeddable cards and A2A for the thin app and headless clients.

| Capability | Runtime | Status |
|---|---|---|
| Discover the sandbox MCP tools, resources and five prompts with your workspace key | Sandbox | Live |
| Discover product tools and four cards on configured credentialed Access | Sandbox | Preview |
| Read the Access A2A agent card and send a JSON-RPC message to `/api/a2a` | Sandbox | Preview |

## Connect a client

Request a private per-company workspace key (`penv_...`) at `https://sandbox.precise.ai`, then export `PRECISE_SANDBOX_KEY` (or paste your URL-scoped `/api/mcp/<key>` endpoint directly):

```sh
claude mcp add --transport http precise-sandbox https://sandbox.precise.ai/api/mcp --header "Authorization: Bearer $PRECISE_SANDBOX_KEY"
codex mcp add precise-sandbox --url "https://sandbox.precise.ai/api/mcp/$PRECISE_SANDBOX_KEY"
```

For Cursor, add your URL-scoped server to `mcp.json`:

```json
{"mcpServers": {"precise-sandbox": {"url": "https://sandbox.precise.ai/api/mcp/<YOUR_SANDBOX_KEY>"}}}
```

## The endpoint

`POST /api/mcp` answers protocol revisions `2026-07-28`, `2025-11-25`, `2025-06-18` and `2025-03-26` with plain JSON. Any instance answers any request, so a `tools/list` works with no `initialize` before it.

A 2025-revision client sends plain JSON-RPC with `Accept: application/json, text/event-stream`. A request that leaves that header out is answered with HTTP 406. Legacy initialization echoes the supported revision you requested: `2025-03-26`, `2025-06-18` or `2025-11-25`.

```json try mcp
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-11-25", "capabilities": {}, "clientInfo": {"name": "docs-example", "version": "1.0"}}}
```

A `2026-07-28` client states its revision on every request: the `MCP-Protocol-Version` and `Mcp-Method` headers, `Mcp-Name` on a tool call, and two keys under `params._meta`. The answer then links the run and the guide as `resource_link` content.

```sh try
curl -s -X POST https://sandbox.precise.ai/api/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -H 'MCP-Protocol-Version: 2026-07-28' \
  -H 'Mcp-Method: tools/call' \
  -H 'Mcp-Name: size_holdout' \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "size_holdout", "arguments": {"order_id": "ORD-067"}, "_meta": {"io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientCapabilities": {}}}}'
```

## The ten tools

```json try mcp
{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}
```

| Tool | What it answers | Main inputs | Scope |
|-|-|-|-|
| `get_guide` | What the tables, measures, methods and workflows mean | `section`, `name` | Workspace key (`precise:read`) |
| `get_book` | The book, a search of its orders, or one order in full | `id`, `query`, `format`, `holdout`, `campaign_id`, `limit`, `offset` | Workspace key (`precise:read`) |
| `query` | One read-only SQL query or one structured join | `sql` or `join_spec`, `max_rows` (1 to 200), `timeout_ms` (100 to 120,000) | Workspace key (`precise:query`) |
| `run_analysis` | One Gateway method or one workflow | `method` or `workflow`, `order_id`, `fixture`, `describe`, `list_contracts` | Workspace key (`precise:run`) |
| `size_holdout` | The smallest Audience Holdout that detects a lift, or what a test can detect | `order_id`, or `baseline_rate`, `mde`, `daily_volume`, `max_days`, `max_holdout_pct`, `alpha`, `power` | Workspace key (`precise:run`) |
| `get_calls` | The record of scored Decisions, or one Decision | `call_id`, `status`, `order_id`, `campaign_id`, `limit` | Workspace key (`precise:read`) |
| `inspect_audit` | A verified run, reopened by its `run_id` | `run_id` | Workspace key (`precise:read`) |
| `make_call` | Records a Decision and its forecast range before spend moves | `known`, `chosen`, `predicted_value`, `lower`, `upper`, `confidence_level`, `gateway_run_id` | Workspace key (`precise:record`) |
| `score_call` | Scores a recorded Decision against its outcome | `call_id`, `realized_value`, `lesson` | Workspace key (`precise:record`) |
| `advance_time` | Moves the workspace clock | `hours` (1 to 336) | Workspace key (`precise:record`) |

The record these tools read and write is a Decision. The hosted sandbox still serves it under its older tool names, `get_calls`, `make_call` and `score_call`, so the examples on this site use those names exactly.

## How an answer reads

Every tool answer opens with one or two sentences. `Measured:` is read from the records. `Said:` is what Precise predicts or proposes, with its range. An answer that ran a query, a method or a workflow ends its sentence with the run and a short digest. One `structuredContent` object follows, shaped by the tool's `outputSchema`, with the full `run_id` and `result_digest`.

Read the book. On the synthetic book the answer is measured: 84 orders, $19,851,772 of media spend, 13 orders with an Audience Holdout.

```json try mcp
{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "get_book", "arguments": {}}}
```

Query it. The answer is three rows, led by online video at $9,262,672.56 of media spend.

```json try mcp
{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "query", "arguments": {"sql": "SELECT format, ROUND(SUM(media_spend_usd), 2) AS media_spend_usd, SUM(impressions) AS impressions FROM gold_daily_cube GROUP BY format ORDER BY media_spend_usd DESC"}}}
```

Size a test. For order `ORD-067` the answer is a `Said:` sentence: with 48 units per arm, the order's cap, the test can detect a lift of 13.8 percentage points, and the target of 0.40 points needs 57,487 units per arm.

```json try mcp
{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "size_holdout", "arguments": {"order_id": "ORD-067"}}}
```

## Resources and prompts

| Resource | Holds |
|-|-|
| `precise://guide` | What the tables, measures, methods and workflows mean, under one digest |
| `precise://catalog` | The pinned Parquet catalog: every table, its columns and the catalog digest |
| `precise://runs/{run_id}` | One verified run, reopened |
| `precise://guide/methods/{family}/{method}` | One method: the question it answers, what it assumes, how to say its result |
| `precise://guide/workflows/{name}` | One workflow with its real steps |

```json try mcp
{"jsonrpc": "2.0", "id": 1, "method": "resources/read", "params": {"uri": "precise://guide"}}
```

There is one prompt per workflow.

| Prompt | Steps | The question it answers |
|-|-|-|
| `understand-the-book` | 20 | Where is spend leaking, and which signals are confounded? |
| `find-the-next-move` | 10 | Which reallocation or bid change earns the most for its risk? |
| `design-the-test` | 5 | What is the smallest Audience Holdout that can detect the lift you care about? |
| `measure-and-learn` | 11 | Did the decision land inside its predicted range once outcomes matured? |
| `plan-adaptive-campaign-loop` | 5 | How do the current setup and a changed setup compare, period by period, while outcomes mature? |

## Authentication failure (`401 workspace_required`)

Without a valid workspace key, sandbox MCP and REST calls fail closed with HTTP 401. The `www-authenticate` header reads `Bearer realm="precise-sandbox", resource_metadata="https://sandbox.precise.ai/.well-known/oauth-protected-resource"`. Request a private per-company workspace key on `https://sandbox.precise.ai`.

```json
{
  "jsonrpc": "2.0", "id": 8,
  "error": {
    "code": -32001,
    "data": {
      "code": "workspace_required", "tool": "make_call", "scope": "precise:record",
      "works_without_a_key": ["get_guide", "get_book", "query", "run_analysis", "size_holdout", "get_calls", "inspect_audit"],
      "resource_metadata": "https://sandbox.precise.ai/.well-known/oauth-protected-resource"
    }
  }
}
```

## The app's MCP server

The app uses the same Access control plane as an API client. On the pinned public-test configuration, `tools/list` returns 34 tools with the optional ratio worker and 33 without it. `resources/list` includes the guide, catalog and four self-contained cards. A host can discover which card belongs to a tool from `_meta.ui.resourceUri`.

| Tool | Card URI |
|-|-|
| `get_overview` | `ui://precise/cards/figure-card` |
| `get_decision` | `ui://precise/cards/decision-card` |
| `size_holdout` | `ui://precise/cards/holdout-dial-card` |
| `get_proof_file` | `ui://precise/cards/proof-verifier-card` |
| `verify_proof_file` | `ui://precise/cards/proof-verifier-card` |

Send `Accept: application/json, text/event-stream`. The deployed public book returns JSON. Unified Access can return a JSON-RPC response as an SSE message. Decode its `data:` field when the media type is `text/event-stream`. An HTTP 200 can still contain a JSON-RPC error or `result.isError:true`.

## A2A

At your Access origin, `/.well-known/agent-card.json` advertises both 1.0 (`SendMessage`) and 0.3 (`message/send`) at `/api/a2a`. Send a single structured part with `skill` and `input`. The eligible skills depend on the caller and deployment. The public sandbox returns 404 for that agent card.

Selected fields from the completed task follow. The full artifact also contains the measured answer, its source and the limits of the comparison.

```sh preview
curl -s -X POST "$PRECISE_URL/api/a2a" -H 'content-type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"SendMessage","params":{"message":{"role":"ROLE_USER","messageId":"docs-example","parts":[{"data":{"skill":"ask","input":{"question":"Which deal lost to the open line?"}}}]}}}'
```


```json answer
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "task": {
      "status": {
        "state": "TASK_STATE_COMPLETED"
      },
      "artifacts": [
        {
          "name": "ask",
          "parts": [
            {
              "data": {
                "question": "Which deal lost to the open line?",
                "understood": true
              }
            }
          ]
        }
      ]
    }
  }
}
```

For governed buying, use the buyer and governance URLs published for your tenant. See [AdCP governance and buying](adcp-governance-and-buying.md).

## Related

[REST API quickstart](rest-api-quickstart.md) · [API and MCP playground](../../reference/playground.md) · [Limits and errors](../../reference/limits-and-errors.md)
