How do you audit SPF and DMARC with an AI agent, using AdminKit's MCP server?
AdminKit's check_mail_auth tool lets an AI agent ask AdminKit's live Check API to read a domain's SPF and DMARC records and report whether outbound mail authentication is actually enforced, so you can audit SPF and DMARC posture from a chat prompt instead of decoding DNS TXT records by hand.
By AdminKit team, Netbase JSC · Updated
Key takeaways
check_mail_authgives an AI agent a structured mail-authentication audit of any domain from one prompt. It reads only public DNS records, so no ownership check is needed.- Through AdminKit’s Check API it scores seven sub-checks: DMARC, SPF, DKIM (common selectors), MX, MTA-STS, TLS-RPT and BIMI. The score is 0-100, and 90 or above counts as
ok. - The two findings that matter most are an SPF record ending in
+all(anyone passes SPF) and a DMARC policy ofp=none(no enforcement). - Every response uses the same envelope,
result,evidence,fix_hintandreport_url, so the agent can quote the evidence and the first fix instead of guessing.
How do you ask your agent to run the audit?
Install AdminKit’s open-source adminkit-mcp connector (MIT, PyPI) and wire it into any MCP-capable AI agent — see connect an AI agent to AdminKit’s MCP server if you haven’t yet. Once it’s running:
uvx adminkit-mcp
Ask the agent, in plain language:
“Use check_mail_auth to check SPF and DMARC for my domain, and tell me what to fix if anything looks wrong.”
The agent calls check_mail_auth(domain="...") and gets back a structured result it can read, summarize, or act on — no manual dig TXT lookups or squinting at raw SPF mechanisms required. Prompts that work well name the domain, say what you want back, and ask the agent to cite the evidence. For example: “Run check_mail_auth on example.org, list each finding with its id, and quote the DNS record that caused it.”
What does check_mail_auth check?
The tool takes two paths. Normally it calls AdminKit’s Check API (POST /v1/check/mail), which runs a full mail-posture check. If that route is ever briefly unreachable, it falls back to the SPF and DMARC function behind AdminKit’s public mail tool pages, which covers a narrower set of conditions. Both paths read the domain’s published SPF record (the v=spf1 ... TXT record) and its DMARC policy (the _dmarc TXT record).
On the Check API path, seven sub-checks contribute to one score. The weights below are the ones AdminKit’s check library uses:
| Sub-check | Weight | What it reads | Standard |
|---|---|---|---|
| DMARC | 30 | _dmarc TXT: policy, pct, rua, alignment tags | RFC 9989 |
| SPF | 25 | v=spf1 TXT, including include: chains and the final all | RFC 7208 |
| DKIM | 20 | Public keys at up to 20 common selector names | RFC 6376 |
| MX | 15 | MX records, including null MX | RFC 5321, RFC 7505 |
| MTA-STS / TLS-RPT / BIMI | 5 / 3 / 2 | _mta-sts TXT and policy file, _smtp._tls TXT, BIMI TXT | RFC 8461, RFC 8460 |
A sub-check that passes earns its full weight, a warning earns half, and a failure earns nothing. A sub-check that could not run, such as DKIM when no common selector exists, is left out of both sides of the calculation, so it does not drag the score down. The overall status is ok at 90 or above, warn from 60 to 89, and fail below 60.
On the fallback path, the tool flags four specific conditions: SPF missing or unparsable, DMARC missing or unparsable, SPF ending in the permissive +all mechanism (which RFC 7208 defines as matching literally any sending host), and DMARC still set to p=none. RFC 9989 §3.2.8 defines p=none as the Domain Owner offering no expression of preference — the current DMARC specification’s own way of saying it carries no enforcement effect on its own, so a domain can have a syntactically valid DMARC record and still be fully spoofable in practice.
Which findings should you fix first?
The Check API returns each problem as a finding with a stable id, a severity and a fix hint. These are the SPF and DMARC findings most likely to come up, ordered roughly by how much they weaken protection:
| Finding id | Severity | What it means | Usual fix |
|---|---|---|---|
spf.allows_all | critical | SPF ends in +all; any server passes | Change to -all (or ~all while testing) |
dmarc.missing | high | No _dmarc record at all | Publish a DMARC record, starting with p=none and an rua address |
spf.too_many_lookups | high | More than 10 DNS-querying mechanisms, so SPF returns permerror | Flatten or remove include: entries |
dmarc.policy_none | medium | Monitor-only; failing mail is delivered as usual | Move to p=quarantine, then p=reject, once reports look clean |
dmarc.no_rua | medium | No aggregate reports, so no visibility into who sends as you | Add rua=mailto: with an address you read |
The DNS lookup limit comes from RFC 7208 §4.6.4, which caps SPF evaluation at 10 mechanisms that need a DNS query; too many DNS lookups in SPF walks through flattening a long include: chain. For the meaning of every SPF qualifier and result, see what an SPF check result means.
What does a response look like?
This is a labelled example, not a claim about any specific domain’s current records. It shows the Check API path for the documentation domain example.org, trimmed for length: the per-sub-check sub_results and each finding’s detail text are left out. The domain in this example publishes SPF with -all, DMARC at p=none with an rua address, a DKIM key at selector1 and working MX records, but no MTA-STS, TLS-RPT or BIMI records. The score follows the weights above: 15 (DMARC, half) + 25 + 20 + 15 + 2.5 + 1.5 + 1 = 80.
{
"tool": "check_mail_auth",
"status": "warn",
"result": {
"check": "mail.posture",
"target": "example.org",
"summary": "example.org mail posture score 80/100 (dmarc=warn, spf=ok, dkim=ok, mx=ok, mta_sts=warn, tls_rpt=warn, bimi=warn)",
"findings": [
{ "id": "dmarc.policy_none", "severity": "medium", "fix_hint": "Move to 'p=quarantine' once reports confirm senders pass, then 'p=reject'." },
{ "id": "mta_sts.missing", "severity": "low" },
{ "id": "tls_rpt.missing", "severity": "low" },
{ "id": "bimi.missing", "severity": "info" }
],
"score": 80
},
"evidence": { "breakdown": { "dmarc": { "status": "warn", "weight": 30, "factor": 0.5 } } },
"fix_hint": "Move to 'p=quarantine' once reports confirm senders pass, then 'p=reject'.",
"report_url": "https://adminkit.net/tools/spf-check/?utm_source=mcp"
}
The top-level fix_hint is always the first finding’s fix, and findings are listed in weight order with DMARC first, so the most consequential problem is the one an agent will quote. On the fallback path the shape is simpler: result carries spf_status, dmarc_status and a findings list, and evidence holds the raw SPF and DMARC parse. A domain that’s missing SPF or DMARC entirely gets spf_status/dmarc_status of "not-found" and a fix_hint naming which record to publish first; a well-configured domain gets status: "ok" and fix_hint: null. How do you read a DMARC check result covers reading the DMARC-specific tags (p, pct, rua) in depth once you have a real result in front of you.
Why is DKIM sometimes skipped?
A DKIM public key is published at <selector>._domainkey.<domain>, and the selector is chosen by whoever signs your mail. Nothing in DNS lists the selectors a domain uses, which is why RFC 6376 leaves discovery to the signature itself: a receiving server reads the selector from the s= tag of each message’s DKIM-Signature header. An outside check has no message to read, so it can only try likely names.
The Check API tries up to 20 common selector names, one TXT query each, and audits every one that resolves. If none of them match, the DKIM sub-check is reported as skipped with the finding dkim.no_selector_known and is left out of the score. That is a limit of checking from outside, not a statement that your DKIM is broken. To audit a custom selector, read it from the s= tag in a message you sent and check it on AdminKit’s DKIM check page; DKIM selector mistakes covers the usual reasons a selector is wrong or missing.
How do you use the audit before a mail migration?
Moving to a new mail provider is where an agent-run audit saves the most time, because the same checks need to pass before, during and after the switch. A workable sequence:
- Baseline. Ask the agent to run
check_mail_authon every domain you send from and keep the scores and findings. - Add the new sender. Add the new provider’s
include:to SPF and publish its DKIM key, then run the audit again. Watch forspf.too_many_lookups, which often appears at this step. - Cut over. Change MX, then re-run. The MX sub-check confirms the new records resolve.
- Tighten. Once DMARC aggregate reports show the new provider passing alignment, move from
p=nonetowardsp=rejectand confirmdmarc.policy_nonehas gone.
Migrating email providers without breaking SPF/DKIM/DMARC is the fuller checklist, and SPF, DKIM and DMARC explained covers how the three fit together if you need the background first.
Why run this from an agent instead of the SPF tool page?
An agent that can call check_mail_auth directly can fold the check into a bigger workflow — auditing every domain your org sends mail from before a migration, re-checking after a DNS change, or explaining the fix in the same conversation where you’re already debugging why a message landed in spam. The AI agents & MCP cluster covers the broader pattern of giving an agent real, structured tools instead of asking it to scrape a web page and guess at the meaning of what it finds. That pattern — a well-defined tool an agent can discover and call directly — is exactly what the Model Context Protocol specification itself defines, and it’s what lets adminkit-mcp expose check_mail_auth to any compliant agent in the first place.
The web pages are still the better choice for a single quick look, and for checks the MCP tool does not cover. AdminKit’s SPF check shows the record and its lookup chain in a browser, and the MTA-STS check goes deeper into the policy file than the posture score does; how to publish and test MTA-STS explains what to publish if the audit flags it as missing. Use the agent when you want the same check repeated across many domains, or when you want the result explained in the context of the problem you are already working on.
This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.
Frequently asked questions
Which real tool does this use, and where does the data come from?
check_mail_auth, one of the 15 tools in adminkit-mcp (PyPI, MIT). It calls AdminKit's live Check API (api.adminkit.net, POST /v1/check/mail), with a fallback to the SPF/DMARC function behind AdminKit's public mail tool pages if that specific route is ever briefly unreachable. It only reads published DNS records (and, for MTA-STS, the published policy file) for the domain you give it — nothing is guessed or fabricated.
Does it check DKIM too?
Partly. DKIM keys live under a selector (the prefix before `._domainkey`), which isn't knowable from the domain name alone. Through the Check API, check_mail_auth tries a fixed list of 20 common selector names (selector1, selector2, google, k1, default and others) and audits any that exist; if none match, DKIM is reported as skipped with the finding dkim.no_selector_known and left out of the score. If your provider uses a different selector, check it on the DKIM check tool page. The fallback path covers SPF and DMARC only.
Do I need to own the domain to run this?
No ownership verification is required for this check — SPF and DMARC records are published in public DNS by design, the same data any mail server performing its own authentication check would read. Treat the result the same way regardless: it's informative about any domain's public posture, not a private scan.
What does a 'warn' result mean versus 'ok'?
On the Check API path, status comes from a 0-100 posture score: 90 or above is ok, 60-89 is warn, below 60 is fail. On the fallback path, ok means SPF and DMARC both resolve cleanly, SPF doesn't end in the permissive +all mechanism, and DMARC isn't stuck at monitoring-only (p=none); warn means at least one of those is true. Either way, the fix_hint field names the first thing to fix.
Why is my score below 100 when SPF and DMARC look fine?
The Check API scores seven sub-checks, not two. DMARC (30 points) and SPF (25) carry most of the weight, but DKIM (20), MX (15), MTA-STS (5), TLS-RPT (3) and BIMI (2) count too. A sub-check that passes earns its full weight, a warning earns half, and a failure earns nothing, so a missing MTA-STS or TLS-RPT record costs a few points even when SPF and DMARC are correct.
Sources
- RFC 7208 — Sender Policy Framework (SPF)
- RFC 9989 — Domain-based Message Authentication, Reporting, and Conformance (DMARC)
- Model Context Protocol — official specification
- RFC 6376 — DomainKeys Identified Mail (DKIM) Signatures
- RFC 8461 — SMTP MTA Strict Transport Security (MTA-STS)
- RFC 8460 — SMTP TLS Reporting
Related tools
Want AdminKit to watch this for you?
Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.
Talk to an expert
Huy Nguyen (David), Founder & CEO, Netbase JSC
Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.