Skip to main content
Glama
code-alchemist01

Development Tools MCP Server

discover_api_endpoints

Monitor network requests on web pages to identify and document API endpoints for development analysis and integration.

Instructions

Discover API endpoints by monitoring network requests on a web page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to analyze
timeoutNoAnalysis timeout in milliseconds

Implementation Reference

  • Core handler function that implements the logic for discovering API endpoints by launching a headless browser, navigating to the URL, monitoring network requests and responses, filtering API-like requests, extracting endpoints with parameters, and detecting authentication methods.
    async discoverAPIEndpoints(url: string, options?: { timeout?: number }): Promise<APIDiscoveryResult> {
      if (!Validators.isValidUrl(url)) {
        throw new Error('Invalid URL');
      }
    
      const browser = await this.getBrowser();
      const page = await browser.newPage();
      const endpoints: APIEndpoint[] = [];
      const requests: NetworkRequest[] = [];
    
      try {
        // Monitor network requests
        page.on('request', (request) => {
          const requestUrl = request.url();
          const method = request.method();
          
          // Filter for API-like requests (JSON, XML, or common API patterns)
          if (
            requestUrl.includes('/api/') ||
            requestUrl.endsWith('.json') ||
            requestUrl.includes('?') ||
            method !== 'GET'
          ) {
            requests.push({
              url: requestUrl,
              method,
              status: 0,
              statusText: '',
              headers: request.headers(),
              requestHeaders: request.headers(),
            });
          }
        });
    
        page.on('response', (response) => {
          const responseUrl = response.url();
          const request = requests.find((r) => r.url === responseUrl);
          if (request) {
            request.status = response.status();
            request.statusText = response.statusText();
            request.type = response.headers()['content-type'] || '';
          }
        });
    
        // Navigate to page
        await page.goto(url, {
          waitUntil: 'networkidle',
          timeout: options?.timeout || 30000,
        });
    
        // Wait a bit for all requests to complete
        await page.waitForTimeout(2000);
    
        // Process requests into endpoints
        for (const request of requests) {
          try {
            const urlObj = new URL(request.url);
            const method = request.method as APIEndpoint['method'];
    
            // Extract parameters from URL
            const parameters: APIEndpoint['parameters'] = [];
            urlObj.searchParams.forEach((_value, key) => {
              parameters.push({
                name: key,
                type: 'string',
                required: false,
                location: 'query',
              });
            });
    
            endpoints.push({
              method,
              path: urlObj.pathname,
              fullUrl: request.url,
              parameters: parameters.length > 0 ? parameters : undefined,
              statusCode: request.status,
              headers: request.headers,
            });
          } catch {
            // Skip invalid URLs
          }
        }
    
        // Detect authentication
        const authInfo = this.detectAuthentication(requests);
    
        return {
          endpoints: [...new Map(endpoints.map((e) => [e.fullUrl, e])).values()], // Remove duplicates
          baseUrl: new URL(url).origin,
          authentication: authInfo,
        };
      } finally {
        await page.close();
      }
    }
  • Tool registration entry in apiDiscoveryTools array defining the name, description, and input schema for the discover_api_endpoints tool.
    {
      name: 'discover_api_endpoints',
      description: 'Discover API endpoints by monitoring network requests on a web page',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'URL to analyze',
          },
          timeout: {
            type: 'number',
            description: 'Analysis timeout in milliseconds',
            default: 30000,
          },
        },
        required: ['url'],
      },
    },
  • Input schema definition for the discover_api_endpoints tool, specifying parameters url (required string) and optional timeout (number).
    inputSchema: {
      type: 'object',
      properties: {
        url: {
          type: 'string',
          description: 'URL to analyze',
        },
        timeout: {
          type: 'number',
          description: 'Analysis timeout in milliseconds',
          default: 30000,
        },
      },
      required: ['url'],
    },
  • Wrapper handler in handleAPIDiscoveryTool that extracts parameters, calls the core APIScraper.discoverAPIEndpoints, formats the result, and returns it.
    case 'discover_api_endpoints': {
      const url = params.url as string;
      const timeout = params.timeout as number;
      const result = await apiScraper.discoverAPIEndpoints(url, { timeout });
      return Formatters.formatAPIDiscoveryResults(result);
    }
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 of behavioral disclosure. It mentions monitoring network requests but doesn't specify behavioral traits such as whether it requires specific permissions, how it handles dynamic content, what the output format is, or any rate limits. This is a significant gap for a tool with no annotation coverage.

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?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. Every word earns its place, making it highly concise and well-structured for quick understanding.

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 of discovering API endpoints (which may involve dynamic interactions) and the lack of annotations and output schema, the description is incomplete. It doesn't address key aspects like output format, error handling, or integration with sibling tools, leaving gaps 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 input schema has 100% description coverage, so the schema already documents both parameters ('url' and 'timeout'). The description doesn't add any meaning beyond what the schema provides, such as explaining the context of the URL or timeout usage. Baseline 3 is appropriate when schema does the heavy lifting.

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: 'Discover API endpoints by monitoring network requests on a web page.' It specifies the verb ('discover') and resource ('API endpoints') with the method ('monitoring network requests'). However, it doesn't explicitly differentiate from sibling tools like 'analyze_network_requests' or 'extract_api_schema,' which reduces clarity in context.

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 siblings like 'analyze_network_requests' and 'extract_api_schema' available, it lacks explicit when-to-use, when-not-to-use, or prerequisite information, leaving the agent to infer usage from the purpose alone.

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/code-alchemist01/development-tools-mcp-Server'

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