# Ahrefs MCP

Connect the official Ahrefs MCP server, sample backlinks to one page, and give your team a shortlist of source pages to verify.

## Connect the official server

The hosted connector uses OAuth on paid Ahrefs plans starting at Lite. The Backlinks report draws from your shared API units and has a 50-unit minimum per request. Check the workspace and key limits in Ahrefs before approving the read.

Hosted endpoint `https://api.ahrefs.com/mcp/mcp`

### Claude Code

Add the hosted server with the Site Explorer reports group. In Claude Code, open /mcp, sign in to Ahrefs, choose your workspace and click Allow. This group exposes the Backlinks report and keeps account management tools out of this connection.

```sh
claude mcp add ahrefs "https://api.ahrefs.com/mcp/mcp?tools=site-explorer-reports" -t http
```

[Ahrefs setup for Claude Code](https://docs.ahrefs.com/en/mcp/docs/claude-code)

### Claude Desktop or web

Open Customize → Connectors. Add the Ahrefs connector, then sign in and choose your workspace. Enable it for the chat and keep approval prompts on for the Backlinks report. Check that the report appears in the client’s tool list.

[Ahrefs setup for Claude Desktop and web](https://docs.ahrefs.com/en/mcp/docs/claude-desktop-web)

## Sample backlinks to one URL

Start with a page your team cares about, such as a service page. This read-only workflow gives you the linking pages, the anchor text Ahrefs saw and which source to verify first.

1. **Pick the target and confirm the report.** Use one operator-approved public URL, including its protocol and path. Find Site Explorer Backlinks in your client and check its input schema. If the report is missing, check the connected workspace and the Site Explorer reports tool group.
2. **Approve one read of up to five rows.** Use the example’s fields and sort. Set the scope to exact, history to live and the protocol to match the target. Use all as the aggregation mode so you can see repeated links. Get approval for the read and unit budget before calling the report.
3. **Group the sample by referring domain.** Keep rows that point to the approved URL. Ignore fragments and retain path, query, protocol and trailing slash differences. Keep the first row per source page. Group by the referring root domain and preserve source URL, destination, anchor, Ahrefs crawl date and nofollow flag.
4. **Give a teammate one source to verify.** Record the target, observation time, row counts and units if shown. Start with the source Ahrefs last visited longest ago. Check the live page for the link and its destination before making an outreach decision. An empty or capped sample gives you only what Ahrefs returned for that read.

### Prompt for your agent

Use ahrefs-mcp-backlinks.json. Default to offline and read the saved response and observation time. Compare source and destination URLs after standard URL normalization and fragment removal. Preserve path, query, protocol and trailing slash distinctions. Count rows outside the target and skip them. For each in-scope source page, keep the first row and count repeats. Group by root_name_source and preserve url_from, url_to, anchor, last_visited and is_nofollow. Pick the oldest last_visited among retained rows as the first source to check. Return null when there is no retained source. Compute before checking expected. In live mode, use the official Ahrefs connection in a supported client, find Site Explorer Backlinks and map the file’s parameters to the tool’s schema. Ask for an exact public URL and approval for one metered read. Match the protocol to the target and keep the live history and five-row cap. Stop on missing access, insufficient budget or a failed call. Qualify the output as an index sample and label an empty sample. Report units if shown. Leave outreach and account changes to the operator.

## Replay the example

Save both files in the same folder and run the command with Node.js 18+. The replay uses local fictional data.

- [Download example JSON](https://seotoolsforagents.com/examples/ahrefs-mcp-backlinks.json)
- [Download Node runner](https://seotoolsforagents.com/examples/seo-mcp-replay.mjs)

```sh
node seo-mcp-replay.mjs ahrefs-mcp-backlinks.json --verify
```

A result of verified: true means the output matches the expected fields.

https://roofworks.example/roof-repair

| Referring domain | Source pages | Nofollow flagged |
| --- | --- | --- |
| neighborhood-news.example | 2 | 0 |
| business-directory.example | 1 | 1 |

## Provider references

- [Ahrefs MCP access and usage](https://docs.ahrefs.com/en/mcp/docs/introduction)
- [Ahrefs MCP tool categories](https://docs.ahrefs.com/en/mcp/docs/tool-categories)
- [Site Explorer Backlinks fields and pricing](https://docs.ahrefs.com/en/api/reference/site-explorer/get-all-backlinks)
- [Ahrefs setup for ChatGPT web](https://docs.ahrefs.com/en/mcp/docs/chatgpt-web)

## Where to go next

- [Recover backlinks to broken URLs](https://seotoolsforagents.com/workflows/recover-broken-backlinks.md)
- [Try Semrush for a domain keyword comparison](https://seotoolsforagents.com/mcp-servers/semrush.md)
- [Compare AI SEO tools](https://seotoolsforagents.com/compare/ai-seo-tools.md)
