Skip to main content
Glama

test_api_endpoint

Test API endpoints by sending HTTP requests with configurable methods, headers, and body to verify functionality and responses.

Instructions

Test an API endpoint with HTTP request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesAPI endpoint URL to test
methodNoHTTP methodGET
headersNoHTTP headers
bodyNoRequest body

Implementation Reference

  • Core handler implementation that performs the actual HTTP request to test the API endpoint using axios.
    async testAPIEndpoint( url: string, options?: { method?: string; headers?: Record<string, string>; body?: unknown } ): Promise<{ status: number; statusText: string; headers: Record<string, string>; body?: unknown; responseTime: number; }> { const axios = (await import('axios')).default; const startTime = Date.now(); try { const response = await axios({ url, method: (options?.method as any) || 'GET', headers: options?.headers, data: options?.body, validateStatus: () => true, }); return { status: response.status, statusText: response.statusText, headers: response.headers as Record<string, string>, body: response.data, responseTime: Date.now() - startTime, }; } catch (error) { throw new Error(`Failed to test endpoint: ${error instanceof Error ? error.message : String(error)}`); } }
  • Input schema definition for the test_api_endpoint tool, specifying parameters like url, method, headers, and body.
    inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'API endpoint URL to test', }, method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'], description: 'HTTP method', default: 'GET', }, headers: { type: 'object', description: 'HTTP headers', }, body: { type: 'object', description: 'Request body', }, }, required: ['url'], },
  • Tool registration in the apiDiscoveryTools array, including name, description, and input schema.
    { name: 'test_api_endpoint', description: 'Test an API endpoint with HTTP request', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'API endpoint URL to test', }, method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'], description: 'HTTP method', default: 'GET', }, headers: { type: 'object', description: 'HTTP headers', }, body: { type: 'object', description: 'Request body', }, }, required: ['url'], }, },
  • Dispatcher handler case in handleAPIDiscoveryTool that extracts parameters and delegates to APIScraper.testAPIEndpoint.
    case 'test_api_endpoint': { const url = params.url as string; const method = params.method as string; const headers = params.headers as Record<string, string>; const body = params.body as unknown; const result = await apiScraper.testAPIEndpoint(url, { method, headers, body }); return 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/code-alchemist01/development-tools-mcp-Server'

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