api_get
Make HTTP GET requests to external APIs through the MCP API Server, enabling AI assistants to retrieve data from specified URLs with optional headers.
Instructions
Make an HTTP GET request to the specified URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to make the GET request to | |
| headers | No | Optional headers to include in the request |
Implementation Reference
- src/tools.ts:10-31 (schema)Defines the MCPTool object for 'api_get' including name, description, and input schema.export const API_GET_TOOL: MCPTool = { name: 'api_get', description: 'Make an HTTP GET request to the specified URL', inputSchema: { type: 'object', properties: { url: { type: 'string', format: 'uri', description: 'The URL to make the GET request to', }, headers: { type: 'object', description: 'Optional headers to include in the request', additionalProperties: { type: 'string', }, }, }, required: ['url'], }, };
- src/tools.ts:128-133 (registration)Registers 'api_get' tool (via API_GET_TOOL) in the ALL_API_TOOLS array used by the MCP server's list_tools handler.export const ALL_API_TOOLS: MCPTool[] = [ API_GET_TOOL, API_POST_TOOL, API_PUT_TOOL, API_DELETE_TOOL, ];
- src/mcp-server.ts:85-90 (registration)Registers the list_tools MCP request handler that returns all tools including 'api_get'.this.server.setRequestHandler(ListToolsRequestSchema, async () => { this.log('Received list_tools request'); return { tools: ALL_API_TOOLS, }; });
- src/mcp-server.ts:199-227 (handler)Tool dispatch handler that routes 'api_get' calls to APIClient.get() method after validation.switch (toolName) { case 'api_get': return await this.apiClient.get(validatedRequest.url, validatedRequest.headers); case 'api_post': return await this.apiClient.post( validatedRequest.url, validatedRequest.body, validatedRequest.headers ); case 'api_put': return await this.apiClient.put( validatedRequest.url, validatedRequest.body, validatedRequest.headers ); case 'api_delete': return await this.apiClient.delete(validatedRequest.url, validatedRequest.headers); default: return { error: { type: 'validation' as const, message: `Unsupported tool: ${toolName}`, }, }; }
- src/api-client.ts:64-70 (handler)Executes the HTTP GET request using axios instance, implementing the core logic of the 'api_get' tool.async get(url: string, headers?: Record<string, string>): Promise<APIResponse | ErrorResponse> { return this.makeRequest({ url, method: 'GET', headers, }); }