playwright_post
Execute HTTP POST requests with specified URL and body data to automate browser tasks via the MCP Browser Automation Server, facilitating efficient data submission and interaction.
Instructions
Perform an HTTP POST request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to perform POST operation | |
| value | Yes | Data to post in the body |
Implementation Reference
- src/toolsHandler.ts:354-391 (handler)The switch case implementing the logic for the 'playwright_post' tool. It performs an HTTP POST request to the specified URL with the provided data (args.value) as JSON, using Playwright's APIRequestContext. Returns the response JSON and status code.case "playwright_post": try { var data = { data: args.value, headers: { 'Content-Type': 'application/json' } }; var response = await apiContext!.post(args.url, data); return { toolResult: { content: [{ type: "text", text: `Performed POST Operation ${args.url} with data ${JSON.stringify(args.value, null, 2)}`, }, { type: "text", text: `Response: ${JSON.stringify(await response.json(), null, 2)}`, }, { type: "text", text: `Response code ${response.status()}` }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Failed to perform POST operation on ${args.url}: ${(error as Error).message}`, }], isError: true, }, }; }
- src/tools.ts:101-112 (schema)The tool definition object for 'playwright_post', providing the name, description, and input schema (url and value as required strings).{ name: "playwright_post", description: "Perform an HTTP POST request", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to perform POST operation" }, value: { type: "string", description: "Data to post in the body" }, }, required: ["url", "value"], }, },
- src/tools.ts:164-170 (helper)API_TOOLS constant array listing 'playwright_post' among API request tools, used in toolsHandler.ts to conditionally set up APIRequestContext without launching a browser.export const API_TOOLS = [ "playwright_get", "playwright_post", "playwright_put", "playwright_delete", "playwright_patch" ];
- src/index.ts:22-26 (registration)Registration of all tools including 'playwright_post' via createToolDefinitions() and passing to setupRequestHandlers on the MCP server.// Create tool definitions const TOOLS = createToolDefinitions(); // Setup request handlers setupRequestHandlers(server, TOOLS);