playwright_post
Send HTTP POST requests to submit data to web endpoints through browser automation, enabling form submissions and API interactions via Playwright with Chrome DevTools Protocol.
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:344-377 (handler)The handler logic within handleToolCall that executes the playwright_post tool by sending a POST request using Playwright's APIRequestContext.case "playwright_post": try { var data = { data: args.value, headers: { 'Content-Type': 'application/json' } }; var response = await apiContext!.post(args.url, data); return { 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 { content: [{ type: "text", text: `Failed to perform POST operation on ${args.url}: ${(error as Error).message}`, }], isError: true, }; }
- src/tools.ts:105-116 (schema)Tool definition object containing name, description, and inputSchema for the playwright_post tool.{ 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:167-173 (helper)API_TOOLS constant array that includes 'playwright_post', used in toolsHandler.ts to determine if API context is needed without launching a browser.export const API_TOOLS = [ "playwright_get", "playwright_post", "playwright_put", "playwright_delete", "playwright_patch" ];
- src/index.ts:22-26 (registration)Where the tool definitions are created and passed to setupRequestHandlers for MCP server registration.// Create tool definitions const TOOLS = createToolDefinitions(); // Setup request handlers setupRequestHandlers(server, TOOLS);
- src/requestHandler.ts:65-67 (registration)Registration of the general tool call handler that dispatches to specific tool handlers including playwright_post.server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );