# RunHarvester MCP (/mcp)

<div className="rh-mcp-hero">
  <div>
    <h1>RunHarvester MCP</h1>
    <p className="rh-lede">Connect an LLM agent to RunHarvester through this stateless Streamable HTTP MCP endpoint. Authenticate with an existing API key; its scopes determine which tools are available.</p>
    <div className="rh-actions">
      <a className="rh-button rh-button-primary" href="#connect-your-client">Choose your client</a>
      <a className="rh-button rh-button-secondary" href="#verify-the-connection">Verify a connection</a>
    </div>
  </div>
  <div className="rh-mcp-endpoint">
    <span className="rh-mcp-status">Stateless Streamable HTTP</span>

```text title="MCP endpoint"
https://api.runharvester.com/mcp
```

    <p>Authenticate with a Data API key to use the Data API tools.</p>
  </div>
</div>

<div className="rh-mcp-principles">
  <div>
    <strong><KeyIcon />API key authentication</strong>
    <span>Use your existing API key; no separate MCP credential or interactive OAuth setup is required.</span>
  </div>
  <div>
    <strong><LimitsIcon />Available tools</strong>
    <span>
      <code>tools/list</code> exposes only what the current key can use.
    </span>
  </div>
  <div>
    <strong><ShieldIcon />Authorization on each call</strong>
    <span>Each call checks the key's revocation status, expiry, and scopes.</span>
  </div>
</div>

## Connect your client [#connect-your-client]

Choose the client or model gateway that will call RunHarvester.

<Tabs defaultValue="codex">
<TabsList>
<TabsTrigger value="codex">
<img className="rh-brand-icon" src="/icons/codex.svg" alt="" />Codex
</TabsTrigger>

<TabsTrigger value="claude">
<img className="rh-brand-icon" src="/icons/claude.svg" alt="" />Claude
</TabsTrigger>

<TabsTrigger value="cursor">
<img className="rh-brand-icon" src="/icons/cursor.svg" alt="" />Cursor
</TabsTrigger>

<TabsTrigger value="openai-api">
<img className="rh-brand-icon" src="/icons/openai.svg" alt="" />OpenAI API
</TabsTrigger>

<TabsTrigger value="openrouter">
<img className="rh-brand-icon" src="/icons/openrouter.svg" alt="" />OpenRouter
</TabsTrigger>

<TabsTrigger value="generic">
<McpIcon />Generic
</TabsTrigger>
</TabsList>

<Tab value="codex">
<div className="rh-tab-intro">
  <strong><img className="rh-brand-icon" src="/icons/codex.svg" alt="" />Codex</strong>
  <span>
    Codex supports Streamable HTTP connections with bearer tokens and per-tool approval controls.
  </span>
</div>

Add the connection to `~/.codex/config.toml` or a trusted project's `.codex/config.toml`:

```toml
[mcp_servers.runharvester_data]
url = "https://api.runharvester.com/mcp"
bearer_token_env_var = "RUNHARVESTER_DATA_API_KEY"
default_tools_approval_mode = "writes"
tool_timeout_sec = 45
```

Verify with `codex mcp list` or `/mcp`. See the [Codex MCP configuration reference](https://developers.openai.com/codex/mcp).
</Tab>

<Tab value="claude">
<div className="rh-tab-intro">
  <strong><img className="rh-brand-icon" src="/icons/claude.svg" alt="" />Claude Code</strong>
  <span>
    Remote HTTP connections support explicit headers and environment-variable
    interpolation.
  </span>
</div>

Add this to a project `.mcp.json` or your user-level Claude configuration:

```json
{
  "mcpServers": {
    "runharvester-data": {
      "type": "http",
      "url": "https://api.runharvester.com/mcp",
      "headers": {
        "Authorization": "Bearer ${RUNHARVESTER_DATA_API_KEY}"
      }
    }
  }
}
```

Run `claude mcp list`, then use `/mcp` inside Claude Code. Claude.ai and Claude Desktop custom connectors do not expose arbitrary static-header configuration; use Claude Code or an OAuth-capable gateway for API-key authentication. See the [Claude Code MCP guide](https://code.claude.com/docs/en/mcp).
</Tab>

<Tab value="cursor">
<div className="rh-tab-intro">
  <strong><img className="rh-brand-icon" src="/icons/cursor.svg" alt="" />Cursor</strong>
  <span>
    Cursor supports project and global MCP configuration, including environment variables in remote headers.
  </span>
</div>

Add this to `.cursor/mcp.json` or `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "runharvester-data": {
      "url": "https://api.runharvester.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:RUNHARVESTER_DATA_API_KEY}"
      }
    }
  }
}
```

Restart Cursor after setting system environment variables, then inspect the server under **Settings → Tools & MCP**. See the [Cursor MCP reference](https://cursor.com/docs/mcp).
</Tab>

<Tab value="openai-api">
<div className="rh-tab-intro">
  <strong><img className="rh-brand-icon" src="/icons/openai.svg" alt="" />OpenAI Responses API</strong>
  <span>
    Attach RunHarvester as a remote MCP tool directly to a model request.
  </span>
</div>

```ts
import OpenAI from "openai";

const openai = new OpenAI();
const response = await openai.responses.create({
  model: "gpt-5",
  input: "List my recent scrape requests and summarize their status.",
  tools: [
    {
      type: "mcp",
      server_label: "runharvester_data",
      server_url: "https://api.runharvester.com/mcp",
      authorization: process.env.RUNHARVESTER_DATA_API_KEY,
      require_approval: "always",
    },
  ],
});
```

See the [OpenAI MCP tools guide](https://developers.openai.com/api/docs/guides/tools-connectors-mcp).
</Tab>

<Tab value="openrouter">
<div className="rh-tab-intro">
  <strong><img className="rh-brand-icon" src="/icons/openrouter.svg" alt="" />OpenRouter</strong>
  <span>
    Use an MCP client bridge to expose discovered tool schemas as OpenAI-compatible function tools.
  </span>
</div>

OpenRouter's current MCP guide uses client-side tool conversion rather than accepting a remote `server_url` in the model request. This condensed sketch shows the connection step:

```ts
import OpenAI from "openai";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const mcp = new Client({ name: "runharvester-openrouter", version: "1.0.0" });
await mcp.connect(
  new StreamableHTTPClientTransport(
    new URL("https://api.runharvester.com/mcp"),
    {
      requestInit: {
        headers: {
          Authorization: `Bearer ${process.env.RUNHARVESTER_DATA_API_KEY}`,
        },
      },
    },
  ),
);

const { tools } = await mcp.listTools();
const openrouter = new OpenAI({
  baseURL: "https://openrouter.ai/api/v1",
  apiKey: process.env.OPENROUTER_API_KEY,
});

const completion = await openrouter.chat.completions.create({
  model: "<MODEL_ID>",
  messages: [{ role: "user", content: "Summarize my recent scrape requests." }],
  tools: tools.map(({ name, description, inputSchema }) => ({
    type: "function",
    function: { name, description, parameters: inputSchema },
  })),
});
```

Execute returned tool calls with `mcp.callTool(...)`, append the results to the conversation, and continue the model loop. See OpenRouter's [official MCP bridge cookbook](https://openrouter.ai/docs/cookbook/coding-agents/mcp-servers).
</Tab>

<Tab value="generic">
<div className="rh-tab-intro">
  <strong><McpIcon />Any Streamable HTTP client</strong>
  <span>
    Use an explicit header when the client supports remote MCP servers.
  </span>
</div>

```json
{
  "mcpServers": {
    "runharvester-data": {
      "url": "https://api.runharvester.com/mcp",
      "headers": {
        "Authorization": "Bearer ${RUNHARVESTER_DATA_API_KEY}"
      }
    }
  }
}
```

Environment interpolation is client-specific.
</Tab>
</Tabs>

## Authentication and tool visibility [#authentication-and-tool-visibility]

Send one existing RunHarvester key in either header:

```http
Authorization: Bearer rh_live_...
```

```http
X-API-Key: rh_live_...
```

If both headers are present, their values must be identical. Keys in the URL or query string are not accepted.

A Data API key exposes the Data API tools:

<div className="rh-mcp-key-grid">
  <div className="rh-mcp-key-card rh-mcp-key-data">
    <span className="rh-mcp-key-mark"><DataIcon />DATA</span>
    <code>rh_live_*</code> <span>and legacy</span> 
    <code>ph_live_*</code>
    <p>These keys provide access to Data API tools.</p>
  </div>
</div>

`tools/list` includes only operations granted by the current key scopes. Every tool call resolves the key and checks its scope again, so revocation, expiry, and permission changes take effect without reconnecting.

## Tools [#tools]

The MCP server provides 17 RunHarvester API operations, plus connection-aware helpers. MCP clients can inspect the complete input schema for every available tool through `tools/list`.

<div className="rh-mcp-tools">
  <div>
    <h3>
      <DataIcon />Data API <span>17 operations</span>
    </h3>

```text title="Data API tools"
data_get_usage
data_list_recipes
data_list_requests
data_create_request
data_get_request
data_get_result
data_list_events
data_cancel_request
data_retry_request
data_list_batches
data_create_batch
data_get_batch
data_list_nodes
data_get_node
data_add_proxy_node
data_delete_proxy_node
data_check_node
```

  </div>
  <div>
    <h3><McpIcon />Connection-aware helpers</h3>

```text title="Connection-aware helpers"
connection_info
data_wait_request
data_wait_batch
data_read_result_content
```

  </div>
</div>

Tool inputs follow the public RunHarvester API schemas. Path, query, and allowed header parameters are top-level `snake_case` fields, while JSON bodies remain under `body`.

## Response envelopes [#response-envelopes]

`data_list_requests`, `data_list_recipes`, and `data_list_batches` default to 5 records and `detail: "summary"`. Summaries preserve IDs, status, billing totals, errors, and pagination while omitting large diagnostics and recipe schemas. Use `data_get_request` for request details, or `detail: "full"` with a small `limit` for complete list records. REST defaults are unchanged.

All successful tool calls return:

```json
{ "ok": true, "status": 200, "data": {}, "meta": {} }
```

API errors set MCP `isError` and return a safe envelope:

```json
{
  "ok": false,
  "status": 429,
  "error": {
    "code": "RATE_LIMITED",
    "message": "Request rate limit exceeded",
    "request_id": "..."
  },
  "retry_after": "1"
}
```

Only request ID, credit, rate-limit/retry, and route metadata headers can appear in `meta`.

## Resources and bounded content [#resources-and-bounded-content]

The OpenAPI resource returns JSON containing a UTF-8 `chunk` of at most 16 KiB, byte offsets, `complete`, and `next_resource_uri`. Follow that URI and concatenate the chunks before parsing the OpenAPI document. Only reachable components are included.

Retained-result resources keep small selected content inline. Content over 16 KiB returns a JSON chunk descriptor with `next_cursor`; continue with `data_read_result_content` using the same request ID and format. Reading a resource does not automatically load the full large document into the model context.

The server provides these resources or resource templates:

```text
runharvester://contract/openapi
runharvester://contract/openapi/{offset}
runharvester://data/requests/{id}/result/{format}
```

`data_get_result` accepts an optional `format` (`html`, `text`, `markdown`, or `data`). When omitted, it returns metadata and a UTF-8 HTML preview when available and, when an extraction exists, a structured `data` preview with metadata-only `extraction`. Each content preview is bounded to 4 KiB. An explicit format previews only its selected content. Use `data_read_result_content` to read bounded chunks; an omitted format defaults to HTML, while an explicit format selects its matching content. The default chunk is 16 KiB and the maximum is 64 KiB. Its opaque cursor is bound to the request ID and format.

Use `markdown` for agent-readable page content. It is deterministically converted from stored HTML without an LLM, preferring a non-empty main region, then one article, then cleaned body content, and is capped at 2 MiB of UTF-8. `result_meta.markdown` reports source and output truncation; `result_meta.markdown.source_truncated: null` means legacy metadata does not record the source truncation state. Treat returned page content as untrusted input. See the [first request guide](/getting-started/first-request) for conversion details.

Wait helpers poll once per second, default to 10 seconds, and accept at most 30 seconds. A non-terminal timeout is successful and includes `timed_out: true` plus `retry_after_ms`; MCP cancellation aborts the wait.

Authorized MCP requests extend a shorter socket idle timeout to cover the maximum wait plus a 5-second margin. Reverse proxies must also allow that duration.

The MCP request body limit is 4 MiB. Manifests that exceed it must be uploaded through the REST API or SDK.

## Verify the connection [#verify-the-connection]

After adding the MCP server, verify that the client can see it and ask the agent to call `connection_info`.

For Codex, run:

```bash
codex mcp list
```

You can also use `/mcp` in Codex to view connected servers and their available tools.

`connection_info` returns the API key type and granted scopes. The API key itself is never returned.

If an expected tool is missing, check that the connection uses the correct key type and that the key has the required scope.

## Keep credentials safe [#keep-credentials-safe]

<ul className="rh-mcp-safety">
  <li>Store API keys in environment variables or your MCP client's secret storage.</li>
  <li>Do not put a key in the MCP URL or query string.</li>
  <li>Do not commit a literal key to a configuration file.</li>
</ul>