# Connect an AI tool

Source: https://mostlyright.md/docs/guides/mcp/

Mostly Right runs a Model Context Protocol server at `https://mostlyright.md/api/mcp`. It speaks Streamable HTTP and negotiates protocol revisions `2025-11-25`, `2025-06-18`, `2025-03-26` and `2024-11-05`. It is stateless: it issues no session id, so every request stands alone.

Searching the catalogue, reading schemas, pulling sample rows and searching a public table's rows need no account. Logging in adds querying whole tables at 10,000 rows a page and downloading a full Parquet snapshot, counted against a free monthly allowance of 100,000 rows and 1,000 queries unless your workspace is subscribed. Building is free with an account: write a recipe, run it, publish the table it produces.

## Add the server

Claude Code adds it from the shell.

```bash
claude mcp add --transport http mostlyright https://mostlyright.md/api/mcp
```

Claude Desktop takes it under Settings → Connectors → Add custom connector, pasting `https://mostlyright.md/api/mcp`.

Cursor reads `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "mostlyright": {
      "url": "https://mostlyright.md/api/mcp"
    }
  }
}
```

VS Code reads `.vscode/mcp.json`:

```json
{
  "servers": {
    "mostlyright": {
      "type": "http",
      "url": "https://mostlyright.md/api/mcp"
    }
  }
}
```

ChatGPT takes the same URL under Settings → Connectors → Add custom connector. Its connector contract requires two tools with exact names and shapes, and this server implements both. `search` takes a `query` and returns `{results: [{id, title, url}]}` with the dataset slug as the `id`. `fetch` takes that `id` and returns `{id, title, text, url, metadata}` with the dataset as Markdown in `text`. Both are anonymous. From the OpenAI Responses API, pass the server as a tool: `{"type": "mcp", "server_label": "mostlyright", "server_url": "https://mostlyright.md/api/mcp"}`.

Any other client handshakes by hand:

```bash
curl -sS https://mostlyright.md/api/mcp \
  -H "content-type: application/json" \
  -H "accept: application/json, text/event-stream" \
  -H "mcp-protocol-version: 2025-06-18" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1"}}}'
```

## What works without an account

| Tool | What it answers |
| --- | --- |
| `search` | The ChatGPT connector search. A query in, up to 20 `{id, title, url}` results out. |
| `fetch` | The ChatGPT connector fetch. One dataset by slug, as Markdown, with its metadata. |
| `search_datasets` | Full-text search over the public catalogue, with cursor pagination. |
| `get_dataset` | One dataset: summary, publisher, licence, tables, column schemas, canonical URL. |
| `list_tables` | The tables and their ids. The cheap call. |
| `get_table_schema` | Columns, types, published profiles, and the capabilities the publisher turned on. |
| `sample_rows` | The publisher's materialized preview, up to 100 real rows. A sample, not a query. |
| `search_table` | Ranked search over a public table's rows, the same search its dataset page runs. 30 calls a minute and 600 a day per address. |
| `get_download_instructions` | The URL, method and header for the full Parquet snapshot. |
| `get_access_instructions` | What needs an account, the key classes, and the numbered steps to get one. |

### Search a table's rows without a key

`search_table` works on any public table with search. You need no key and no account. A table has row search only when `get_table_schema` returns `capabilities.search`. Its `state` says whether search answers now:

| `state` | Meaning |
| --- | --- |
| `ready` | `search_table` answers now. |
| `preparing` | A search package is being built. Search may still answer from the previous version's package, so try it. After a publisher activates search the build can last minutes, and longer on a large table. |
| `unavailable` | No package and no build. Search will not answer until the publisher builds it. |

No `state` means Cloud has not read it yet, or the table is a recorded stream, whose state Cloud never reads. Try `search_table`.

A refused search answers `search_unavailable` with a `reason` and `retry_after_seconds`:

| `reason` | What to do |
| --- | --- |
| `preparing` | Wait `retry_after_seconds`, then retry once. The package is being built or loaded, or Cloud could not tell why it is missing. |
| `service_unavailable` | Wait `retry_after_seconds`, then retry once. The search service is down. |
| `build_failed` | Do not retry. The package failed to build. `retry_after_seconds` is null. |
| `no_package` | Do not retry. The table has no search package. `retry_after_seconds` is null. |
| `not_servable` | Do not retry soon. The table's search package cannot be served right now. `retry_after_seconds` is null. |
| `not_public` | Do not retry. The table is another workspace's private or link-shared table. |

For the last four, use `query_table` or `sample_rows` instead. Most tables search words only. The `like` option and the `meaning` and `image` modes need `capabilities.search.semantic_columns` to be non-empty.

1. Call `search_datasets` with `{"query": "movies"}`. Take a dataset slug from the results.
2. Call `list_tables` with `{"dataset_slug": "<slug>"}`. Take a table id.
3. Call `get_table_schema` with `{"table_id": "<id>"}`. A `capabilities.search` member means the table has search. Its `state` says whether to try now. Keyless search also needs `capabilities.current_parquet` to be true.
4. Call `search_table` with `{"table_id": "<id>", "query": "blade runner 1982"}`. It returns ranked rows, a `plan` and a `next_cursor`.
5. For the next page, send the same query with that `plan` and with `next_cursor` as `cursor`. Stop when `next_cursor` is null.

Without a key, each address gets 30 calls a minute and 600 a day. All keyless callers together get 300 a minute and 10,000 a day. Settled searches also share the dataset page's per-table limit. Keyless search has its own allowance, so it never spends the keyless query route's. Past it the tool answers `rate_limited` with `retry_after_seconds`. Private and link-shared tables need a workspace credential. So do public tables whose publisher turned download off. A workspace key or an OAuth connection raises the limit and adds your workspace's own tables.

A `dataset://{slug}` resource returns one dataset as Markdown, and a `mostlyright://access` resource explains access. The prompts are `explore_dataset`, `find_dataset` and `build_dataset`.

## What needs a workspace

| Tool | What it does |
| --- | --- |
| `query_table` | A bounded structured query: columns, filters, order, `group_by`, aggregates, up to 10,000 rows a page, with `offset` to the end of the table. Filters cover equality, ranges (`between`) and text (`contains`, `starts_with`, `ends_with`). No SQL. |
| `catalog_search` | Searches a fixed snapshot of public data sources for feeds that might answer a question. It swept one provider, Data.gov, and only partially, so a hit is a lead and a miss proves nothing. Every ranked candidate comes back with its disposition, and the tool scores none of them. Each includes the catalogue's own facts: bounding boxes or null, and a record URL only where the entry names one. About one in four do not, and the tool invents nothing. `format` is one lowercase token sent once, because the catalogue takes a single format filter per question and has no OR. An entry that does not declare the required format comes back `refused` with `filters_match: false` rather than held back. The tool checks `question`, `limit` and `format` before it calls, so it rejects a malformed argument itself. One that reached the catalogue another way can surface as its 422 rather than as `CATALOG_SEARCH_INVALID`. |
| `list_connected_datasets` | The datasets this workspace has connected, which is what `query_table` can read. |
| `connect_dataset` | Connects a public dataset to the workspace. Needs the Owner, Admin or Editor role and an OAuth connection. |

OAuth is one of two routes, and it pastes no key anywhere. A client that speaks OAuth 2.1 finds the authorization server in the `WWW-Authenticate` header on the first refusal, registers itself, and opens a browser. You log in there and pick one workspace. The client holds workspace-scoped credentials rather than an API key, and the server rechecks membership on every request. Settings → Access manages and revokes them.

A workspace key is the other route. Log in, create an `mr_use_…` key under Settings → Access, and send it as `Authorization: Bearer mr_use_…`. That header is the only place the server reads a key. `x-api-key` and a query parameter do not authenticate, and a scripted client does not need OAuth for `query_table` when this bearer is valid. The first `query_table` over a dataset connects it to the workspace. Scripted MCP clients with no browser take this route.

An `mr_use_` key only reads: `query_table` over any public dataset and over the workspace's own tables, plus `list_connected_datasets`. It never needs `connect_dataset`, because its first query over a public dataset connects it. An OAuth connection carries only the scopes the person approved. `datasets:read` reads datasets the workspace has already used. `datasets:use` lets it use new public datasets, on first query or through `connect_dataset`. `datasets:build` also reads the workspace's own tables.

An `mr_live_…` key is a different credential. It authenticates the Hosted Table API for tables your own workspace publishes, and the MCP server says so rather than refusing silently.

## Read an existing recipe

The website chat and MCP clients can inspect registered recipes. With the workspace's build
access, call `get_my_dataset` for its table ids, then `list_recipes` with `table_id` to find the
current revision. Set `current_only: false` for older revisions and follow `next_cursor` until
null, including after an empty page. For the exact revision a run executed, use `recipe_id`
from `get_run`.

`get_recipe` takes `recipe_id` and returns the registered document with its identifiers and
digest. This is the MCP equivalent of `mr-data recipe show RECIPE_ID`; reference documents and
example recipes describe the format but do not contain your saved recipe. An optional JSON
Pointer selects a section, such as `/transform` or `/sources/0`.

Small selections return `value`. Large selections return `value_json` chunks. Concatenate them
in offset order, calling again with `next_offset` as `offset` and the same id and pointer until
`next_offset` is null, then parse the JSON once. Offsets count Unicode code points. No run starts
and nothing changes when you list or read recipes.

## Inspect progress and manage search or streams

`get_run_attempts` reads durable attempt history, loss causes and current source/page progress.
Its counts belong to one attempt, and counts that started after the first tick are a lower bound.
Planned pages establish completion only after discovery is complete. `get_recipe_readiness`
reads the full refresh-readiness inventory, including per-source classifications and blockers.
A refresh blocker does not by itself invalidate a fixed snapshot.

For row search, use `inspect_table_search` to inspect, propose, validate, explain or estimate a
configuration. `configure_table_search` saves a draft revision for an exact sealed table version
and observed draft head. `build_table_search` starts preparation; `get_search_job` follows it.
`activate_table_search` activates or rolls back a qualified generation against observed active
revision and generation ids. `cancel_search_job` requests cancellation. Builds, activation and
cancellation require browser approval. Search preparation is not proof of active search; verify
metadata and actual `query_table` rows. `web_search` finds upstream pages and serves a different purpose.

For streams, `register_stream_document` admits a connector or rotating-series document and
`create_stream_registry` registers its admitted digests. `start_stream` starts a probe, capture
or durable subscription after approval. `get_stream` reads the resource, subscription quiescence
or retained recording evidence. `control_stream_subscription` pauses, resumes or stops through
the version-fenced quiescence API, with the observation version bound during approval. There
is no fallback to the older unfenced actions. A desired state of paused or stopped is not proof
of drain; check quiescence. The person enters credential values in settings, never in the chat.

These diagnostic reads return small JSON in `value`. Larger selections use `value_json` chunks
and JSON Pointers. Continue with the same request, `next_offset` as `offset` and `snapshot_digest`
as `expected_snapshot_digest`; restart if the record changed. Join all chunks before parsing.
Inventory cursors paginate backend pages separately: finish a page before following its cursor,
and clear the chunk offset and snapshot digest when starting another backend page.

The following matrix states the browser behavior for every command family in the pinned build
skill. It distinguishes callable operations from client-only work and explicit limitations.

{/* agent-capability-matrix:start */}
| CLI command | Website behavior | Tools |
| --- | --- | --- |
| `mr-data acquire-slices` | client only: Reads local acquisition files; use hosted source inspection and builds in this app. | Handled in the app or intentionally unavailable |
| `mr-data artifacts` | available: Lists sealed artifacts and their download coordinates. | `run_artifacts`, `get_artifact_download` |
| `mr-data ask` | available: Offered only on deployments with the support agent. | `ask_support`, `get_support_answer` |
| `mr-data auth` | in app: Sign in, sign out and manage credentials in app settings; the chat cannot rotate login credentials. | Handled in the app or intentionally unavailable |
| `mr-data catalog` | available: Searches the source catalogue, not a table’s rows. | `catalog_search` |
| `mr-data checks` | available: Reads recorded checks; success alone is not verification. | `get_run` |
| `mr-data clarify` | in app: The conversation resolves the brief; no shell command or separate artifact is required. | Handled in the app or intentionally unavailable |
| `mr-data client` | client only: CLI installation and client diagnostics do not run in the browser. | Handled in the app or intentionally unavailable |
| `mr-data connected` | available: Lists workspace dataset connections. | `list_connected_datasets` |
| `mr-data connections` | partial: Discovers saved connection names; editing their credentials stays in settings. | `list_source_credentials` |
| `mr-data cover` | available: First cover runs when authored; replacing a cover requires approval. | `generate_cover` |
| `mr-data dataset` | partial: Dataset authoring, category, notes, event history and lifecycle are available. Setting the page's activity line and the draft helpers are not separate tools. | `create_dataset`, `update_dataset`, `get_my_dataset`, `list_my_datasets`, `write_note`, `list_notes`, `set_dataset_visibility`, `archive_dataset`, `list_runs`, `list_dataset_events` |
| `mr-data demote` | available: Requires approval and a reviewed table version. | `demote_table` |
| `mr-data diff` | available: Compares recorded run evidence. | `compare_runs` |
| `mr-data download` | available: Returns download coordinates; it does not write a local file. | `run_artifacts`, `get_artifact_download` |
| `mr-data export-hosted-candidate` | client only: Local candidate packaging is a CLI operation; hosted artifact downloads are available separately. | Handled in the app or intentionally unavailable |
| `mr-data keys` | in app: Lists enrolled credential names; the person adds, rotates or revokes values in settings. | `list_source_credentials` |
| `mr-data login` | in app: The chat uses the signed-in workspace. | Handled in the app or intentionally unavailable |
| `mr-data models` | available: Lists the small models recipes can call and suggests, from a run's rows, where a rule or a model would improve the table. | `list_models`, `suggest_enrichments` |
| `mr-data note` | available: Writes or reads dataset/run notes. | `write_note`, `list_notes` |
| `mr-data open` | in app: The dataset page is already open; links can be shown in the conversation. | Handled in the app or intentionally unavailable |
| `mr-data parts` | available: Reads immutable table-part evidence. | `list_table_parts` |
| `mr-data peek` | available: Queries the sealed run table with a bounded read. | `query_run` |
| `mr-data pin` | policy restricted: No browser pin operation is offered; never invent a pointer change. | Handled in the app or intentionally unavailable |
| `mr-data probe` | available: Inspects a prepared source before a build. | `probe_source`, `get_source_probe` |
| `mr-data promote` | policy restricted: First-success promotion is automatic. Explicit re-promotion is hidden until browser review can bind its version. | Handled in the app or intentionally unavailable |
| `mr-data public` | available: Reads schemas and queries published rows. Gives application developers table-specific API and polling instructions. | `list_tables`, `get_table_schema`, `query_table`, `get_access_instructions`, `get_download_instructions` |
| `mr-data query` | available: Read-only SQL over the sealed run table. | `query_run` |
| `mr-data reader` | available: Returns certified canonical Reader options. | `normalize_reader_options` |
| `mr-data receipt` | available: Reads immutable outcome evidence. | `get_run` |
| `mr-data recipe` | available: Saved documents, inventory, draft checks, forecasts, bounded preflight and refresh-readiness diagnostics are available. | `register_recipe`, `get_recipe`, `list_recipes`, `explain_recipe`, `forecast_recipe`, `test_recipe`, `get_recipe_readiness` |
| `mr-data reschedule` | available: Requires approval and a reviewed table version. | `reschedule_table` |
| `mr-data run` | available: Starts hosted builds, including fresh-answer, snapshot-history and resume options; attempt history and source counts are separate durable reads. | `start_run`, `get_run_attempts` |
| `mr-data runs` | available: Lists workspace runs with filters. | `list_runs` |
| `mr-data search` | partial: Search inspection, configuration, sampling, value lists, scan previews, evaluation cases, preparation and activation are available. Ranked row search uses search_table; row queries use query_table. CLI locator/try helpers are not a dedicated operation; standalone spec/case-file validation is not claimed. | `inspect_table_search`, `configure_table_search`, `build_table_search`, `activate_table_search`, `get_search_job`, `cancel_search_job`, `sample_table`, `list_column_values`, `preview_table_search`, `get_search_evaluation`, `add_search_cases`, `query_table`, `search_table` |
| `mr-data source` | available: Prepares and inspects an upstream source; with archive_members it lists a ZIP's member names before a recipe names one. | `start_source_inspection`, `get_source_inspection` |
| `mr-data status` | available: Reads run outcome and the attempt-scoped source progress ledger. | `get_run`, `get_run_attempts` |
| `mr-data stream` | available: Admits connector/series documents, probes, captures and subscribes; pause/resume/stop use reviewed version-fenced quiescence APIs. | `register_stream_document`, `create_stream_registry`, `start_stream`, `get_stream`, `control_stream_subscription` |
| `mr-data table` | available: Table reads, diagnosis, naming, retirement, an on-demand refresh and a full source resync are available. | `get_table`, `diagnose_table`, `rename_table`, `archive_table`, `refresh_table`, `resync_table`, `reschedule_table` |
| `mr-data unpin` | policy restricted: No browser unpin operation is offered. | Handled in the app or intentionally unavailable |
| `mr-data verify` | available: Verifies sealed manifests and optionally downloads for deep verification. | `verify_run` |
| `mr-data watch` | available: Events show current activity; the ledger preserves attempt and source progress when logs have rolled over. | `run_events`, `get_run_attempts` |
| `mr-data whoami` | in app: The chat already has the signed-in user and active workspace. | Handled in the app or intentionally unavailable |
{/* agent-capability-matrix:end */}

## Build datasets

Any workspace builds datasets through the same server, free. It needs two things: an OAuth connection that approved the `datasets:build` scope, and the Owner, Admin or Editor role in that workspace. An `mr_use_` key cannot build. Every build tool refuses it by name and points at the OAuth route.

| Tools | What they do |
| --- | --- |
| `create_dataset`, `update_dataset`, `list_my_datasets`, `get_my_dataset` | The dataset page: create one, rename it, write its description, read its tables and their state. |
| `register_recipe` | Send one recipe document. Returns with `recipe_id`, `recipe_digest`, `dataset_id`, `table_id` and `source_ids`. |
| `start_run`, `confirm_run`, `cancel_run` | Start a run in `sample`, `full`, `refresh` or `backfill` mode with row and byte ceilings, settle a run held for a confirmation, or stop one. A `backfill` covers one exact window and rejects without a `window` of `{start, end}`. |
| `get_run`, `run_events`, `list_runs` | Read a run's record, page its events until it is terminal, and find runs you did not start. |
| `query_run` | One bounded read-only SQL statement over a finished run's own table, where the relation is named `run_table`. |
| `run_artifacts`, `get_artifact_download` | What the run wrote, and a signed URL for one artifact. Bytes never stream through MCP. |
| `write_note` | One cell of the decision record, on the dataset or on the run. |
| `promote_table`, `get_table` | Publish a table, and read what one is serving. |
| `list_source_credentials` | The names of the secrets the workspace holds. Never a value. |

The loop runs in this order:

1. Read the build guide and the recipe reference.
2. Propose sources.
3. Write a recipe with a description on every column and units on every numeric column.
4. `register_recipe`.
5. `start_run` in full mode within the user's authorization.
6. `run_events` until the run is terminal.
7. `query_run` to check the rows.
8. `write_note` for each decision.
9. Repair the recipe and register it again only when failure evidence identifies a recipe defect.

Full builds use progressive acquisition automatically. A long build exposes an inspection checkpoint after about five minutes and continues in the same run without a second approval or acquisition. Any required spend confirmation happens before acquisition. Use `sample` only for a deliberately bounded experiment; a row ceiling does not limit acquisition time. The first successful run makes the table live automatically; `promote_table` records an authorized refresh cadence.

A person pastes credentials, never an agent. A source that needs an API key takes its value from Settings → Secrets in the dashboard, which stores the value under a name, and the recipe names that name. No secret passes through MCP or through a chat message.

Four resources carry the rest:

- `mostlyright://build-guide` walks the whole loop with the tool names, and also ships as an agent skill at [/.well-known/agent-skills/mostlyright-build/SKILL.md](/.well-known/agent-skills/mostlyright-build/SKILL.md).
- `mostlyright://recipe-reference` lists every member of the recipe document, every bound, every refusal.
- `mostlyright://recipe-connections` covers using a saved workspace connection instead of a named secret.
- `mostlyright://recipes/examples` holds six recipe documents that ran, each readable at `mostlyright://recipes/examples/{name}`.

The `build_dataset` prompt walks the same loop for a question you give it.

## When a tool refuses

Every refusal names what to do next. An anonymous caller reaching `query_table` gets a `401`. Its body carries the signup URL, the header format and the numbered steps, the same content `get_access_instructions` returns. A client that speaks OAuth turns that `401` into a login prompt. One that does not shows the instructions to the model.

A spent allowance is a different refusal. `query_table`, `get_download_instructions` and `get_artifact_download` answer it with `usage_limit_exceeded`, the limit, what was used, the reset time and an upgrade URL. Give the user that URL rather than reporting a failure.

## Bulk data

Bytes never stream through MCP. `get_download_instructions` returns the one request that fetches a complete Parquet snapshot, and you make that request yourself. Applications, scripts and notebooks use the [Public Dataset API](/docs/reference/public-dataset-api/) directly.

## Discovery

- `/.well-known/oauth-protected-resource/api/mcp` carries the ratified protected-resource metadata.
- `/.well-known/mcp.json` is a server card for registries and directory crawlers, listing the anonymous, authenticated and build tools.
- `/.well-known/agent-skills/index.json` lists the agent skills this deployment publishes.
- `/llms.txt` and `/llms-full.txt` carry the catalogue as plain text.
- `/datasets/{slug}/llms.txt` carries one dataset as Markdown.
