Ahrefs MCP server for AI agents and assistants

Securely connect your AI agents and chatbots (Claude, ChatGPT, Cursor, etc) with Ahrefs MCP or direct API to analyze keywords, audit websites, find backlink opportunities, and monitor competitors through natural language.

Ahrefs logoAhrefs
Api KeyOauth2

Ahrefs is an SEO and marketing platform for site audits, keyword research, and competitor insights. It helps you improve search rankings and drive organic traffic.

46 Tools

Try Ahrefs now

Type what you want done — sign in and watch it run live in the Tool Router playground.

TOOL ROUTER PLAYGROUND
Ahrefs
Try asking
TOOLS

Supported Tools

Every Ahrefs action and event your agent gets out of the box.

Backlinks stats retrieval

Retrieves comprehensive backlink statistics for a specified website or URL using Ahrefs' Site Explorer tool.

Batch Url Analysis

Performs a batch analysis on multiple URLs or domains using Ahrefs' powerful SEO metrics.

Domain rating for site explorer

Retrieves Ahrefs Domain Rating and Ahrefs Rank for a specified domain or URL on a requested date.

Domain rating history

Retrieves the historical Domain Rating (DR) data for a specified domain over time.

Explore keywords overview

Retrieves keyword-level overview metrics from Ahrefs' Keywords Explorer for specified keywords or an existing keyword list in a country.

Explore keyword volume by country

Retrieves monthly search volume data across countries for a specified keyword using Ahrefs' Keywords Explorer.

Explore linked domains of a site

Retrieves a list of external domains that the specified target website or URL links to, using Ahrefs' Site Explorer functionality.

Explore matching terms for keywords

The keywords_explorer_matching_terms endpoint retrieves a list of keyword phrases that match or contain the specified keyword from Ahrefs' vast database.

Fetch all backlinks

Retrieves a comprehensive list of backlinks for a specified website or URL using Ahrefs' Site Explorer tool.

Fetch broken backlinks data

Retrieves a list of broken backlinks for a specified website using Ahrefs' Site Explorer tool.

Fetch competitors overview

Retrieves a Rank Tracker competitor overview for a project, including comparative keyword ranking and organic search performance data.

Fetch rank tracker overview

Retrieves an Ahrefs Rank Tracker overview for a project, date and device, with ranking and search-performance metrics.

Fetch site explorer referring domains

Retrieves a list of domains that have backlinks pointing to a specified target website.

Fetch total search volume history

Retrieves historical total search volume for keywords associated with a target domain or URL using Ahrefs Site Explorer.

Get content helper topics

Retrieve topics covered by top-ranking pages for a keyword.

Get domain rating free

Retrieve the free Ahrefs Domain Rating for a domain or URL.

Get domain rating top domains

Retrieves domains ordered by Ahrefs Domain Rating.

Get serp overview

Retrieves a SERP overview for one keyword in a specified country, optionally at a historical date.

Get site audit projects

Lists Site Audit projects associated with the authenticated Ahrefs account, with project and crawl status details.

Get site explorer AI responses count

Retrieve AI response citation and page counts for a site.

Get site explorer country metrics

Retrieves country-specific Site Explorer metrics for a target website or URL, including organic traffic and keyword metrics.

Get site explorer crawled pages

Retrieve crawled pages and crawl metadata for a target URL.

Get site explorer linked anchors external

Retrieves anchor text data for external links going out from a target website using Ahrefs Site Explorer.

Get url rating history

Retrieves the historical URL Rating data for a specified URL over time.

Linked anchors explorer

Retrieves information about internal linked anchors for a specified website using the Ahrefs API.

List best by external links

Retrieves pages from a specified website using Ahrefs' Site Explorer best-by-external-links report.

Pages by traffic overview

Retrieves a list of pages from a specified website, ordered by their estimated organic search traffic.

Post Domain Rating Free

Retrieve Domain Rating scores for up to 1,000 target URLs.

Retrieve anchor data

Retrieves anchor text data for a specified website or URL using Ahrefs' Site Explorer tool.

Retrieve best by internal links

Retrieves pages ranked by internal links for a specified website using Ahrefs' Site Explorer.

Retrieve crawler ip ranges

Retrieves the list of IP address ranges used by Ahrefs' web crawler (AhrefsBot).

Retrieve organic competitors

Retrieves organic search competitors for a target domain or URL, with keyword overlap and performance metrics.

Retrieve organic keywords

Retrieves organic keywords data for a specified website using Ahrefs' Site Explorer tool.

Retrieve outlinks stats

Retrieves outgoing-link statistics for a specified website or URL using Ahrefs Site Explorer.

Retrieve paid pages data

Retrieves information about paid pages (PPC advertising) for a specified website using Ahrefs' Site Explorer tool.

Retrieve public crawler ips

Retrieves a list of IP addresses currently used by AhrefsBot, Ahrefs' web crawler.

Retrieve related terms

Retrieves related keyword ideas for a given keyword or keyword list in a specified country.

Retrieve site explorer keywords history

Retrieves historical keyword performance data for a specified website or domain using Ahrefs' Site Explorer.

Retrieve site explorer metrics

Retrieves Site Explorer SEO metrics for a target domain or URL on a specified date, including backlink, referring-page and crawled-page counts.

Retrieve site explorer metrics history

Retrieves historical Site Explorer traffic metrics for a target website or URL over a specified period, including estimated organic and paid traffic and cost.

Retrieve site explorer pages history

Retrieves historical page counts for a target domain or URL from Ahrefs Site Explorer over a specified period.

Retrieve site explorer referring domains history

Retrieves the historical data of referring domains for a specified website or URL over time.

Retrieve subscription limits and usage

Retrieves an Ahrefs account's subscription limits and remaining API usage allowance.

Retrieve top pages from site explorer

Retrieves data about the top-performing pages of a specified website using Ahrefs' Site Explorer tool.

Retrieve volume history

Retrieves the historical search volume data for a specified keyword using Ahrefs' Keywords Explorer tool.

Search suggestions explorer

Retrieves search suggestions for keywords or an existing keyword list using Ahrefs Keywords Explorer.

SETUP GUIDE

Connect Ahrefs MCP Tool with your Agent

1

Install Composio

typescript
npm install @composio/core ai @ai-sdk/mcp @ai-sdk/openai
Install the Composio SDK and your agent framework
2

Create a session with MCP enabled

typescript
import { Composio } from "@composio/core";

const composio = new Composio();
const { mcp } = await composio.create("your-user-id", {
  toolkits: ["ahrefs"],
  mcp: true,
});
Create a session scoped to Ahrefs and read its MCP URL and headers
3

Connect your agent to the MCP server

typescript
import { createMCPClient } from "@ai-sdk/mcp";
import { openai } from "@ai-sdk/openai";
import { generateText, stepCountIs } from "ai";

const client = await createMCPClient({
  transport: { type: "http", url: mcp.url, headers: mcp.headers },
});

const { text } = await generateText({
  model: openai("gpt-5.6-sol"),
  tools: await client.tools(),
  prompt: "Show me all broken backlinks for example.com and suggest fixes.",
  stopWhen: stepCountIs(10),
});

console.log(text);
await client.close();
Pass the session's MCP URL and headers to your agent and run a Ahrefs request
SETUP GUIDE

Connect Ahrefs API Tool with your Agent

1

Install Composio

typescript
npm install @composio/core @composio/openai openai
Install the Composio SDK, the OpenAI provider, and the OpenAI SDK
2

Create a Composio session

typescript
import OpenAI from "openai";
import { Composio } from "@composio/core";
import { OpenAIResponsesProvider } from "@composio/openai";

const composio = new Composio({ provider: new OpenAIResponsesProvider() });
const client = new OpenAI();

const session = await composio.create("your-user-id", { toolkits: ["ahrefs"] });
const tools = await session.tools();
Initialize Composio with the OpenAI Responses provider and create a session scoped to Ahrefs
3

Run Ahrefs tools with your agent

typescript
let response = await client.responses.create({
  model: "gpt-5.6-sol",
  tools,
  input: [{ role: "user", content: "Show me all broken backlinks for example.com and suggest fixes." }],
});

while (response.output.some((o) => o.type === "function_call")) {
  const outputs = await composio.provider.handleToolCalls(session, response.output);
  response = await client.responses.create({
    model: "gpt-5.6-sol",
    tools,
    previous_response_id: response.id,
    input: outputs,
  });
}

console.log(response.output_text);
Send a request, execute the Ahrefs tool calls through the session, and print the final answer

Why Use Composio?

AI Native Ahrefs Integration

  • Supports both Ahrefs MCP and direct API based integrations
  • Structured, LLM-friendly schemas for reliable tool execution
  • Rich coverage for reading, writing, and querying your Ahrefs data

Managed Auth

  • Built-in API key handling with secure storage
  • Central place to manage, scope, and revoke Ahrefs access
  • Per user and per environment credentials instead of hard-coded keys

Agent Optimized Design

  • Tools are tuned using real error and success rates to improve reliability over time
  • Comprehensive execution logs so you always know what ran, when, and on whose behalf

Enterprise Grade Security

  • Fine-grained RBAC so you control which agents and users can access Ahrefs
  • Scoped, least privilege access to Ahrefs resources
  • Full audit trail of agent actions to support review and compliance

Rolling this out across your team?

Give your team centralized access control across every framework with Composio’s MCP Gateway.

EXPLORE MCP GATEWAY
FAQ

Frequently asked questions

Ahrefs requires connections to go through your own OAuth app. You register it once with Ahrefs, add its client ID and secret in the Composio dashboard, and from then on everyone connects by signing in to Ahrefs as usual. Composio handles the rest of the flow and the token refresh.

Yes! Composio's Tool Router enables agents to use multiple toolkits. Learn more.

Yes. Composio is SOC 2 Type II compliant and is built to keep your Ahrefs connection and credentials secure. OAuth tokens and API keys are encrypted, and sensitive customer data is protected at rest and in transit.

Composio also undergoes independent security testing and continuously monitors its systems for security threats. You can review the latest reports and policies in the Composio Trust Center.

Composio maintains and updates all toolkit integrations automatically, so your agents always work with the latest API versions.

When you connect a Ahrefs account through Composio, every action runs under that account, so anything the agent creates, sends, or changes shows up in Ahrefs as done by you. Keep an approval step in your prompt for actions with side effects, such as sending or deleting, and have the agent draft first.

Exactly the ones Ahrefs lists on its consent screen when you connect. Review that screen before approving. If you connect a work account, your Ahrefs administrator may need to approve the app first, and you can revoke the access inside Ahrefs whenever you want.

Yes. Composio supports multiple connected accounts for the same app, and that works in Claude, ChatGPT, or any other assistant you connect through Composio. Give each Ahrefs connection a name such as work or personal, and the assistant uses the one you mention in the request. Each account keeps its own credentials and nothing is merged.

Composio refreshes Ahrefs tokens automatically, so day to day you do nothing. If you revoke access inside Ahrefs, or Ahrefs invalidates the session, the connection shows as expired in Composio and the agent stops acting on that account until you reconnect it, which is a single sign-in.

Composio's free Hobby plan includes 100,000 tool calls per month with no credit card, which covers most personal Ahrefs use. Paid plans add higher limits and team features. Your Ahrefs plan and its API limits still apply as usual.

Built-in connectors usually give one AI access to a limited set of apps. Many people use Composio because it lets their AI connect to more apps than it normally supports, or connect to multiple accounts for the same app (e.g. connect Claude to multiple Ahrefs accounts).

With Composio, you connect Ahrefs once and then use it across different AI assistants without setting it up separately in each one. Connect your apps to Composio once, then connect Composio to whichever AI you use, whether that's Claude, ChatGPT, Hermes, or your own custom assistant.

Start with Ahrefs.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Ahrefs tool your agent needs.Free to start.

Start building