make_http_request
Execute HTTP requests (GET, POST, PUT, DELETE) with custom headers and body using curl, enabling integration with Puppeteer MCP Server for web automation tasks.
Instructions
Make an HTTP request with curl
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | Body to include in the request | |
| headers | Yes | Headers to include in the request | |
| type | Yes | Type of the request. GET, POST, PUT, DELETE | |
| url | Yes | Url to make the request to |
Implementation Reference
- index.ts:216-227 (handler)The switch case handler for the 'make_http_request' tool, which delegates to the makeRequest utility function.case "make_http_request": { const response = await makeRequest( args.url, args.type, args.headers, args.body ); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }], isError: false, }; }
- index.ts:43-68 (schema)Input schema definition for the make_http_request tool, defining parameters like type, url, headers, body.{ name: "make_http_request", description: "Make an HTTP request with curl", inputSchema: { type: "object", properties: { type: { type: "string", description: "Type of the request. GET, POST, PUT, DELETE", }, url: { type: "string", description: "Url to make the request to", }, headers: { type: "object", description: "Headers to include in the request", }, body: { type: "object", description: "Body to include in the request", }, }, required: ["type", "url", "headers", "body"], }, },
- index.ts:278-280 (registration)Registration of the tools list (TOOLS array including make_http_request) for ListToolsRequestSchema.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS, }));
- utilities.ts:4-33 (helper)The makeRequest helper function that implements the core HTTP request logic using fetch.export async function makeRequest( url: string, type: string, headers: Record<string, string>, body: any ) { try { const response = await fetch(url, { method: type, headers, body: body && (type === "POST" || type === "PUT") ? JSON.stringify(body) : undefined, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return { status: response.status, data: await response.text(), headers: Object.fromEntries(response.headers), }; } catch (error) { console.error("Error making request:", error); throw error; } }