Skip to main content
Glama
seayniclabs

Keel

by seayniclabs

traceroute

Trace the network path to any host, showing each hop and latency. Diagnose connectivity issues by identifying routing problems.

Instructions

Trace the network route to a host.

Wraps the system traceroute command and parses output.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYes
max_hopsNo

Implementation Reference

  • The main handler function for the traceroute tool. It validates input via validate_host, enforces max_hops 1-64, spawns the system 'traceroute' subprocess, parses the output into structured hop data, and returns a dict with host, max_hops, hops list, and raw output.
    @mcp.tool()
    async def traceroute(host: str, max_hops: int = 30) -> dict:
        """Trace the network route to a host.
    
        Wraps the system ``traceroute`` command and parses output.
        """
        host = validate_host(host)
        if max_hops < 1 or max_hops > 64:
            raise ValueError("max_hops must be between 1 and 64")
    
        try:
            proc = await asyncio.create_subprocess_exec(
                "traceroute", "-m", str(max_hops), "-w", "3", host,
                stdout=asyncio.subprocess.PIPE,
                stderr=asyncio.subprocess.PIPE,
            )
            stdout, stderr = await asyncio.wait_for(proc.communicate(), timeout=120)
        except FileNotFoundError:
            return {"error": "traceroute command not found — install it on the host system"}
        except asyncio.TimeoutError:
            return {"error": "traceroute timed out"}
    
        lines = stdout.decode(errors="replace").strip().splitlines()
        hops: list[dict] = []
        for line in lines[1:]:  # skip header
            parts = line.split()
            if len(parts) >= 2:
                hops.append({"hop": parts[0], "detail": " ".join(parts[1:])})
    
        return {
            "host": host,
            "max_hops": max_hops,
            "hops": hops,
            "raw": stdout.decode(errors="replace"),
        }
  • The tool is registered with MCP using the @mcp.tool() decorator on the traceroute async function.
    @mcp.tool()
  • The validate_host helper is used by traceroute to sanitize the host input. The docstring notes that allow_internal defaults to True since tools like traceroute legitimately target internal networks.
    def validate_host(host: str, *, allow_internal: bool = True) -> str:
        """Validate a hostname or IP address.
    
        Args:
            host: The hostname or IP to validate.
            allow_internal: If False, reject internal/private/loopback IPs and
                hostnames that resolve to them (SSRF protection). Defaults to
                True since tools like ping and traceroute legitimately target
                internal networks.
    
        Returns the cleaned host string.
        Raises ``ValueError`` on anything suspicious.
        """
        host = host.strip()
        if not host:
            raise ValueError("Host must not be empty")
    
        if _SHELL_META.search(host):
            raise ValueError(f"Host contains forbidden characters: {host!r}")
    
        # Accept valid IP addresses directly.
        try:
            addr = ipaddress.ip_address(host)
            if not allow_internal and is_internal_ip(host):
                raise ValueError(
                    f"Host {host} is an internal/private/loopback address — "
                    "requests to internal addresses are blocked"
                )
            return host
        except ValueError as exc:
            # Re-raise if it's our own SSRF block, not an ip_address parse error
            if "internal" in str(exc):
                raise
            pass
    
        if not _HOSTNAME_RE.match(host):
            raise ValueError(f"Invalid hostname: {host!r}")
    
        # If internal not allowed, resolve and check the IP
        if not allow_internal:
            _resolve_and_check(host)
    
        return host
Behavior2/5

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

Despite no annotations, the description only states it wraps the system traceroute command and parses output. Missing details on system dependencies, permissions, timeout behavior, or output structure.

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

Conciseness5/5

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

Two short, clear sentences with no wasted words. Front-loaded with the core purpose.

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

Completeness2/5

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

Given no annotations, no output schema, and minimal description, the tool lacks important context about return values, error states, and behavior of max_hops. Incomplete for a network tool.

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

Parameters1/5

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

The description provides no information about the parameters 'host' or 'max_hops'. With 0% schema description coverage, the agent gets no help understanding what values to provide.

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

Purpose5/5

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

The description clearly states the tool's action ('Trace the network route to a host'), using a specific verb and resource, and is well-distinguished from sibling tools like ping, dns_lookup, etc.

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?

No guidance on when to use this tool versus alternatives such as ping or port_check. The description does not mention context or conditions for usage.

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/seayniclabs/sounding'

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