Skip to main content
Glama
SlanyCukr

Bug Bounty MCP Server

by SlanyCukr

dirsearch_scan

Discover hidden directories and files on web servers using customizable wordlists and extensions to identify potential security vulnerabilities during penetration testing.

Instructions

Execute Dirsearch for advanced directory and file discovery with enhanced logging.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
additional_argsNo
extensionsNophp,html,js,txt,xml,json
recursiveNo
threadsNo
urlYes
wordlistNo/usr/share/wordlists/dirb/common.txt

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Primary MCP handler for the 'dirsearch_scan' tool. Proxies parameters to the REST API endpoint '/api/dirsearch' and handles logging and response.
    @mcp.tool()
    def dirsearch_scan(
        url: str,
        extensions: str = "php,html,js,txt,xml,json",
        wordlist: str = "/usr/share/wordlists/dirb/common.txt",
        threads: int = 30,
        recursive: bool = False,
        additional_args: str = "",
    ) -> dict[str, Any]:
        """Run Dirsearch for advanced directory and file discovery with logging."""
        data = {
            "url": url,
            "extensions": extensions,
            "wordlist": wordlist,
            "threads": threads,
            "recursive": recursive,
            "additional_args": additional_args,
        }
    
        logger.info(f"📁 Starting Dirsearch directory discovery on {url}")
        result = api_client.safe_post("api/dirsearch", data)
    
        if result.get("success"):
            logger.info(f"✅ Dirsearch scan completed on {url}")
        else:
            logger.error("❌ Dirsearch scan failed")
    
        return result
  • Input schema defined by function parameters with type hints and defaults for the dirsearch_scan tool.
    def dirsearch_scan(
        url: str,
        extensions: str = "php,html,js,txt,xml,json",
        wordlist: str = "/usr/share/wordlists/dirb/common.txt",
        threads: int = 30,
        recursive: bool = False,
        additional_args: str = "",
    ) -> dict[str, Any]:
  • Backend handler in REST API server that implements the dirsearch logic: parameter extraction, command building, execution, and result parsing.
    @tool(required_fields=["target"])
    def execute_dirsearch():
        """Execute Dirsearch for directory and file discovery."""
        data = request.get_json()
        params = extract_dirsearch_params(data)
    
        logger.info(f"Executing Dirsearch on {params['url']}")
    
        command = build_dirsearch_command(params)
        execution_result = execute_command(command, timeout=600)
    
        return parse_dirsearch_result(execution_result)
  • Helper function to construct the dirsearch command line from input parameters.
    def build_dirsearch_command(params: dict) -> str:
        """Build dirsearch command from parameters."""
        import shlex
    
        cmd_parts = ["dirsearch", "-u", params["url"]]
    
        if params["extensions"]:
            cmd_parts.extend(["-e", params["extensions"]])
    
        cmd_parts.extend(["-w", params["wordlist"]])
        cmd_parts.extend(["-t", str(params["threads"])])
        cmd_parts.extend(["--timeout", str(params["timeout"])])
    
        if params["recursive"]:
            cmd_parts.append("-r")
            if params["max_recursion_depth"] > 1:
                cmd_parts.append("--max-recursion-depth")
                cmd_parts.append(str(params["max_recursion_depth"]))
    
        if params["exclude_status"]:
            cmd_parts.extend(["--exclude-status", params["exclude_status"]])
    
        if params["rate_limit"]:
            rate_limit_value = params["rate_limit"]
            if isinstance(rate_limit_value, int | float) and rate_limit_value > 0:
                delay_ms = int(1000 / rate_limit_value)
                cmd_parts.extend(["--delay", str(delay_ms)])
    
        cmd_parts.extend(["--format", "json", "-o", "/tmp/dirsearch_out.json"])
    
        if params["additional_args"]:
            cmd_parts.extend(params["additional_args"].split())
    
        return " ".join(shlex.quote(part) for part in cmd_parts)
  • Helper function to parse the execution result, read JSON output, extract unique findings, and compute statistics.
    def parse_dirsearch_result(execution_result: dict) -> dict[str, Any]:
        """Parse dirsearch execution result and format response with findings."""
        if not execution_result["success"]:
            return {"findings": [], "stats": create_stats(0, 0, 0), "version": None}
    
        stdout = execution_result.get("stdout", "")
        with open("/tmp/dirsearch_raw_output.log", "w") as f:
            f.write(stdout)
        json_file_path = "/tmp/dirsearch_out.json"
        findings = []
        if execution_result["success"]:
            try:
                with open(json_file_path) as f:
                    file_content = f.read().strip()
                findings = parse_dirsearch_json_output(file_content)
                os.remove(json_file_path)
            except FileNotFoundError:
                logger.warning("Dirsearch JSON output file not found.")
            except json.JSONDecodeError:
                logger.warning("Failed to parse dirsearch JSON file")
            except Exception as e:
                logger.warning(f"Error reading dirsearch JSON file: {e}")
    
        seen_urls = set()
        unique_findings = []
        dupes_count = 0
    
        for finding in findings:
            url = finding["evidence"]["url"]
            if url not in seen_urls:
                seen_urls.add(url)
                unique_findings.append(finding)
            else:
                dupes_count += 1
    
        payload_bytes = len(stdout.encode("utf-8"))
        truncated = len(findings) > 100
    
        stats = create_stats(len(unique_findings), dupes_count, payload_bytes)
        stats["truncated"] = truncated
    
        return {
            "findings": unique_findings,
            "stats": stats,
        }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions 'enhanced logging' but does not disclose critical behavioral traits such as whether it's read-only or destructive, rate limits, authentication needs, or output format. For a tool with 6 parameters and no annotations, 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 a single, efficient sentence with no wasted words. It is appropriately sized and front-loaded, stating the core action clearly, though it could be slightly more informative without losing conciseness.

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 the complexity (6 parameters, 0% schema coverage, no annotations) and the presence of an output schema, the description is incomplete. It fails to explain parameters, behavioral traits, or usage context, making it inadequate for an agent to effectively use this tool despite the output schema.

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

Parameters2/5

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

Schema description coverage is 0%, so the schema provides no parameter details. The description does not explain any parameters, their meanings, or how they affect the scan (e.g., what 'extensions' or 'wordlist' do). With 6 parameters, this leaves the agent guessing about their semantics.

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

Purpose3/5

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

The description states the tool 'Execute[s] Dirsearch for advanced directory and file discovery with enhanced logging,' which clarifies it performs directory/file discovery using Dirsearch. However, it lacks specificity about what makes it 'advanced' or distinguishes it from similar sibling tools like dirb_scan, feroxbuster_scan, or gobuster_scan, making the purpose somewhat vague.

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. With multiple sibling tools for directory/file discovery (e.g., dirb_scan, feroxbuster_scan, gobuster_scan), there is no indication of scenarios, prerequisites, or trade-offs, leaving the agent without usage context.

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/SlanyCukr/bugbounty-mcp-server'

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