Skip to main content
Glama
ElonJask

ProxyPin MCP Server

by ElonJask

analyze_api

Analyze API structure for a domain to understand endpoints, methods, and parameters from captured HTTP traffic.

Instructions

Analyze API structure for a domain.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes

Implementation Reference

  • The analyze_api function is a decorated tool that aggregates request information for a given domain, normalizes URL paths to identify API endpoints, and generates a structured summary of the API, including counts, authentication, and request/response structures.
    def analyze_api(domain: str) -> str:
        """Analyze API structure for a domain."""
        normalized_domain = domain.strip()
        if not normalized_domain:
            return _json_response({"error": "domain is required"})
    
        requests = reader.get_requests(
            limit=300,
            detail_level=DetailLevel.KEY,
            domain=normalized_domain,
        )
    
        endpoints: dict[str, dict[str, Any]] = {}
        for req in requests:
            path = req.path or "/"
            normalized = re.sub(r"/\d+", "/{id}", path)
            normalized = re.sub(r"/[a-f0-9-]{32,}", "/{uuid}", normalized, flags=re.IGNORECASE)
    
            key = f"{req.method} {normalized}"
            endpoint = endpoints.setdefault(
                key,
                {
                    "method": req.method,
                    "path": normalized,
                    "count": 0,
                    "statuses": set(),
                    "has_auth": False,
                    "request_structure": None,
                    "response_structure": None,
                    "sample_url": req.url,
                },
            )
            endpoint["count"] += 1
            if req.status is not None:
                endpoint["statuses"].add(req.status)
            if req.has_auth:
                endpoint["has_auth"] = True
            if req.request_body_structure and not endpoint["request_structure"]:
                endpoint["request_structure"] = req.request_body_structure
            if req.response_body_structure and not endpoint["response_structure"]:
                endpoint["response_structure"] = req.response_body_structure
    
        endpoints_list: list[dict[str, Any]] = []
        result: dict[str, Any] = {
            "domain": normalized_domain,
            "total_requests": len(requests),
            "endpoints_count": len(endpoints),
            "endpoints": endpoints_list,
        }
        for _, endpoint in sorted(endpoints.items(), key=lambda item: -item[1]["count"]):
            endpoints_list.append(
                {
                    "method": endpoint["method"],
                    "path": endpoint["path"],
                    "count": endpoint["count"],
                    "statuses": sorted(endpoint["statuses"]),
                    "has_auth": endpoint["has_auth"],
                    "request_structure": endpoint["request_structure"],
                    "response_structure": endpoint["response_structure"],
                    "sample_url": endpoint["sample_url"],
                }
            )
        return _json_response(result)

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/ElonJask/proxypin-mcp'

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