# MCP server

> curva mcp gives any Model Context Protocol client seven tools: decide, route, check, guard, feedback, recipes and find. One command, no server to start first.

Source: https://docs.tarkova.com/curva/guides/mcp/

`curva mcp` lets any [Model Context Protocol](https://modelcontextprotocol.io) client (desktop
assistants, coding agents, IDE agents) call Curva as a set of tools. An agent then gets typed
answers with calibrated probabilities instead of judging in free text, can check an action
against your policy before it acts, and screens untrusted text before it trusts it.

## Add it to a client

One command, with a provider key in the environment or in a `.env` file. There is no server to
start first:

```bash
claude mcp add curva -- curva mcp
```

Or in a JSON client config such as Claude Desktop's `claude_desktop_config.json`:

```json
{"mcpServers": {"curva": {"command": "curva", "args": ["mcp"], "env": {"GEMINI_API_KEY": "..."}}}}
```

## Which server answers

`curva mcp` speaks MCP over **stdio** (JSON-RPC 2.0, one message per line) and sends every
decision through a Curva server, so decisions are cached, calibrated by feedback and audit-logged.
It picks the server in this order:

1. `--url`, or `CURVA_BASE_URL`: your own or a shared server.
2. A server already running on `http://127.0.0.1:7777`.
3. Otherwise it starts its own on a free localhost port and stops it when the client disconnects.
   That server keeps its decisions in `~/.curva/curva.db`, the same file the SDKs use, so
   [`curva dashboard`](/curva/guides/dashboard/) shows what your agents decided.

```bash
curva mcp                                                       # the three steps above
curva mcp --url https://curva.internal --api-key curva_...       # or set CURVA_API_KEY
```

## The tools

| Tool | What the agent uses it for |
|---|---|
| `decide` | Answer typed questions about any JSON: classify, triage, score, extract |
| `route` | Pick which model, agent or tool should handle a request |
| `check` | Ask whether a policy allows an action, before carrying it out |
| `guard` | Screen a text for prompt injection, personal or secret data and toxicity |
| `feedback` | Record the true answer of a past decision, so Curva gets calibrated |
| `recipes` | List the ready question packs, or return one |
| `find` | Search a library of PDFs and text files: the best passages with file, page and snippet, in milliseconds |

The server also sends the client short instructions on when to call each tool, so most agents use
them without extra prompting.

### `decide`

| Argument | Required | Meaning |
|---|---|---|
| `state` | yes | Any JSON to decide about |
| `questions` | one of the two | Key → question, as in [`/v1/decide`](/curva/reference/http-api/#question-fields) |
| `recipe` | one of the two | A [ready question pack](/curva/guides/recipes/) such as `support-triage`, in place of `questions` |
| `model` | no | A model id, a fallback list, `{"council": [...]}`, `{"cascade": [...]}` or `{"race": [...]}` |
| `project` | no | Calibration namespace |
| `think`, `explain`, `mode`, `debias`, `privacy`, `config`, `images` | no | As in [`/v1/decide`](/curva/reference/http-api/) |

The result is the `/v1/decide` response. An answer with `abstain: true` is below the question's
`min_confidence`: the agent should hand that one to a person.

### `route`

| Argument | Required | Meaning |
|---|---|---|
| `prompt` | yes | The request to route |
| `models` | yes | The candidates: name → what it is good at, or a list of names (at least two) |
| `default` | no | The candidate to use when the pick is unsure or cannot be made |
| `min_confidence` | no | Below this, use `default` |
| `model`, `project` | no | As for `decide` |

```json
{"model": "small-fast", "confidence": 0.98, "probabilities": {"small-fast": 0.98, "large-reasoning": 0.02},
 "defaulted": false, "decision_id": "dec_..."}
```

The candidates need not be models: route between agents, tools or queues the same way. See
[Route a prompt to the right model](/curva/guides/routing/).

### `check`

| Argument | Required | Meaning |
|---|---|---|
| `action` | yes | What is about to happen: a sentence, or JSON such as `{"tool": "refund", "amount": 500}` |
| `policy` | yes | The rules in plain words |
| `context` | no | Background such as the conversation so far, one entry per speaker: `[{"caller": "..."}, {"manager": "..."}]` |
| `requester` | no | Who asks for the action, as named in `context` (for example `caller`). Their entries are not shown to the model, so they cannot approve their own request |
| `min_confidence` | no | Below this the verdict is `review` (default 0.8) |
| `deadline_ms` | no | How long to wait for a model (default 10000); past it the verdict is `review` with `fallback: true` |
| `model`, `project` | no | As for `decide` |

```json
{"verdict": "block", "allowed": false, "confidence": 1.0, "decision_id": "dec_..."}
```

`verdict` is `allow`, `block` or `review`. The agent should act only when `allowed` is true.

### `guard`

| Argument | Required | Meaning |
|---|---|---|
| `text` | yes | The text to screen |
| `deadline_ms` | no | How long to wait for a model (default 10000); past it the verdict is `review` with `fallback: true` |
| `model`, `project` | no | As for `decide` |

```json
{"verdict": "block", "confidence": 0.98, "prompt_injection": 0.99, "personal_data": [], "toxicity": 0.0,
 "decision_id": "dec_..."}
```

`prompt_injection` is a probability, `personal_data` lists the kinds found (`email`, `phone`,
`address`, `government_id`, `payment_card`, `health`, `secret`) and `toxicity` runs from 0 (none)
to 3 (severe). These are the questions of the [`guardrails` recipe](/curva/guides/recipes/).

### `feedback`

| Argument | Required | Meaning |
|---|---|---|
| `decision_id` | yes | The decision's `id` (`decision_id` from `route`, `check` and `guard`) |
| `question` | yes | The question key: `route` for a route, `check` for a check |
| `label` | yes | The true answer: an option key, a level index, `true`/`false`, a list of option keys, or the true value |

Once a question has 30 labels its probabilities come back [calibrated](/curva/concepts/calibration/).

### `recipes`

With no argument it lists the packs; with `name` it returns that pack's questions, to read or
adapt before passing them to `decide`.

### `find`

Searches a [library](/curva/guides/library/) collection on the server, with no model call, so it is free and
answers in milliseconds. `collection` and `query` are required; `k` (default 10), `file` (one file
id) and `pages` (`[first, last]`) narrow it. Each hit has its file, page, snippet and score.

## When something fails

- **A mistake in the call** (a missing argument, an unknown question type, a wrong API key) comes
  back as a tool error (`isError: true`) whose text is Curva's message, so the agent can fix the
  call and try again.
- **A busy server** (429 or 503) is asked again, up to two more times, waiting as long as its
  `Retry-After` says.
- **No model can answer** (the server is down, or every model failed or timed out, or none
  answered within `deadline_ms`, 10 s unless you set it): `check` and `guard` answer `review`
  and `route` answers its `default`, each with `fallback: true` and the reason in `error`. An action is never allowed and a text never passed because Curva was
  unreachable. `decide`, and `route` without a `default`, return a tool error.

## Protocol details

Supported methods: `initialize`, `notifications/initialized`, `ping`, `tools/list` and
`tools/call`, for protocol versions 2024-11-05 to 2025-11-25. Calls run concurrently: a client
that sends several at once gets each answer as soon as it is ready. Every successful result
carries the answer twice, as `structuredContent` and as the same JSON in a text block, for
clients that read only one of them. The MCP step itself adds about a millisecond; the time of a
call is the model's.
