Skip to main content
Glama
cnych

Backlinks MCP

by cnych

get_traffic

Check estimated search traffic for any website by domain or URL, with options for country-specific data and query modes.

Instructions

Check the estimated search traffic for any website. 

Args:
    domain_or_url (str): The domain or URL to query
    country (str): The country to query, default is "None"
    mode (["subdomains", "exact"]): The mode to use for the query
Returns:
    Traffic data for the specified domain or URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domain_or_urlYes
countryNoNone
modeNosubdomains

Implementation Reference

  • The get_traffic tool handler, registered via @mcp.tool() decorator. Handles captcha token acquisition and delegates to check_traffic for core logic.
    @mcp.tool()
    def get_traffic(domain_or_url: str, country: str = "None", mode: Literal["subdomains", "exact"] = "subdomains") -> Optional[Dict[str, Any]]:
        """
        Check the estimated search traffic for any website. 
    
        Args:
            domain_or_url (str): The domain or URL to query
            country (str): The country to query, default is "None"
            mode (["subdomains", "exact"]): The mode to use for the query
        Returns:
            Traffic data for the specified domain or URL
        """
        site_url = f"https://ahrefs.com/traffic-checker/?input={domain_or_url}&mode={mode}"
        token = get_capsolver_token(site_url)
        if not token:
            raise Exception(f"Failed to get verification token for domain: {domain_or_url}")
        return check_traffic(token, domain_or_url, mode, country)
  • Core helper function implementing the traffic check by making authenticated request to Ahrefs API and parsing the response.
    def check_traffic(token: str, domain_or_url: str, mode: Literal["subdomains", "exact"] = "subdomains", country: str = "None") -> Optional[Dict[str, Any]]:
        """
        Check the estimated search traffic for any website.
        
        Args:
            domain_or_url (str): The domain or URL to query
            token (str): Verification token
            mode (str): Query mode, default is "subdomains"
            country (str): Country, default is "None"
        
        Returns:
            Optional[Dict[str, Any]]: Dictionary containing traffic data, returns None if request fails
        """
        if not token:
            return None
        
        url = "https://ahrefs.com/v4/stGetFreeTrafficOverview"
        
        # 将参数转换为JSON字符串,然后作为单个input参数传递
        params = {
            "input": json.dumps({
                "captcha": token,
                "country": country,
                "protocol": "None",
                "mode": mode,
                "url": domain_or_url
            })
        }
        
        headers = {
            "accept": "*/*",
            "content-type": "application/json",
            "referer": f"https://ahrefs.com/traffic-checker/?input={domain_or_url}&mode={mode}"
        }
    
        try:
            response = requests.get(url, params=params, headers=headers)
            if response.status_code != 200:
                return None
            
            data: Optional[List[Any]] = response.json()
    
            # 检查响应数据格式
            if not isinstance(data, list) or len(data) < 2 or data[0] != "Ok":
                return None
            
            # 提取有效数据
            traffic_data = data[1]
            
            # 格式化返回结果
            result = {
                "traffic_history": traffic_data.get("traffic_history", []),
                "traffic": {
                    "trafficMonthlyAvg": traffic_data.get("traffic", {}).get("trafficMonthlyAvg", 0),
                    "costMontlyAvg": traffic_data.get("traffic", {}).get("costMontlyAvg", 0)
                },
                "top_pages": traffic_data.get("top_pages", []),
                "top_countries": traffic_data.get("top_countries", []),
                "top_keywords": traffic_data.get("top_keywords", [])
            }
            
            return result
        except Exception as e:
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool checks 'estimated search traffic,' implying a read-only operation, but fails to detail critical aspects like rate limits, authentication needs, data sources, accuracy, or response format. For a tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the core purpose stated first. The structured 'Args' and 'Returns' sections enhance clarity without unnecessary verbosity. However, minor improvements could make it more efficient, such as integrating parameter details more seamlessly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is partially complete. It covers the basic purpose and parameters but lacks details on behavioral traits, usage context, and output specifics. Without annotations or output schema, more comprehensive guidance would improve completeness for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description includes an 'Args' section that lists parameters (domain_or_url, country, mode) and a 'Returns' note, adding meaning beyond the input schema, which has 0% description coverage. However, it doesn't fully compensate for the schema gap—e.g., it doesn't explain what 'subdomains' vs. 'exact' mode entails or provide examples for the country parameter. The baseline is 3 due to some added value but incomplete coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Check the estimated search traffic for any website.' It specifies the verb ('Check') and resource ('search traffic for any website'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like get_backlinks_list or keyword_difficulty, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It lacks context about scenarios where this tool is appropriate, prerequisites, or comparisons with sibling tools like get_backlinks_list or keyword_generator. This omission leaves the agent without usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cnych/backlinks-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server