home / mcp / ahrefs mcp server

Ahrefs MCP Server

Official Ahrefs MCP Server

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "ahrefs-ahrefs-mcp-server": {
      "command": "npx",
      "args": [
        "--prefix=~/.global-node-modules",
        "@ahrefs/mcp"
      ],
      "env": {
        "API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

The Ahrefs MCP Server lets you connect Claude Desktop and other compatible AI assistants to Ahrefs data sources via a Model Context Protocol (MCP). It enables natural-language queries and actions on Ahrefs data through your AI tools, making it easier to access insights and automate tasks.

How to use

Set up the local Ahrefs MCP Server to enable your AI assistant to query Ahrefs data. You will run the MCP server locally and point your AI client to it using the provided configuration. Provide your API key in the environment to authorize requests. Once configured, your AI assistant can send requests to Ahrefs data through the MCP bridge.

How to install

Prerequisites you need before installation:

  • Node.js and npm must be installed on your system
  • You will run commands in a terminal or command prompt
  • Ensure Node.js version is compatible with the MCP package

Step-by-step commands to install the MCP server globally for your user:

npm install --prefix=~/.global-node-modules @ahrefs/mcp -g

Configuration details

Configure your AI client to load the Ahrefs MCP server using a local stdio configuration. The following snippet shows how to reference the MCP server from your assistant’s configuration:

{
  "mcpServers": {
    "ahrefs": {
      "command": "npx",
      "args": [
        "--prefix=~/.global-node-modules",
        "@ahrefs/mcp"
      ],
      "env": {
        "API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

Upgrading versions

If you previously installed the MCP server and want to upgrade to the latest version, run the following command to update the package in your user-scoped global modules:

npm install --prefix=~/.global-node-modules @ahrefs/mcp@latest -g