# The MCP server

The DFO serves one MCP server, named `dfo`, over streamable HTTP.

Server address: `https://developmentfinance.org/mcp`

Any client can call the endpoint without an API key or sign-in. [Connect an assistant](/docs/start/connect-an-assistant) has the set-up steps for every client.

## Tools

| Tool          | Title                 | What it does                                                                                                                                           |
| ------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `search`      | Search DFO data       | Matches a query to DFO data and returns a `spec_id` that `get_data` fetches. Takes up to 6 parts, one per indicator.                                   |
| `get_data`    | Get data              | Fetches the data for a `spec_id` as a frame, with its source. Its `scope` argument changes the places, years, or unit before the fetch.                |
| `run_steps`   | Run analysis steps    | Runs a plan of up to 12 analysis steps in one call.                                                                                                    |
| `chart`       | Chart a frame         | Draws a frame as a trend chart, a ranked bar chart, a headline card, or a table.                                                                       |
| `describe`    | Describe a reference  | Describes any id (up to 8 at once). `sources` lists the DFO's sources, `skill:<id>` describes a skill, and `op:<name>` gives an operation's arguments. |
| `export_data` | Export data as a file | Writes a frame as CSV, Excel, or Parquet, optionally zipped with `README.md`, `datapackage.json`, and `CITATION.cff`, and returns a public link.       |
| `get_skill`   | Load a skill          | Loads a skill's `SKILL.md` and lists its other files, or reads one file when given `path`.                                                             |

`search`, `get_data`, `describe`, and `get_skill` are read-only. The server sends instructions when a client connects. They describe how the tools fit together. Call `get_skill("dfo")` for the `dfo` skill and worked plans.

`export_data` returns the file's link in `url`. Its `cite` field gives the name of the field that contains the link to cite:

- For data from `get_data`, `export_data` also pins the version and returns the URL of that version's page on /data in `snapshot_url`. The DFO keeps a pinned version indefinitely. `cite` is `"snapshot_url"`.
- If the pin fails, for example because the caller has reached the daily limit, the response has no `snapshot_url`, `snapshot_note` gives the reason, and `cite` is `"url"`.
- A computed result from `run_steps` has no page on /data, so `cite` is `"url"`.

### Frames

`get_data` returns a frame reference as a pair of `spec_id` and `content_version`. The `spec_id` identifies a spec and stays the same when the data is refreshed. The `content_version` identifies one set of rows and changes when the rows change, for example when the publisher revises the data. Pass the pair to `run_steps`, `chart`, `describe`, and `export_data`. To cite the exact data an answer used, export the frame and cite the link in the field whose name is in `cite`.

Every `get_data` result and every frame from `run_steps` ends with a `Next:` line that lists likely follow-ups as `run_steps` steps.

### Analysis operations

A `run_steps` step has the shape `{id, op, args}`, and a step's frame can reference an earlier step's `id`. The server checks every step before running any. A plan can call these operations:

- `filter`, `aggregate`, `rank`, `share_of`, `growth`, `compare`, and `join`
- the shortcuts `top_n`, `share_of_total`, `change_over`, and `total_by`
- `chart`, which takes the same arguments as the `chart` tool

Call `describe` with `ref` set to `op:<name>` for an operation's full input schema. `share_of` with `operation` set to `quotient` divides one indicator by another in any two units, such as debt service per person.

### Charts

`chart` returns a component with an id and a write token that let a later call revise it. Clients that declare the MCP Apps extension draw the component as an interactive view. Clients that declare capabilities without MCP Apps get the component's data as a Markdown table in the reply.

### Skills

A `search` result can list matching skills, which `get_skill` loads by id. The server also exposes skills as resources (`skill://<id>/SKILL.md`, `skill://<id>/_manifest`, and `skill://<id>/<path>`) and through the Skills over MCP extension. A skill file longer than 32,000 characters comes in pages, and a page ends with the call to read the next one.

## Limits

| Limit                        | Value                                                                                                    |
| ---------------------------- | -------------------------------------------------------------------------------------------------------- |
| A tool call or resource read | 45 seconds, then the server cancels the request                                                          |
| Requests to `/mcp`           | 300 per minute from one IP address, counted by the site                                                  |
| Concurrent calls             | Set per deployment, per server instance. The server refuses excess calls immediately.                    |
| Calls per second             | Set per deployment, in one token bucket across all callers. The server refuses excess calls immediately. |
| Rows in a frame              | 250,000                                                                                                  |
| Steps in one `run_steps`     | 12                                                                                                       |
| Parts in one `search`        | 6                                                                                                        |
| Ids in one `describe`        | 8                                                                                                        |

Claude, ChatGPT, and Gemini call from their providers' IP addresses, so multiple users share the 300-request-per-minute limit for one IP address. Requests over that limit get HTTP 429 with a `Retry-After` header.

A large `get_data` fetch can take longer than one 45-second call. A few seconds before the limit, the server refuses the call with `operation_still_processing` while the fetch continues upstream. Repeating the same call returns the data once the fetch finishes.

## Refusals

A refusal is a tool result with `isError` set. Its text gives the cause and the next step, and `_meta` has `{"code": ...}` under the key `org.one.dfo/refusal`. Its `structuredContent` contains the refusal as JSON.

```json
{
  "code": "operation_still_processing",
  "retry_mode": "retry_after_delay",
  "message": "This dataset is still being prepared upstream …",
  "fix": { "operation_id": "…", "last_status": "running", "elapsed_s": 30.2 },
  "retry_after_s": 5.0
}
```

`fix` gives what the next call needs: the corrected values for a `correct_and_retry` refusal, or, as here, the state of the work to wait for. `retry_after_s` appears when waiting will help. `retry_mode` sets the client's next step.

| `retry_mode`         | What to do                                                    |
| -------------------- | ------------------------------------------------------------- |
| `correct_and_retry`  | Change an argument, using `fix`, and call again.              |
| `refresh_then_retry` | Fetch fresh state, such as a new `get_data` call, then retry. |
| `retry_after_delay`  | Repeat the same call after `retry_after_s`.                   |
| `do_not_retry`       | Stop. This call cannot succeed on this server.                |

Clients get these refusal codes most often.

| Code                          | Cause                                                                                                                      | Fix                                                           |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| `entity_ambiguous`            | A name matches more than one place or party, such as "Congo"                                                               | Call again with one of the candidates the refusal lists       |
| `entity_not_found`            | A name matches nothing in the DFO                                                                                          | Correct the name                                              |
| `definition_not_held`         | The server has no stored spec for the `spec_id`                                                                            | Run `search` again                                            |
| `over_ceiling`                | A `get_data` fetch is larger than the frame limit                                                                          | Narrow the places or years                                    |
| `frame_too_large`             | A `run_steps` result is larger than the frame limit                                                                        | Narrow the input frames                                       |
| `operation_still_processing`  | A large fetch continues upstream past the call limit                                                                       | Repeat the same call after `retry_after_s`                    |
| `comparison_periods_disjoint` | A `compare` step's two sides have no period in common                                                                      | Pick frames or windows that overlap                           |
| `cross_frame_unit_mismatch`   | Two frames in one step are in different units                                                                              | Fetch both in one unit, or use `share_of` with `quotient`     |
| `growth_gap_year`             | No indicator has numbers in both the first and last year of a `growth` window for any place or provider and recipient pair | Use the window the refusal gives                              |
| `rate_limited`                | The server is at its concurrent-call or calls-per-second limit                                                             | Repeat after `retry_after_s`                                  |
| `service_unavailable`         | An upstream service failed or timed out                                                                                    | Repeat after `retry_after_s`                                  |
| `capability_unavailable`      | This deployment has turned the feature off                                                                                 | None                                                          |
| `tool_not_found`              | The tool name is not one of the seven                                                                                      | Use one of the tools listed in `fix`                          |
| `internal_error`              | A tool failed with no more specific refusal                                                                                | Send the time of the call and the tool's name to data@one.org |

A `search` part with the status `no_data` or `unsupported` is a result, not a refusal. A `no_data` part means the DFO has no data for that part and may list related indicators. An `unsupported` part means the question is outside the DFO's scope and gives the reason.

## Troubleshooting

| Problem                                                           | Cause                                                  | Fix                                                          |
| ----------------------------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------ |
| A redirect on connect, or "server unreachable" with a 308 in logs | The URL ends in `/mcp/`                                | Use `/mcp`, omitting the trailing slash                      |
| HTTP 429 from the site                                            | One IP address sent more than 300 requests in a minute | Wait the number of seconds given in the `Retry-After` header |
