Skip to main content
Glama
urldna

urlDNA MCP Server

Official
by urldna

new_scan

Submit URLs for security scanning to detect threats and analyze malicious content using the urlDNA threat intelligence platform.

Instructions

Submit a URL to urlDNA and wait for the scan result.

Args: url (str): URL to submit for scanning. Returns: dict: Truncated scan result JSON. Raises: RuntimeError: If submission or polling fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • Executes the new_scan tool: authenticates with API key, POSTs URL to /scan endpoint, polls /scan/{id} every 2s up to 60s for 'DONE' status, truncates and returns result.
    def new_scan(url: str):
        """
        Submit a URL to urlDNA and wait for the scan result.
    
        Args:
            url (str): URL to submit for scanning.
        Returns:
            dict: Truncated scan result JSON.
        Raises:
            RuntimeError: If submission or polling fails.
        """
        # Get urlDNA API key 
        try:
            urlDNA_api_key = get_api_key()
        except Exception as e:
            raise RuntimeError(f"[new_scan] Failed to retrieve API key: {e}")
    
        headers = {
            "Authorization": urlDNA_api_key,
            "Content-Type": "application/json",
            "User-Agent": "urlDNA-MCP"
        }
    
        # Submit new scan
        try:
            response = requests.post(
                f"{config.urlDNA_API_URL}/scan",
                json={"submitted_url": url},
                headers=headers,
                timeout=10
            )
            response.raise_for_status()
        except requests.RequestException as e:
            raise RuntimeError(f"[new_scan] Scan submission failed: {e}")
    
        scan = response.json()
        scan_id = scan.get("id")
        if not scan_id:
            raise RuntimeError("[new_scan] No scan ID returned from submission.")
    
        # Polling for scan completion
        status = scan.get("scan", {}).get("status", "PENDING")
        scan_result = None
        retries = 0
        max_retries = 30
    
        while status not in {"DONE", "ERROR"} and retries < max_retries:
            time.sleep(2)
            retries += 1
            try:
                res = requests.get(
                    f"{config.urlDNA_API_URL}/scan/{scan_id}",
                    headers=headers,
                    timeout=10
                )
                res.raise_for_status()
                scan_result = res.json()
                status = scan_result.get("scan", {}).get("status", "UNKNOWN")
            except requests.RequestException as e:
                raise RuntimeError(f"[new_scan] Failed to fetch scan status: {e}")
    
        if status != "DONE":
            raise RuntimeError(f"[new_scan] Scan did not complete successfully (status: {status})")
    
        return truncate_scan_length(scan_result)
  • Input schema from type annotation and docstring: url (str); Output: dict (truncated scan JSON)
    def new_scan(url: str):
        """
        Submit a URL to urlDNA and wait for the scan result.
    
        Args:
            url (str): URL to submit for scanning.
        Returns:
            dict: Truncated scan result JSON.
        Raises:
            RuntimeError: If submission or polling fails.
        """
  • Registers new_scan tool in stdio transport server.
    register_new_scan(mcp)
  • Registers new_scan tool in SSE HTTP server.
    register_new_scan(mcp)
  • Supporting utility called by new_scan to truncate large scan JSON by dropping heavy fields (dom, http_transactions, page.text) to fit LLM context limits.
    def truncate_scan_length(scan_result):
        """
        Truncate scan result JSON if it exceeds max context length.
        Attributes are removed in the following order until the size is within limit:
        1. "dom"
        2. "http_transactions"
        3. "page.text"
        
        :param scan_result: dict - urlDNA Scan Result JSON
        :return: dict - truncated scan result
        """
        context_length = get_max_context_length()
    
        # Work on a copy to avoid mutating the original input
        truncated = dict(scan_result)
        
        # If context length not provided remove dom anyway
        if context_length <= 0:
            if "dom" in truncated:
                del truncated["dom"]
    
        # Helper to calculate JSON size in characters
        def json_length(obj):
            return len(json.dumps(obj, separators=(',', ':')))
    
        # If already under the limit, return as-is
        if json_length(truncated) <= context_length:
            return truncated
    
        # Truncate in the specified order
        drop_order = [
            ("dom",),
            ("http_transactions",),
            ("page", "text")
        ]
    
        for path in drop_order:
            obj = truncated
            *parents, last = path
    
            # Navigate to the parent
            for key in parents:
                obj = obj.get(key, {})
                if not isinstance(obj, dict):
                    break
            else:
                # Only attempt to remove if the key exists
                if last in obj:
                    obj.pop(last)
                    if json_length(truncated) <= context_length:
                        break
    
        return truncated
Behavior3/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 adds some context: it's a submission tool that waits for results and can raise RuntimeError on failure. However, it lacks details on permissions, rate limits, timeouts, or what 'truncated' means in the return value, leaving gaps for a mutation-like operation.

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 Args, Returns, and Raises sections are structured but slightly verbose for a single parameter; every sentence adds value, though it could be more streamlined.

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 complexity (submission with waiting, potential errors) and no annotations or output schema, the description is minimally adequate. It covers the basic operation and error handling but lacks details on output format beyond 'truncated scan result JSON,' which is vague, and doesn't address sibling tool relationships.

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

Parameters4/5

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

The description adds meaningful semantics beyond the input schema, which has 0% coverage. It explains that the 'url' parameter is 'URL to submit for scanning,' clarifying its purpose. Since there's only one parameter, the baseline is high, and this extra detail compensates well for the schema's lack of descriptions.

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: 'Submit a URL to urlDNA and wait for the scan result.' It specifies the action (submit and wait) and resource (URL to urlDNA). However, it doesn't explicitly differentiate from sibling tools like 'fast_check' or 'get_scan', which likely have related scanning functions.

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 like 'fast_check' or 'get_scan'. It mentions waiting for results, which implies this might be a synchronous or blocking operation, but doesn't clarify use cases, prerequisites, or exclusions compared to siblings.

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/urldna/mcp'

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