Ahrefs MCP for AI Agents

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 Key

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.

40 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 the Domain Rating (DR) for a specified domain.

Domain rating history

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

Explore keywords overview

Retrieves a comprehensive overview of keyword data from Ahrefs' Keywords Explorer tool.

Explore keyword volume by country

Retrieves the search volume data for specified keywords across different countries using Ahrefs' Keywords Explorer tool.

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 comprehensive overview of competitor data in relation to keyword rankings and organic search performance.

Fetch rank tracker overview

The GetRankTrackerOverview endpoint retrieves a comprehensive summary of keyword rankings and SEO performance data from Ahrefs' Rank Tracker tool.

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 the historical total search volume data for specified keywords using Ahrefs' Site Explorer tool.

Get serp overview

Retrieves a comprehensive overview of Search Engine Results Pages (SERP) data for specified keywords or queries.

Get site audit projects

Retrieves a list of Site Audit projects associated with the authenticated Ahrefs account.

Get site explorer country metrics

Retrieves country-specific Site Explorer metrics for a given website from Ahrefs.

Get site explorer linked anchors external

The site-explorer-linked-anchors-external endpoint retrieves data about external anchor texts linking to a specified target website.

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

The 'get_best_by_external_links' endpoint retrieves a list of pages from a specified website, ranked by the number of external links pointing to them.

Pages by traffic overview

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

Retrieve anchor data

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

Retrieve best by internal links

Retrieves data on the best-performing internal links within a specified website using Ahrefs' Site Explorer feature.

Retrieve crawler ip ranges

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

Retrieve organic competitors

The GetOrganicCompetitors endpoint in the Ahrefs API provides a comprehensive analysis of websites competing for organic search rankings with a specified target domain.

Retrieve organic keywords

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

Retrieve outlinks stats

Retrieves comprehensive statistics about outgoing links (outlinks) from a specified website using Ahrefs' Site Explorer tool.

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

The keywords_explorer_related_terms endpoint retrieves a list of related terms for a given keyword using Ahrefs' extensive keyword database.

Retrieve site explorer keywords history

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

Retrieve site explorer metrics

The GetSiteExplorerMetrics endpoint retrieves comprehensive SEO metrics for a specified website using Ahrefs' Site Explorer tool.

Retrieve site explorer metrics history

Retrieves historical SEO metrics data for a specified website over a given time period.

Retrieve site explorer pages history

The get_site_explorer_pages_history endpoint retrieves historical data about specific pages or domains from Ahrefs' Site Explorer.

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 detailed information about the current subscription limits and usage for an Ahrefs account.

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 a given keyword or phrase using Ahrefs' Keywords Explorer tool.

SETUP GUIDE

Connect Ahrefs MCP Tool with your Agent

1

Install Composio

typescript
npm install @composio/core ai @ai-sdk/openai @ai-sdk/mcp
Install the Composio SDK and Claude Agent SDK
2

Create Tool Router Session

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

const composio = new Composio({ apiKey: 'your-api-key' });

console.log("Creating Tool Router session...");
const { mcp } = await composio.create('your-user-id');
console.log(`Tool Router session created: ${mcp.url}`);
Initialize the Composio client and create a Tool Router session
3

Connect to AI Agent

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

const client = await createMCPClient({
  transport: {
    type: 'http',
    url: mcp.url,
    headers: { 'x-api-key': 'your-composio-api-key' }
  }
});

const tools = await client.tools();

const { text } = await generateText({
  model: openai('gpt-4o'),
  tools,
  messages: [{ role: 'user', content: 'Show me the domain rating history for example.com' }],
  stopWhen: stepCountIs( 5 )
});

console.log(`Agent: ${text}`);
Use the MCP server with your AI agent
SETUP GUIDE

Connect Ahrefs API Tool with your Agent

1

Install Composio

typescript
npm install @composio/openai
Install the Composio SDK
2

Initialize Composio and Create Tool Router Session

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

const composio = new Composio({
  provider: new OpenAIResponsesProvider(),
});
const openai = new OpenAI({});
const session = await composio.create('your-user-id');
Import and initialize Composio client, then create a Tool Router session
3

Execute Ahrefs Tools via Tool Router with Your Agent

typescript
const tools = session.tools;
const response = await openai.responses.create({
  model: 'gpt-4.1',
  tools: tools,
  input: [{
    role: 'user',
    content: 'Show me all broken backlinks for example.com and suggest fixes.'
  }],
});
const result = await composio.provider.handleToolCalls(
  'your-user-id',
  response.output
);
console.log(result);
Get tools from Tool Router session and execute Ahrefs actions with your Agent

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
FAQ

Frequently asked questions

Yes, Ahrefs requires you to configure your own API key credentials. Once set up, Composio handles secure credential storage and API request handling for you.

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

Composio is SOC 2 and ISO 27001 compliant with all data encrypted in transit and at rest. Learn more.

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

Start with Ahrefs.It takes 30 seconds.

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

Start building