@ahrefs/mcp

中文文档
0.0.11发布于 2025/05/27MITES Module近 30 天下载 1795

Ahrefs MCP server

原始使用文档
文档目录18 节
  1. Installation
  2. Install Node.js and npm
  3. Install Ahrefs MCP Server
  4. Upgrading versions
  5. Configuration
  6. Specific for Windows OS
  7. Where to find the configuration file
  8. Common Installation Issues & Fixes
  9. 1. Node.js or npm Not Installed / Recognized
  10. 2. Permission Errors During Global Installation
  11. 2a. macOS Terminal Permissions
  12. 3. npx Cannot Find the Ahrefs MCP Command
  13. 4. Configuration File Not Detected
  14. 5. API Key Problems
  15. 6. Path Expansion Issues
  16. 🧪 Diagnostic Commands Per Platform
  17. 📍 Summary of Key Paths
  18. 📘 Still Having Issues?

Ahrefs MCP

A Model Context Protocol server to connect Claude desktop and other compatible AI assistants to Ahrefs.

Installation

npm commands need to be executed in a terminal:

  • macOS: open the Terminal from your Applications folder
  • Windows: press Windows + R, type cmd, and press Enter

Install Node.js and npm

  1. Download Node.js from nodejs.org
  2. Follow the installation instructions for your operating system
  3. Verify installation by running:
npm -v
  1. A version number will be printed if installation was successful

Windows Users

  • When installing Node.js, use the official installer and make sure the folder is added to PATH when selecting installation options.

Install Ahrefs MCP Server

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

Upgrading versions

If you've installed our MCP server before, and just want to upgrade, run this command:

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

Configuration

You can now add the Ahrefs MCP to your favourite AI assistant app by adding the ahrefs part to your app's configuration file:

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

Specific for Windows OS

{
    "mcpServers": {
        "ahrefs": {
            "command": "npx",
            "args": [
                "--prefix=C:\\Users\\YOUR_USERNAME_HERE\\.global-node-modules\\node_modules",
                "@ahrefs/mcp"
            ],
            "env": {
                "API_KEY": "YOUR_API_KEY_HERE"
            }
        }
    }
}
  1. Take note of the double escape backslashes
  2. Take note that the prefix directory is slightly different
  3. Take note of the forward slash for @ahrefs/mcp
  4. If you are working with Claude Desktop, run Ctrl-Alt-Del to open Task Manager and kill Claude Desktop. Otherwise, your newly changed config will not be loaded.

To learn more about creating or controlling API keys, refer to the official documentation.

Where to find the configuration file

Claude Desktop

  1. Download Claude for Desktop
  2. Select Settings...

Open the Claude menu

  1. Click on Developer in the left panel, then Edit Config

Open the MCP config file

  1. Paste the configuration above into the open file

  2. Restart the Claude app! If the installation is successful, it should look like this:

ahrefs MCP appears under 'tools'

If you prefer directly navigating to the file, the paths are:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

If there are any issues, please refer to the official documentation

Cursor

Cursor supports configurations that are either project-specific or global: the MCP configuration file will be at .cursor/mcp.json or ~/.cursor/mcp.json respectively. For more details, read the official documentation.

Common Installation Issues & Fixes

1. Node.js or npm Not Installed / Recognized

Symptoms:

  • Running npm -v shows an error like command not found or 'npm' is not recognized.

Fix:

  • Ensure you've installed Node.js from nodejs.org.
  • Restart your terminal after installation.
  • On Windows, make sure the Node.js installer added npm to your PATH.

Platform-Specific Checks:

  • Windows: Open Command Prompt (Win + R → cmd) and run:
    node -v
    npm -v
    
  • macOS/Linux: Open Terminal and run:
    which node && which npm
    

If it returns nothing, Node.js may not be in your $PATH.


2. Permission Errors During Global Installation

Symptoms:

  • Errors like EACCES: permission denied, especially on macOS or Linux.

Fix:

  • Install using a user-scoped global prefix as shown in the installation guide:
    npm install --prefix=~/.global-node-modules @ahrefs/mcp -g
    
  • This avoids requiring elevated privileges (sudo).

Extra Tip: If you used sudo previously and created permission issues, reset folder ownership:

sudo chown -R $(whoami) ~/.global-node-modules

2a. macOS Terminal Permissions

Symptoms:

  • Terminal shows "Operation not permitted" errors
  • Unable to create folders or files
  • Permission denied messages when running npm commands

Fix: Check if Terminal has Full Disk Access:

  • Open System Settings (or System Preferences)
  • Go to Privacy & Security → Full Disk Access
  • Make sure Terminal.app is in the list and checked
  • If not present, click '+', navigate to Applications → Utilities → Terminal.app

Note: Modern macOS versions require explicit permissions for Terminal access. Without proper permissions, npm installations and other file operations may fail silently or with permission errors.


3. npx Cannot Find the Ahrefs MCP Command

Symptoms:

  • Error: Cannot find package '@ahrefs/mcp'

Fix: Ensure your config uses the same prefix used during install:

"command": "npx",
"args": [
  "--prefix=~/.global-node-modules",
  "@ahrefs/mcp"
]

Note: Do not omit the --prefix unless you're installing globally system-wide (not recommended).


4. Configuration File Not Detected

Symptoms:

  • Claude does not list the MCP under “tools”.

Fix:

  • Make sure the config file path is correct:
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: (Rare, but if applicable) ~/.config/Claude/claude_desktop_config.json
  • Double-check you pasted the configuration inside the correct section and restarted Claude after saving.

5. API Key Problems

Symptoms:

  • MCP fails silently or throws an error about API_KEY.
  • Claude responds with a message that it ran into authentication issues.

Fix: Ensure this line is present in the MCP config:

"env": {
  "API_KEY": "YOUR_API_KEY_HERE"
}

Replace YOUR_API_KEY_HERE with your actual key. Ensure that your API key settings give you the necessary permissions.

For more help, refer to Ahrefs API key docs.


6. Path Expansion Issues

Symptoms:

  • Error messages containing ENOENT or "no such file or directory"
  • npm commands fail with path-related errors
  • ~ or environment variables not being expanded correctly

Fix: Use absolute paths instead of relying on path expansion:

Windows:

C:\Users\<username>\.global-node-modules

Replace <username> with your actual Windows username.

macOS:

/Users/<username>/.global-node-modules

Replace <username> with your macOS username.

Linux:

/home/<username>/.global-node-modules

Replace <username> with your Linux username.

Example Configuration:

{
    "mcpServers": {
        "ahrefs": {
            "command": "npx",
            "args": [
                "--prefix=/Users/username/.global-node-modules",  // Replace with your absolute path
                "@ahrefs/mcp"
            ],
            "env": {
                "API_KEY": "YOUR_API_KEY_HERE"
            }
        }
    }
}

How to Find Your Absolute Path:

Windows:

  1. Open Command Prompt
  2. Type echo %USERPROFILE%

macOS/Linux:

  1. Open Terminal
  2. Type echo $HOME

Note: Using absolute paths eliminates issues with path expansion and ensures the configuration works regardless of environment variables or shell configurations.


🧪 Diagnostic Commands Per Platform

IssueWindows CommandmacOS/Linux Command
Check Node versionnode -v && npm -vnode -v && npm -v
Check if MCP is installednpm list -g --prefix=%USERPROFILE%\.global-node-modules @ahrefs/mcpnpm list -g --prefix=~/.global-node-modules @ahrefs/mcp
Clear corrupted installDelete folder manuallyrm -rf ~/.global-node-modules

📍 Summary of Key Paths

PurposeWindowsmacOSLinux
Claude config file%APPDATA%\Claude\claude_desktop_config.json~/Library/Application Support/Claude/claude_desktop_config.json~/.config/Claude/claude_desktop_config.json (if applicable)
Global MCP install location%USERPROFILE%\.global-node-modules~/.global-node-modules~/.global-node-modules

📘 Still Having Issues?

Let us know what errors you're seeing, along with your OS and the output of:

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

版本与发布记录

@ahrefs/mcp 共发布 12 个版本,首次发布于 2025/04/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.11latest2025/05/271.5 年前
0.0.102025/05/151.5 年前
0.0.92025/05/131.5 年前
0.0.82025/05/081.5 年前
0.0.72025/05/061.5 年前
0.0.62025/05/011.5 年前

关于 @ahrefs/mcp 的常见问题

@ahrefs/mcp 是什么?

Ahrefs MCP server

如何安装 @ahrefs/mcp?

在项目目录运行 npm install @ahrefs/mcp,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mcp,可以用 npx mcp 直接运行。

@ahrefs/mcp 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ahrefs__mcp 是否存在。

@ahrefs/mcp 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ahrefs/mcp 可以商用吗?

@ahrefs/mcp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ahrefs/mcp 的下载量有多少?

根据 npm 官方下载统计,@ahrefs/mcp 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,795 次,日均约 60 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ahrefs/mcp 还在维护吗?

最新版本 0.0.11 发布于 2025/05/27(1.5 年前);至今共发布 12 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/04/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。