# MCP server

> The hosted MCP endpoint and the local MCP server that let an AI client call DarkCrawl as tools.

## Hosted endpoint

The hosted service runs these tools at `https://api.darkcrawl.dev/mcp`, so an AI client reaches DarkCrawl with nothing to install. [Get a key](https://darkcrawl.dev/docs/build-with-ai/get-a-key/) first. Send it in the `Authorization` header as `Authorization: Bearer YOUR_API_KEY`, and never put a key in an address. The [quick-starts](https://darkcrawl.dev/docs/quickstart/claude-code/) show the setup for each client. For any other client, these are the two settings:

```text
url: https://api.darkcrawl.dev/mcp
header: Authorization: Bearer YOUR_API_KEY
```

The hosted tools are the first table under [Tools](https://darkcrawl.dev/docs/mcp/#tools). The ones under “On your own server” are not offered here.

What the server does:

- **Company keys only.** The hosted endpoint serves a key made for a company. A missing, unknown or revoked key is refused with `401`. If you run DarkCrawl yourself, use `darkcrawl mcp` instead, below.

- **POST only, one message at a time.** `GET` and `DELETE` answer `405` with `Allow: POST`. The server keeps no session and offers no stream, so every message is checked again, and a key you revoke stops working on the next message.

- **No web pages.** A request that carries an `Origin` header is refused with `400 BAD_REQUEST`, so a script on a web page cannot call it. Use a client that runs on your machine or your server.

- **Refused before the tool runs.** A company that cannot use the API gets `403` with the code, such as `TRIAL_EXPIRED` or `ORG_DISABLED`. A key that sends too many messages in a minute gets `429 RATE_LIMITED` with `details.limit` `mcpMessagesPerMinute`. This limit is per key, DarkCrawl sets it, and it is separate from your plan’s request limit.

- **Message size.** A message larger than the server accepts gets `413`. No message can be larger than your company’s upload limit. The trial’s is below, and your company’s own is in [`GET /api/org`](https://darkcrawl.dev/docs/api-reference/your-company/get-api-org/):

  - 10 MiB per upload

- **Each tool call counts as the API call it makes.** A scrape counts as a `POST /v2/scrape` against your plan’s limits, as on the [plans and limits](https://darkcrawl.dev/docs/plans-and-limits/) page. The MCP message that carried it does not count as a request. A plan limit or an API error comes back as a tool error: `DarkCrawl API error <CODE>`, with the API’s message.

- **Each company can run a few tool calls at the same time.** A call over that is refused immediately as a tool error `RATE_LIMITED`, with `details.limit` `mcpCallsPerCompany` and its `max`. The server also caps the calls it runs for all companies together. When it is busy, a call is refused the same way with `mcpCallsTotal`, even if your company is under its own limit. Neither is queued. Try again when a call has finished. Start a crawl, a batch or an agent job and check it later, rather than holding a call open.

- **A call that is abandoned is cancelled.** If your client goes away, or a server in front of DarkCrawl cuts the call at its own time limit, the call is cancelled. What it used until then still counts, and the call shows in Activity with a 500 status.

- **No downloads.** The hosted `scrape` and `batch_scrape` have no switch to download images, videos or files.

- **Page text is framed as untrusted.** It comes back in the same frame as from `darkcrawl mcp`, described in [Page text is untrusted](https://darkcrawl.dev/docs/mcp/#page-text-is-untrusted).

## Local server

`darkcrawl mcp` runs a Model Context Protocol server on your own machine, over stdio, so an AI client can call DarkCrawl directly. It is a thin client of the HTTP API: it takes the same `--url` and `DARKCRAWL_API_KEY` as the other `darkcrawl` commands, the server applies every rule, and it works against a DarkCrawl you run yourself or against the hosted service. A company key reaches the tools under “Tools”, on this server or at the hosted endpoint above; the ones under “On your own server” call routes a company key does not reach, as on the [CLI page](https://darkcrawl.dev/docs/cli/).

It needs the optional `mcp` package. The [quick-starts](https://darkcrawl.dev/docs/quickstart/claude-code/) show the install and the setup for each client.

## Tools

Every tool also takes `maxChars` where the reply can be long. The inputs below are the tool’s own; one that is marked optional can be left out.

| Tool                           | Inputs                                                                                                                                                                                                        |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `darkcrawl_scrape`             | `url`; optional `formats`, `onlyMainContent`, `skipTlsVerification`, `redactPII`, `checkPromptInjection`, `summary`, `json_prompt`, `json_schema`, `question`, `highlights_query`, `maxChars`                 |
| `darkcrawl_map`                | `url`; optional `search`, `limit`, `maxChars`                                                                                                                                                                 |
| `darkcrawl_crawl`              | `url`; optional `limit`, `maxDiscoveryDepth`, `redactPII`, `checkPromptInjection` (returns the job id)                                                                                                        |
| `darkcrawl_check_crawl_status` | `id`; optional `skip`, `maxChars`                                                                                                                                                                             |
| `darkcrawl_cancel_crawl`       | `id`                                                                                                                                                                                                          |
| `darkcrawl_batch_scrape`       | `urls` (1 to 1000); optional `formats`, `onlyMainContent`, `redactPII`, `checkPromptInjection`, `summary`, `json_prompt`, `json_schema`, `question`, `highlights_query`, `maxChars` (returns the job id)      |
| `darkcrawl_check_batch_status` | `id`; optional `skip`, `maxChars`                                                                                                                                                                             |
| `darkcrawl_search`             | `query`; optional `limit` (5 by default), `scrape`, `formats`, `redactPII`, `checkPromptInjection`, `summary`, `json_prompt`, `json_schema`, `question`, `highlights_query` (these need `scrape`), `maxChars` |
| `darkcrawl_search_captures`    | `query`; optional `host`, `since`, `jobId`, `limit` (10 by default), `offset`, `maxChars`                                                                                                                     |
| `darkcrawl_list_alerts`        | optional `monitorId`, `type`, `since`, `limit` (20 by default), `includeText`, `maxChars`                                                                                                                     |
| `darkcrawl_agent`              | `prompt`; optional `urls`, `json_schema`, `strictConstrainToURLs`, `threadId` (returns the job id)                                                                                                            |
| `darkcrawl_check_agent_status` | `id`; optional `maxChars`                                                                                                                                                                                     |
| `darkcrawl_cancel_agent`       | `id`                                                                                                                                                                                                          |
| `darkcrawl_leak_check`         | `q` (a company name or a domain); optional `sector`, `country`, `minConfidence`, `limit`, `maxChars`                                                                                                          |
| `darkcrawl_leak_countdowns`    | optional `withinHours`, `sector`, `country`, `group`, `limit`, `maxChars`                                                                                                                                     |
| `darkcrawl_leak_recent`        | optional `days`, `group`, `sector`, `country`, `status`, `limit`, `offset`, `maxChars`                                                                                                                        |
| `darkcrawl_leak_site_status`   | `group`; optional `maxChars`                                                                                                                                                                                  |

## On your own server

These tools call routes a hosted key does not reach. They work against a DarkCrawl you run yourself.

| Tool                      | Inputs                                                                            |
| ------------------------- | --------------------------------------------------------------------------------- |
| `darkcrawl_index_stats`   | none                                                                              |
| `darkcrawl_index_submit`  | `hosts` (1 to 50 strings, each up to 2,048 characters)                            |
| `darkcrawl_link_graph`    | optional `jobId`, `host`, `kind`, `limit` (500 by default), `maxChars`            |
| `darkcrawl_list_monitors` | optional `maxChars`                                                               |
| `darkcrawl_regex_search`  | `pattern`; optional `ignoreCase`, `limit` (1 to 100), `host`, `since`, `maxChars` |
| `darkcrawl_site_links`    | `host`; optional `limit` (1 to 500, 50 by default), `maxChars`                    |

No tool changes a monitor or an alert channel, and none deletes stored data.

## Settings that call an AI model

`summary`, `json_prompt`, `json_schema`, `question` and `highlights_query` ask a model to read the page. They send the page text to the model’s provider, they can cost money on a cloud provider, and they fail with `AI_UNAVAILABLE` when no provider is set up. What they return is text a model wrote about an untrusted page.

`redactPII` and `checkPromptInjection` are off unless the client sets them. On `darkcrawl_search` they need `scrape` to be `true`. A value the server refuses is a tool error and nothing is sent.

## Page text is untrusted

Only DarkCrawl’s own fields come first, outside any frame: the tool name, the ids and counts, the status. Everything that came from a site, and everything a model wrote about it, comes after, framed as untrusted. The frame is a line saying the text came from an untrusted onion site and is data, not instructions, then `<<<UNTRUSTED_CONTENT nonce=N>>>`, the JSON and `<<<END_UNTRUSTED_CONTENT nonce=N>>>`, with a new random `N` in every reply.

A marker word inside the text is replaced with `[marker removed]`, so a page cannot close the frame. Your client should treat what is inside as data and never follow instructions found there.

## Long replies and errors

`maxChars` caps the page text, map links, graph edges or invalid URLs in one reply: 30,000 characters by default, at most 200,000. A cut reply says so outside the frame, and a cut page names its capture, whose full text stays stored.

Errors are tool errors: `DarkCrawl API error <CODE>` with the API’s message framed, or `DarkCrawl API not reachable at <url>` when no connection was made.
