Skip to main content
Glama
README.md
# korimako

A remote [MCP](https://modelcontextprotocol.io) server that makes DNS
queries for agents that cannot send DNS packets themselves. It runs on
Cloudflare Workers.

Agents in cloud sandboxes often have no port 53 and an outbound proxy
that refuses DNS-over-HTTPS, so they end up asking a person to run
`dig` for them. An MCP connector is reached from outside the sandbox,
so korimako can ask on their behalf and hand back the whole answer.

The korimako, or bellbird, is a New Zealand bird. One calls and others
answer.

## What it does

It offers two tools. `dns_query` works like `dig`:

| Argument   | Default      | Meaning |
|------------|--------------|---------|
| `name`     | (required)   | The name to query. IDNs become A-labels; `\.` and `\DDD` escapes work. |
| `type`     | `A`          | A mnemonic (`MX`, `DS`, `HTTPS`, ...) or `TYPEnnn`. |
| `class`    | `IN`         | `IN`, `CH`, `HS` or `CLASSnnn`. |
| `resolver` | `cloudflare` | `cloudflare`, `google` or `quad9`, asked over DoH. |
| `server`   |              | A server to ask directly, by address or name, or a DoH URL. |
| `transport`| `tcp`        | With `server`: `tcp`, `tls` (DoT) or `https` (DoH). |
| `port`     | `53` or `853`| With `server` over `tcp` or `tls`: the default, or from 1024 to 65535. |
| `dnssec`   | `false`      | Set DO, to get RRSIGs and the rest. |
| `cd`       | `false`      | Set CD (checking disabled). |
| `rd`       | `true`       | Set RD (recursion desired). |
| `edns`     | `true`       | Send an OPT record, with a UDP size of 1232. |
| `nsid`     | `false`      | Ask for the server's NSID. |
| `format`   | `dig`        | `dig` for dig-style text, `json` for structured JSON. |

Queries always set AD, as dig does, so that a validating resolver
reports whether it validated the answer.

The answer comes back in full: the header flags (`aa tc rd ra ad cd`),
the RCODE including extended RCODEs such as BADVERS, the OPT record with
its options (NSID, Extended DNS Errors, cookies, client subnet), and all
three sections with their TTLs. RDATA is shown in presentation format
for some fifty types. The rest use the RFC 3597 generic form. In JSON,
the common types also come with their values as separate fields: TXT
strings kept apart, DNSKEY key tags and flag meanings, RRSIG times as
ISO 8601 dates, and SVCB and HTTPS parameters taken apart.

Without `server`, the query goes as an RFC 8484 DoH POST in wire format
to a public validating resolver, so AD in the answer is meaningful.
With `server`, it goes straight to that server: over TCP (RFC 7766) by
default, because a Worker cannot send UDP; over TLS (RFC 7858) with
`transport: tls`, where the certificate must match the name or address
given; or over DoH with `transport: https`, where `server` is an https
URL on port 443, or a host that gets `/dns-query`. Nothing over UDP or
QUIC is possible from a Worker, so there is no DoQ or DoH over HTTP/3. A
Worker also cannot open TCP to Cloudflare's own addresses, so neither
`server: 1.1.1.1` nor any Cloudflare-hosted name server
(`*.ns.cloudflare.com`) can be asked directly; use a resolver instead.

Zone transfers are not supported.

## The audit

`dns_audit` checks a delegation from the root down to a name. At every
zone cut it asks every parent and child server, at every address, over
TCP, and compares the referrals with the child apex, the servers with
each other, and the answers for the name. It validates DNSSEC itself,
from the root trust anchors, and judges algorithms and digests by the
IANA registries of RFC 9904. The result is a list of findings, each
pointing at the raw responses that show it, and each denial of
existence spelt out step by step: for NSEC3, the closest encloser, the
next closer name and the wildcard, each with its hash and the record
that matches or covers it, and whether the proof holds, holds only
through opt-out, or fails.

The summary ends with the answer in one line. By default only the
queries that findings and proofs cite are listed, since a full audit
can run to 200,000 characters; `evidence` adds every query and every
response.

| Argument        | Default | Meaning |
|-----------------|---------|---------|
| `name`          | (required) | The name to audit. |
| `type`          | `A`     | The type to ask for at the end. |
| `thorough`      | `false` | Ask every root and TLD server too, not a sample. |
| `families`      | both    | `ipv4`, `ipv6` or both. |
| `max_queries`   | `300`   | The query budget, up to 1,000. |
| `time_limit_ms` | `25000` | The time budget, up to 60,000. |
| `evidence`      | `false` | List every query and response, not only those cited. |
| `format`        | `text`  | `text` or `json`. |

Name servers on Cloudflare's addresses cannot be reached from a
Worker; those zones are asked through 1.1.1.1 and marked as not
authoritative. Audits are limited to six a minute per client, one per
request, and 500 an hour for the whole service. See
[decision 0005](docs/decisions/0005-dns-audit.md).

## Using it

Add `https://korimako.mcp.strandkip.nl/mcp` as a custom
connector in your MCP client. In claude.ai that is under Settings,
Connectors, Add custom connector. There is no authentication.

Each client address may make 120 requests a minute. Connectors in
claude.ai reach korimako from Anthropic's addresses, so everyone using
it from there shares one allowance.

The front page, `/`, answers in plain text to programs and as a web page
to browsers, chosen by the `Accept` header. The page's icon, favicons and
fonts are in `public/`, which Workers serves as static assets.

## Problems and suggestions

If it doesn't seem to work, or you have an idea, open an
[issue](https://github.com/strandkip/korimako/issues) or a pull request,
or send e-mail to jabley@strandkip.nl. The front page says the same.

## Privacy and retention

korimako keeps nothing. It does not log queries or answers, and Workers
Logs are turned off in `wrangler.jsonc`. Cloudflare keeps its usual
request metrics for the account, which korimako cannot change. The
resolver or server asked sees the query and the address of the
Cloudflare data centre it came from.

## Building and testing

`make test` runs the tests with Node.js 22.6 or later and needs no
packages, so it runs on OpenBSD as well as Linux. The tests include a
mutation fuzzer for the decoder (`make fuzz` runs a million rounds),
and RDATA fixtures built and rendered by dnspython, an independent
implementation.

The rest needs `npm ci` first, which installs wrangler and TypeScript:

    make check     # tests, type check, and a dry-run bundle
    make dev       # run it locally at http://localhost:8787/mcp

wrangler's runtime has no OpenBSD build, so `make dev` and `make build`
need Linux or macOS.

[docs/setup.md](docs/setup.md) describes how to deploy it, from creating
the Cloudflare account to the GitHub Actions secrets. Every push to
`main` that passes the tests is deployed.

## Licence

ISC; see [LICENCE](LICENCE). The code was written mostly with an AI
model (Claude, by Anthropic), and it is not settled whether copyright
applies to such code. Where it does, these are the terms, and where it
does not, nothing restricts its use: the end of LICENCE says so.

The ISC licence does not cover the Strandkip artwork in `public/`
(`strandkip.svg`, `favicon.svg`, `favicon-32.png`,
`apple-touch-icon.png`). That is all rights reserved: see
[LICENCE.artwork](LICENCE.artwork). Do not use it without permission,
and remove or replace it if you run korimako yourself. The artwork is
copied unchanged from strandkip/private, `graphics/`. The Poppins fonts
are subsets of the originals, under the SIL Open Font License in
`public/Poppins-OFL.txt`.

This repository follows the
[Strandkip conventions](https://github.com/strandkip/conventions),
except where [docs/decisions](docs/decisions/) says otherwise.