playwright_put
Execute HTTP PUT requests to send data to specified URLs, enabling direct updates or modifications to web resources in a real browser environment.
Instructions
Perform an HTTP PUT request
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to perform PUT operation | |
| value | Yes | Data to PUT in the body |
Input Schema (JSON Schema)
{
"properties": {
"url": {
"description": "URL to perform PUT operation",
"type": "string"
},
"value": {
"description": "Data to PUT in the body",
"type": "string"
}
},
"required": [
"url",
"value"
],
"type": "object"
}
Implementation Reference
- src/tools/api/requests.ts:78-112 (handler)The PutRequestTool class and its execute method implement the core logic for the 'playwright_put' tool, performing an HTTP PUT request using Playwright's APIRequestContext.put(), handling JSON validation, and returning status and response details.export class PutRequestTool extends ApiToolBase { /** * Execute the PUT request tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { return this.safeExecute(context, async (apiContext) => { // Check if the value is valid JSON if it starts with { or [ if (args.value && typeof args.value === 'string' && (args.value.startsWith('{') || args.value.startsWith('['))) { try { JSON.parse(args.value); } catch (error) { return createErrorResponse(`Failed to parse request body: ${(error as Error).message}`); } } const response = await apiContext.put(args.url, { data: args.value }); let responseText; try { responseText = await response.text(); } catch (error) { responseText = "Unable to get response text"; } return createSuccessResponse([ `PUT request to ${args.url}`, `Status: ${response.status()} ${response.statusText()}`, `Response: ${responseText.substring(0, 1000)}${responseText.length > 1000 ? '...' : ''}` ]); }); } }
- src/tools.ts:247-258 (schema)Tool schema definition for 'playwright_put', including name, description, and input schema requiring 'url' and 'value' parameters.{ name: "playwright_put", description: "Perform an HTTP PUT request", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to perform PUT operation" }, value: { type: "string", description: "Data to PUT in the body" }, }, required: ["url", "value"], }, },
- src/toolHandler.ts:508-509 (registration)Registration and dispatch in the main tool handler switch statement, routing 'playwright_put' calls to the PutRequestTool.execute method.case "playwright_put": return await putRequestTool.execute(args, context);
- src/toolHandler.ts:306-306 (registration)Instantiation of the PutRequestTool instance in the initializeTools function.if (!putRequestTool) putRequestTool = new PutRequestTool(server);
- src/tools.ts:431-432 (registration)Inclusion of 'playwright_put' in the API_TOOLS array for conditional API context initialization."playwright_put", "playwright_delete",