Backlinks (Ahrefs)

by cnych

5 stars
1.8k downloads
Not rated
GitHub

About

Retrieves detailed backlink data from Ahrefs including anchor text, domain rating, and URL information for SEO analysis and link building strategies.

Details

Author
cnych
Repository
cnych/seo-mcp
GitHub stars
5
Downloads
1,835
License
MIT License
Categories
AI, Design, File Management, Search, Infrastructure, Knowledge Base, Frontend
Tags
#web

- πŸ” Backlink Analysis

- Get detailed backlink data for any domain
- View domain rating, anchor text, and link attributes
- Filter educational and government domains

- 🎯 Keyword Research

- Generate keyword ideas from a seed keyword
- Get keyword difficulty score
- View search volume and trends

- πŸ“Š Traffic Analysis

- Estimate website traffic
- View traffic history and trends
- Analyze popular pages and country distribution
- Track keyword rankings

- πŸš€ Performance Optimization

- Use CapSolver to automatically solve CAPTCHA
- Response caching

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Backlinks (Ahrefs)
    Command (node, npx, python, etc.) uvx
    Arguments
    • Argument 1 --python
    • Argument 2 3.10
    • Argument 3 seo-mcp
    Environment
    • CAPSOLVER_API_KEY CAP-xxxxxx

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

pip install seo-mcp

Or use uv:

uv pip install seo-mcp

1. Clone the repository:

   git clone https://github.com/cnych/seo-mcp.git
   cd seo-mcp
   

2. Install dependencies:

```bash
pip install -e .

get_backlinks_list

Get the backlinks of a domain. Parameters: domain (string): The domain to analyze (e.g. 'example.com')

keyword_generator

Generate keyword ideas. Parameters: keyword (string): The seed keyword, country (string): Country code (default: 'us'), search_engine (string): Search engine (default: 'Google')

get_traffic

Get the traffic estimation. Parameters: domain_or_url (string): The domain or URL to analyze, country (string): Country filter (default: 'None'), mode (string): Analysis mode ('subdomains' or 'exact')

keyword_difficulty

Get the keyword difficulty score. Parameters: keyword (string): The keyword to analyze, country (string): Country code (default: 'us')

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "backlinks (ahrefs)": {
            "env": {
                "CAPSOLVER_API_KEY": "CAP-xxxxxx"
            },
            "args": [
                "--python",
                "3.10",
                "seo-mcp"
            ],
            "command": "uvx"
        }
    }
}

Linux

{
    "env": {
        "CAPSOLVER_API_KEY": "CAP-xxxxxx"
    },
    "args": [
        "--python",
        "3.10",
        "seo-mcp"
    ],
    "command": "uvx"
}

Macos

{
    "env": {
        "CAPSOLVER_API_KEY": "CAP-xxxxxx"
    },
    "args": [
        "--python",
        "3.10",
        "seo-mcp"
    ],
    "command": "uvx"
}

Windows

{
    "env": {
        "CAPSOLVER_API_KEY": "CAP-xxxxxx"
    },
    "args": [
        "--python",
        "3.10",
        "seo-mcp"
    ],
    "command": "uvx"
}

SEO MCP

A MCP (Model Control Protocol) SEO tool service based on Ahrefs data. Includes features such as backlink analysis, keyword research, traffic estimation, and more.

δΈ­ζ–‡

Overview

This service provides an API to retrieve SEO data from Ahrefs. It handles the entire process, including solving the CAPTCHA, authentication, and data retrieval. The results are cached to improve performance and reduce API costs.

> This MCP service is for educational purposes only. Please do not misuse it. This project is inspired by @ε“₯飞瀾羀.

Features

- πŸ” Backlink Analysis

- Get detailed backlink data for any domain
- View domain rating, anchor text, and link attributes
- Filter educational and government domains

- 🎯 Keyword Research

- Generate keyword ideas from a seed keyword
- Get keyword difficulty score
- View search volume and trends

- πŸ“Š Traffic Analysis

- Estimate website traffic
- View traffic history and trends
- Analyze popular pages and country distribution
- Track keyword rankings

- πŸš€ Performance Optimization

- Use CapSolver to automatically solve CAPTCHA
- Response caching

Installation

Prerequisites

- Python 3.10 or higher
- CapSolver account and API key (register here)

Install from PyPI

pip install seo-mcp

Or use uv:

uv pip install seo-mcp

Manual Installation

1. Clone the repository:

   git clone https://github.com/cnych/seo-mcp.git
   cd seo-mcp
   

2. Install dependencies:

   pip install -e .
   # Or
   uv pip install -e .
   

3. Set the CapSolver API key:

   export CAPSOLVER_API_KEY="your-capsolver-api-key"
   

Usage

Run the service

You can run the service in the following ways:

Use in Cursor IDE

In the Cursor settings, switch to the MCP tab, click the +Add new global MCP server button, and then input:

{
  "mcpServers": {
    "SEO MCP": {
      "command": "uvx",
      "args": ["--python", "3.10", "seo-mcp"],
      "env": {
        "CAPSOLVER_API_KEY": "CAP-xxxxxx"
      }
    }
  }
}

You can also create a .cursor/mcp.json file in the project root directory, with the same content.

API Reference

The service provides the following MCP tools:

get_backlinks_list(domain: str)

Get the backlinks of a domain.

Parameters:

- domain (string): The domain to analyze (e.g. "example.com")

Returns:

{
  "overview": {
    "domainRating": 76,
    "backlinks": 1500,
    "refDomains": 300
  },
  "backlinks": [
    {
      "anchor": "Example link",
      "domainRating": 76,
      "title": "Page title",
      "urlFrom": "https://referringsite.com/page",
      "urlTo": "https://example.com/page",
      "edu": false,
      "gov": false
    }
  ]
}

keyword_generator(keyword: str, country: str = "us", search_engine: str = "Google")

Generate keyword ideas.

Parameters:

- keyword (string): The seed keyword
- country (string): Country code (default: "us")
- search_engine (string): Search engine (default: "Google")

Returns:

[
  {
    "keyword": "Example keyword",
    "volume": 1000,
    "difficulty": 45,
    "cpc": 2.5
  }
]

get_traffic(domain_or_url: str, country: str = "None", mode: str = "subdomains")

Get the traffic estimation.

Parameters:

- domain_or_url (string): The domain or URL to analyze
- country (string): Country filter (default: "None")
- mode (string): Analysis mode ("subdomains" or "exact")

Returns:

{
  "traffic_history": [...],
  "traffic": {
    "trafficMonthlyAvg": 50000,
    "costMontlyAvg": 25000
  },
  "top_pages": [...],
  "top_countries": [...],
  "top_keywords": [...]
}

keyword_difficulty(keyword: str, country: str = "us")

Get the keyword difficulty score.

Parameters:

- keyword (string): The keyword to analyze
- country (string): Country code (default: "us")

Returns:

{
  "difficulty": 45,
  "serp": [...],
  "related": [...]
}

Development

For development:

git clone https://github.com/cnych/seo-mcp.git
cd seo-mcp
uv sync

How it works

1. The user sends a request through MCP
2. The service uses CapSolver to solve the Cloudflare Turnstile CAPTCHA
3. The service gets the authentication token from Ahrefs
4. The service retrieves the requested SEO data
5. The service processes and returns the formatted results

Troubleshooting

- CapSolver API key error:Check the CAPSOLVER_API_KEY environment variable
- Rate limiting:Reduce request frequency
- No results:The domain may not be indexed by Ahrefs
- Other issues:See GitHub repository

License

MIT License - See LICENSE file

No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.