# crabtalk/docs

> Serve a site's documentation to agents over MCP: search, read and exact lookups

Version 0.1.14 · [Repository](https://github.com/crabtalk/crab)

Agents call these tools over CrabTalk's MCP endpoint ([setup](/docs/guides/mcp.md)); apps and scripts use the CLI or HTTP API ([calling tools](/docs/guides/tools.md)).

## Tools

### crawl

Price: free

Read the site's sitemaps and fetch the docs pages that are new, changed or failed last time, a run after another until none is left.

Arguments (JSON Schema):

```json
{
  "type": "object"
}
```

### grep

Price: free

Answer up to fifty lines of the docs that hold the text, ignoring case, such as a command, a flag, an error code or a setting's name.

Arguments (JSON Schema):

```json
{
  "properties": {
    "text": {
      "description": "The text to find.",
      "type": "string"
    }
  },
  "required": [
    "text"
  ],
  "type": "object"
}
```

### read

Price: free

Answer a page's Markdown, or only the section under `section`, the anchor `search` answered. With no page, answer the list of every docs page.

Arguments (JSON Schema):

```json
{
  "properties": {
    "page": {
      "description": "The page's URL or path on the site; leave it out to list every page.",
      "type": "string"
    },
    "section": {
      "description": "The anchor of one section of the page.",
      "type": "string"
    }
  },
  "required": [],
  "type": "object"
}
```

### search

Price: free

Find up to ten sections of the docs that match the words given, best first, each with its page, heading and an excerpt. Read the page or section for the whole text.

Arguments (JSON Schema):

```json
{
  "properties": {
    "query": {
      "description": "Words describing what to find.",
      "type": "string"
    }
  },
  "required": [
    "query"
  ],
  "type": "object"
}
```

## README

# Docs

Serve a documentation site to agents: search its pages, read a page or one of its sections, and find exact text such as a command, a flag or an error code. It reads one site, the pages its sitemaps list under its docs URL, and keeps them in its own database.

## Call

With Crab signed in, call it by its address:

```sh
crab call crabtalk/docs search '{"query":"custom domain"}'
```

`search` answers up to ten sections, best first, each with its page URL, title, heading, the section's anchor and an excerpt. Then read the page, or only the section:

```sh
crab call crabtalk/docs read '{"page":"/docs/guides/domains","section":"limits"}'
```

`read` with no `page` lists every page it holds. `grep` answers up to fifty lines that hold a text, ignoring case:

```sh
crab call crabtalk/docs grep '{"text":"crab domain add"}'
```

All three read only and are free. It also serves a skill, `docs`, over MCP's skills extension: it tells an agent to search, read the section and grep for exact names before answering, and to cite the page. Agents call them through its own MCP server, with no sign-in since all three take anonymous calls (see [service MCP servers](https://crabtalk.ai/docs/guides/service-mcp)), or through [CrabTalk MCP](https://crabtalk.ai/docs/guides/mcp).

## Crawling

The var `site` is the docs' URL, such as `https://docs.example.com/docs/`: its origin finds `robots.txt` and the sitemaps, and pages outside its path are skipped. A remix sets its own in `crab.remix.toml`.

The service crawls its site once a day, at midnight UTC: it reads its `robots.txt` and sitemaps, then fetches every page that is new, changed or failed last time, a run after another until none is left. The first crawl reads every page; a site of a few hundred pages with Markdown copies fills in minutes. Everything it reads stays in the service's database.

## Limits

- Requests carry `User-Agent: CrabTalk-Docs/1.0 (+https://crabtalk.ai/docs/reference/crawlers)`. Pages come from the site's sitemaps, as its `robots.txt` allows them to `CrabTalk-Docs`. Pages no sitemap lists are not read, and a page dropped from the sitemaps is no longer answered.
- Docs reads static pages and runs no JavaScript. A page is asked for Markdown first, with `Accept: text/markdown`, and Markdown it answers is kept as the site serves it: one request a page. A page answered with HTML costs a second request, for its Markdown copy at its URL with `.md` appended.
- A page with no Markdown is read from the HTML its server sends, up to 512 KiB: its main region, else its article, else its body, becomes Markdown, and navigation, footers and forms are left out. A page that renders its text in the browser, as a single-page app does, is kept without text. Serve Markdown copies, or render the docs on the server.
- A crawl fetches a page again when its sitemap `lastmod` changes. A page with no `lastmod` is asked again each crawl with `If-None-Match` and `If-Modified-Since`, and one that answers unchanged is kept as it is.
- A run takes up to 20 pages answered as Markdown, or one read from HTML, so a site served only as HTML takes about a run a page.
- Sections are cut at headings of level one to three. `search` matches any word of the query, common question words aside, ranked by SQLite full-text search: sections matching more of the words rank higher, and a word in a heading counts ten times one in the text.
