api_post
Send HTTP POST requests to external APIs through the MCP API Server to transmit data or trigger actions at specified endpoints.
Instructions
Make an HTTP POST request to the specified URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to make the POST request to | |
| body | No | The request body (string or JSON object) | |
| headers | No | Optional headers to include in the request |
Implementation Reference
- src/tools.ts:36-64 (schema)Defines the MCPTool schema for the 'api_post' tool, including input validation for URL, optional body, and headers.export const API_POST_TOOL: MCPTool = { name: 'api_post', description: 'Make an HTTP POST request to the specified URL', inputSchema: { type: 'object', properties: { url: { type: 'string', format: 'uri', description: 'The URL to make the POST request to', }, body: { oneOf: [ { type: 'string' }, { type: 'object' }, ], description: 'The request body (string or JSON object)', }, headers: { type: 'object', description: 'Optional headers to include in the request', additionalProperties: { type: 'string', }, }, }, required: ['url'], }, };
- src/tools.ts:138-143 (registration)Registers the 'api_post' tool in TOOL_MAP for quick lookup during tool validation and dispatching in the MCP server.export const TOOL_MAP: Record<string, MCPTool> = { [API_GET_TOOL.name]: API_GET_TOOL, [API_POST_TOOL.name]: API_POST_TOOL, [API_PUT_TOOL.name]: API_PUT_TOOL, [API_DELETE_TOOL.name]: API_DELETE_TOOL, };
- src/mcp-server.ts:203-208 (handler)The handler logic for the 'api_post' tool call, which invokes APIClient.post to perform the HTTP POST request.case 'api_post': return await this.apiClient.post( validatedRequest.url, validatedRequest.body, validatedRequest.headers );
- src/api-client.ts:72-84 (helper)The APIClient.post method that executes the actual HTTP POST request using axios, handling body serialization and error management./** * Makes a POST request */ async post( url: string, body?: string | object, headers?: Record<string, string> ): Promise<APIResponse | ErrorResponse> { return this.makeRequest({ url, method: 'POST', body, headers,
- src/mcp-server.ts:84-90 (registration)Registers the MCP list_tools handler that exposes ALL_API_TOOLS (including 'api_post') to clients.// Register list tools handler this.server.setRequestHandler(ListToolsRequestSchema, async () => { this.log('Received list_tools request'); return { tools: ALL_API_TOOLS, }; });