post_data
Send HTTP POST requests to a specified URL with custom data payloads using a tool on the Violett MCP Server to efficiently transmit information between systems.
Instructions
Send data via HTTP POST request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Data to send in POST body | |
| url | Yes | URL to send POST request to |
Implementation Reference
- The handler for the 'post_data' tool. It extracts URL and data from arguments, performs an HTTP POST request using fetch with JSON body, and returns the response status, headers, and body as text content. Handles errors by returning an error message.case "post_data": { const url = request.params.arguments?.url as string; const data = request.params.arguments?.data; if (!url || !data) { throw new Error("URL and data are required"); } try { const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(data), }); const responseText = await response.text(); const headers = Object.fromEntries(response.headers.entries()); return { content: [ { type: "text", text: `HTTP ${response.status} ${response.statusText}\n\nHeaders:\n${JSON.stringify(headers, null, 2)}\n\nResponse:\n${responseText}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error posting data: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- src/examples/single-node-server.ts:43-60 (registration)The tool descriptor for 'post_data' registered in the ListToolsRequestHandler, including name, description, and input schema definition.{ name: "post_data", description: "Send data via HTTP POST request", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to send POST request to", }, data: { type: "object", description: "Data to send in POST body", }, }, required: ["url", "data"], }, },
- The input schema for the 'post_data' tool, defining required 'url' (string) and 'data' (object) properties.inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to send POST request to", }, data: { type: "object", description: "Data to send in POST body", }, }, required: ["url", "data"], },