Ahrefs Integration 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 Logo
Gradient Top
Gradient Middle
Gradient Bottom
divider

Supported Tools

Tools
Backlinks stats retrievalRetrieves comprehensive backlink statistics for a specified website or url using ahrefs' site explorer tool.
Batch Url AnalysisPerforms a batch analysis on multiple urls or domains using ahrefs' powerful seo metrics.
Domain rating for site explorerRetrieves the domain rating (dr) for a specified domain.
Domain rating historyRetrieves the historical domain rating (dr) data for a specified domain over time.
Explore keywords overviewRetrieves a comprehensive overview of keyword data from ahrefs' keywords explorer tool.
Explore keyword volume by countryRetrieves the search volume data for specified keywords across different countries using ahrefs' keywords explorer tool.
Explore linked domains of a siteRetrieves a list of external domains that the specified target website or url links to, using ahrefs' site explorer functionality.
Explore matching terms for keywordsThe keywords explorer matching terms endpoint retrieves a list of keyword phrases that match or contain the specified keyword from ahrefs' vast database.
Fetch all backlinksRetrieves a comprehensive list of backlinks for a specified website or url using ahrefs' site explorer tool.
Fetch broken backlinks dataRetrieves a list of broken backlinks for a specified website using ahrefs' site explorer tool.
Fetch competitors overviewRetrieves a comprehensive overview of competitor data in relation to keyword rankings and organic search performance.
Fetch rank tracker overviewThe getranktrackeroverview endpoint retrieves a comprehensive summary of keyword rankings and seo performance data from ahrefs' rank tracker tool.
Fetch site explorer referring domainsRetrieves a list of domains that have backlinks pointing to a specified target website.
Fetch total search volume historyRetrieves the historical total search volume data for specified keywords using ahrefs' site explorer tool.
Get serp overviewRetrieves a comprehensive overview of search engine results pages (serp) data for specified keywords or queries.
Get site audit projectsRetrieves a list of site audit projects associated with the authenticated ahrefs account.
Get site explorer country metricsRetrieves country-specific site explorer metrics for a given website from ahrefs.
Get site explorer linked anchors externalThe site-explorer-linked-anchors-external endpoint retrieves data about external anchor texts linking to a specified target website.
Get url rating historyRetrieves the historical url rating data for a specified url over time.
Linked anchors explorerRetrieves information about internal linked anchors for a specified website using the ahrefs api.
List best by external linksThe '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 overviewRetrieves a list of pages from a specified website, ordered by their estimated organic search traffic.
Retrieve anchor dataRetrieves anchor text data for a specified website or url using ahrefs' site explorer tool.
Retrieve best by internal linksRetrieves data on the best-performing internal links within a specified website using ahrefs' site explorer feature.
Retrieve crawler ip rangesRetrieves the list of ip address ranges used by ahrefs' web crawler (ahrefsbot).
Retrieve organic competitorsThe getorganiccompetitors endpoint in the ahrefs api provides a comprehensive analysis of websites competing for organic search rankings with a specified target domain.
Retrieve organic keywordsRetrieves organic keywords data for a specified website using ahrefs' site explorer tool.
Retrieve outlinks statsRetrieves comprehensive statistics about outgoing links (outlinks) from a specified website using ahrefs' site explorer tool.
Retrieve paid pages dataRetrieves information about paid pages (ppc advertising) for a specified website using ahrefs' site explorer tool.
Retrieve public crawler ipsRetrieves a list of ip addresses currently used by ahrefsbot, ahrefs' web crawler.
Retrieve related termsThe keywords explorer related terms endpoint retrieves a list of related terms for a given keyword using ahrefs' extensive keyword database.
Retrieve site explorer keywords historyRetrieves historical keyword performance data for a specified website or domain using ahrefs' site explorer.
Retrieve site explorer metricsThe getsiteexplorermetrics endpoint retrieves comprehensive seo metrics for a specified website using ahrefs' site explorer tool.
Retrieve site explorer metrics historyRetrieves historical seo metrics data for a specified website over a given time period.
Retrieve site explorer pages historyThe get site explorer pages history endpoint retrieves historical data about specific pages or domains from ahrefs' site explorer.
Retrieve site explorer referring domains historyRetrieves the historical data of referring domains for a specified website or url over time.
Retrieve subscription limits and usageRetrieves detailed information about the current subscription limits and usage for an ahrefs account.
Retrieve top pages from site explorerRetrieves data about the top-performing pages of a specified website using ahrefs' site explorer tool.
Retrieve volume historyRetrieves the historical search volume data for a specified keyword using ahrefs' keywords explorer tool.
Search suggestions explorerRetrieves search suggestions for a given keyword or phrase using ahrefs' keywords explorer tool.

Connect Ahrefs MCP Tool with your Agent

Python
TypeScript

Install Composio

python
pip install composio claude-agent-sdk
Install the Composio SDK and Claude Agent SDK

Create Tool Router Session

python
from composio import Composio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions

composio = Composio(api_key='your-composio-api-key')
session = composio.create(user_id='your-user-id')
url = session.mcp.url
Initialize the Composio client and create a Tool Router session

Connect to AI Agent

python
import asyncio

options = ClaudeAgentOptions(
    permission_mode='bypassPermissions',
    mcp_servers={
        'tool_router': {
            'type': 'http',
            'url': url,
            'headers': {
                'x-api-key': 'your-composio-api-key'
            }
        }
    },
    system_prompt='You are a helpful assistant with access to Ahrefs tools.',
    max_turns=10
)

async def main():
    async with ClaudeSDKClient(options=options) as client:
        await client.query('Show me the domain rating history for example.com')
        async for message in client.receive_response():
            if hasattr(message, 'content'):
                for block in message.content:
                    if hasattr(block, 'text'):
                        print(block.text)

asyncio.run(main())
Use the MCP server with your AI agent

Connect Ahrefs API Tool with your Agent

Python
TypeScript

Install Composio

python
pip install composio_openai
Install the Composio SDK

Initialize Composio and Create Tool Router Session

python
from openai import OpenAI
from composio import Composio
from composio_openai import OpenAIResponsesProvider

composio = Composio(provider=OpenAIResponsesProvider())
openai = OpenAI()
session = composio.create(user_id='your-user-id')
Import and initialize Composio client, then create a Tool Router session

Execute Ahrefs Tools via Tool Router with Your Agent

python
tools = session.tools
response = openai.responses.create(
  model='gpt-4.1',
  tools=tools,
  input=[{
    'role': 'user',
    'content': 'Show me all broken backlinks for example.com and suggest fixes.'
  }]
)
result = composio.provider.handle_tool_calls(
  response=response,
  user_id='your-user-id'
)
print(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

Frequently Asked Questions

Do I need my own developer credentials to use Ahrefs with Composio?

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.

Can I use multiple toolkits together?

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

Is Composio secure?

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

What if the API changes?

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

Used by agents from

Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.