Ahrefs MCP
Ahrefs MCP is a Model Context Protocol server connecting Claude and AI assistants to Ahrefs API v3 for SEO data. It enables local or remote setup to access Ahrefs features seamlessly within AI tools.
How to Install and Use Ahrefs MCP
Ahrefs MCP is a tool that helps connect AI assistants to Ahrefs data with ease. If you want to install it on your computer, follow these simple steps. The instructions include how to install Node.js, add the Ahrefs MCP server, and configure it properly.
Step 1: Install Node.js and npm
Before installing Ahrefs MCP, you need Node.js and npm installed on your device. These let you run the MCP server.
Here’s what to do:
- Visit nodejs.org and download the version for your operating system.
- Follow the instructions to install Node.js on your computer.
- Open your terminal (macOS) or command prompt (Windows).
- Type this command to check it works:
npm -v
If you see a version number, that means Node.js and npm are ready. If not, make sure the installer added npm to your PATH environment (especially on Windows).
Step 2: Install the Ahrefs MCP Server
Now that Node.js is ready, you can install the Ahrefs MCP server globally on your computer using npm. This lets your AI assistant communicate with Ahrefs.
Run this command in the terminal or command prompt:
npm install --prefix=~/.global-node-modules @ahrefs/mcp -g
- For Windows users, replace
~/.global-node-moduleswith the full path to your global modules folder, like:
--prefix=C:\Users\YOUR_USERNAME\.global-node-modules\node_modules
Make sure you replace YOUR_USERNAME with your actual Windows user name.
If you want to upgrade the MCP server later, use:
npm install --prefix=~/.global-node-modules @ahrefs/mcp@latest -g
Step 3: Configure the MCP Server in Your AI Assistant
After installation, you need to tell your AI assistant to use the Ahrefs MCP server. This is done by adding a configuration section with your API key.
Here’s an example configuration:
{
"mcpServers": {
"ahrefs": {
"command": "npx",
"args": [
"--prefix=~/.global-node-modules",
"@ahrefs/mcp"
],
"env": {
"API_KEY": "YOUR_API_KEY_HERE"
}
}
}
}
Important:
- Replace
YOUR_API_KEY_HEREwith your actual Ahrefs API key. - On Windows, remember to use double backslashes in the prefix and the full path, for example:
"args": [
"--prefix=C:\\Users\\YOUR_USERNAME\\.global-node-modules\\node_modules",
"@ahrefs/mcp"
]
Step 4: Locate and Edit Your AI App’s Configuration File
Depending on your AI app, the configuration file location varies:
- For Claude Desktop:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
- For Cursor:
- Project or global files at
.cursor/mcp.jsonor~/.cursor/mcp.json
- Project or global files at
Open your app’s config file and paste the configuration from Step 3. Save the file and restart the app to load the new MCP settings.
Following these steps will get Ahrefs MCP installed and running in your AI assistant. If you have any errors, check that your Node.js and npm are installed correctly, your API key is valid, and the file paths use the right formats. This setup helps you connect easily to Ahrefs data using Model Context Protocol tools.