How to integrate Ahrefs MCP with Codex

Codex is one of the most popular coding harnesses out there. And MCP makes the experience even better. With Ahrefs MCP integration, you can draft, triage, summarise emails, and much more, all without leaving the terminal or the app, whichever you prefer.

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

Introduction

Codex is one of the most popular coding harnesses out there. And MCP makes the experience even better. With Ahrefs MCP integration, you can draft, triage, summarise emails, and much more, all without leaving the terminal or the app, whichever you prefer.

Also integrate Ahrefs with

Why use Composio?

Apart from a managed and hosted MCP server, you will get:

  • CodeAct: A dedicated workbench that allows GPT to write its code to handle complex tool chaining. Reduces to-and-fro with LLMs for frequent tool calling.
  • Large tool responses: Handle them to minimise context rot.
  • Dynamic just-in-time access to 20,000 tools across 1000+ other Apps for cross-app workflows. It loads the tools you need, so GPTs aren't overwhelmed by tools you don't need.

How to install Ahrefs MCP in Codex

Run the setup command

Run this command in your terminal to add the Composio MCP server to Codex.

Terminal

It will initiate the authentication in a browser window, authorize Codex to access your Composio account.

Composio authentication page

(Optional) Authenticate with OAuth

To authenticate manually, run the login command to open a browser window and authorize Codex to access your Composio account.

bash
codex mcp login composio

Verify the connection

Run codex mcp list to confirm Composio appears as a registered MCP server.

bash
codex mcp list

Codex App

Codex App follows the same approach as VS Code.

  1. Click ⚙️ on the bottom left → MCP Servers → + Add servers → Streamable HTTP:
  2. Fill the header and Key fields with { "x-consumer-api-key" = "ck_*******" }.
  3. The Key is the Composio API key, that you can find on dashboard.composio.dev
  4. Click on Authenticate and authorize Codex to your Composio account and you're all set.
Codex App MCP setup
  1. Restart and verify if it's there in .codex/config.toml
bash
[mcp_servers.composio]
url = "https://connect.composio.dev/mcp"
http_headers = { "x-consumer-api-key" = "ck_*******" }

What is the Ahrefs MCP server, and what's possible with it?

The Ahrefs MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Ahrefs account. It provides structured and secure access to your SEO and marketing data, so your agent can perform actions like analyzing backlinks, researching keywords, auditing domain authority, and uncovering competitive insights on your behalf.

  • Comprehensive backlink analysis: Instantly retrieve detailed backlink profiles, stats, and broken link data for any website to inform your SEO strategy or spot link-building opportunities.
  • Keyword research and trends: Explore keyword overviews, search volumes by country, and discover matching or related terms to optimize content and target the right audience.
  • Domain authority tracking: Fetch up-to-date domain ratings or track historical changes to monitor the SEO health and growth of your own sites or competitors over time.
  • Batch competitor and site analysis: Analyze up to 100 domains or URLs at once to compare SEO metrics, spot weaknesses, and benchmark your performance against competitors efficiently.
  • Outbound link and partnership insights: Identify all external domains a site links to, helping you understand content strategy, partnerships, and potential link-building prospects.

Conclusion

You've successfully integrated Ahrefs with Codex using Composio's MCP server. Now you can interact with Ahrefs directly from your terminal, VS Code, or the Codex App using natural language commands.

Key benefits of this setup:

  • Seamless integration across CLI, VS Code, and standalone app
  • Natural language commands for Ahrefs operations
  • Managed authentication through Composio
  • Access to 20,000+ tools across 1000+ apps for cross-app workflows
  • CodeAct workbench for complex tool chaining

Next steps:

  • Try asking Codex to perform various Ahrefs operations
  • Explore cross-app workflows by connecting more toolkits
  • Build automation scripts that leverage Codex's AI capabilities
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.

FAQ

Frequently asked questions

With a standalone Ahrefs MCP server, the agents and LLMs can only access a fixed set of Ahrefs tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Ahrefs and many other apps based on the task at hand, all through a single MCP endpoint.

Yes, you can. Codex fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Ahrefs tools.

Yes, absolutely. You can configure which Ahrefs scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Ahrefs data and credentials are handled as safely as possible.

Start with Ahrefs.It takes 30 seconds.

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

Start building