Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_patch

Execute an HTTP PATCH request to update specific parts of a web resource. Provide a URL and data to modify, enabling browser automation and web interaction within the Playwright MCP Server environment.

Instructions

Perform an HTTP PATCH request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to perform PUT operation
valueYesData to PATCH in the body

Implementation Reference

  • The execute method of PatchRequestTool class implements the core logic for the 'playwright_patch' tool. It performs an HTTP PATCH request using the Playwright API context, optionally validates JSON in the request body, retrieves the response text, and formats a success response with status and truncated body.
    export class PatchRequestTool extends ApiToolBase { /** * Execute the PATCH 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.patch(args.url, { data: args.value }); let responseText; try { responseText = await response.text(); } catch (error) { responseText = "Unable to get response text"; } return createSuccessResponse([ `PATCH request to ${args.url}`, `Status: ${response.status()} ${response.statusText()}`, `Response: ${responseText.substring(0, 1000)}${responseText.length > 1000 ? '...' : ''}` ]); }); } }
  • Defines the input schema and metadata for the 'playwright_patch' tool in the createToolDefinitions array.
    name: "playwright_patch", description: "Perform an HTTP PATCH request", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to perform PUT operation" }, value: { type: "string", description: "Data to PATCH in the body" }, }, required: ["url", "value"], }, },
  • In the main handleToolCall switch statement, dispatches 'playwright_patch' calls to the patchRequestTool.execute method.
    case "playwright_patch": return await patchRequestTool.execute(args, context);
  • Instantiates the PatchRequestTool instance during tool initialization in the initializeTools function.
    if (!patchRequestTool) patchRequestTool = new PatchRequestTool(server);
  • src/tools.ts:4-295 (registration)
    The createToolDefinitions function returns the array of all tool definitions including 'playwright_patch', which is used for MCP tool registration.
    export function createToolDefinitions() { return [ // Codegen tools { name: "start_codegen_session", description: "Start a new code generation session to record Playwright actions", inputSchema: { type: "object", properties: { options: { type: "object", description: "Code generation options", properties: { outputPath: { type: "string", description: "Directory path where generated tests will be saved (use absolute path)" }, testNamePrefix: { type: "string", description: "Prefix to use for generated test names (default: 'GeneratedTest')" }, includeComments: { type: "boolean", description: "Whether to include descriptive comments in generated tests" } }, required: ["outputPath"] } }, required: ["options"] } }, { name: "end_codegen_session", description: "End a code generation session and generate the test file", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the session to end" } }, required: ["sessionId"] } }, { name: "get_codegen_session", description: "Get information about a code generation session", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the session to retrieve" } }, required: ["sessionId"] } }, { name: "clear_codegen_session", description: "Clear a code generation session without generating a test", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the session to clear" } }, required: ["sessionId"] } }, { name: "playwright_navigate", description: "Navigate to a URL", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to navigate to the website specified" }, browserType: { type: "string", description: "Browser type to use (chromium, firefox, webkit). Defaults to chromium", enum: ["chromium", "firefox", "webkit"] }, width: { type: "number", description: "Viewport width in pixels (default: 1280)" }, height: { type: "number", description: "Viewport height in pixels (default: 720)" }, timeout: { type: "number", description: "Navigation timeout in milliseconds" }, waitUntil: { type: "string", description: "Navigation wait condition" }, headless: { type: "boolean", description: "Run browser in headless mode (default: false)" } }, required: ["url"], }, }, { name: "playwright_screenshot", description: "Take a screenshot of the current page or a specific element", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name for the screenshot" }, selector: { type: "string", description: "CSS selector for element to screenshot" }, width: { type: "number", description: "Width in pixels (default: 800)" }, height: { type: "number", description: "Height in pixels (default: 600)" }, storeBase64: { type: "boolean", description: "Store screenshot in base64 format (default: true)" }, fullPage: { type: "boolean", description: "Store screenshot of the entire page (default: false)" }, savePng: { type: "boolean", description: "Save screenshot as PNG file (default: false)" }, downloadsDir: { type: "string", description: "Custom downloads directory path (default: user's Downloads folder)" }, }, required: ["name"], }, }, { name: "playwright_click", description: "Click an element on the page", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for the element to click" }, }, required: ["selector"], }, }, { name: "playwright_iframe_click", description: "Click an element in an iframe on the page", inputSchema: { type: "object", properties: { iframeSelector: { type: "string", description: "CSS selector for the iframe containing the element to click" }, selector: { type: "string", description: "CSS selector for the element to click" }, }, required: ["iframeSelector", "selector"], }, }, { name: "playwright_iframe_fill", description: "Fill an element in an iframe on the page", inputSchema: { type: "object", properties: { iframeSelector: { type: "string", description: "CSS selector for the iframe containing the element to fill" }, selector: { type: "string", description: "CSS selector for the element to fill" }, value: { type: "string", description: "Value to fill" }, }, required: ["iframeSelector", "selector", "value"], }, }, { name: "playwright_fill", description: "fill out an input field", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for input field" }, value: { type: "string", description: "Value to fill" }, }, required: ["selector", "value"], }, }, { name: "playwright_select", description: "Select an element on the page with Select tag", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to select" }, value: { type: "string", description: "Value to select" }, }, required: ["selector", "value"], }, }, { name: "playwright_hover", description: "Hover an element on the page", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to hover" }, }, required: ["selector"], }, }, { name: "playwright_upload_file", description: "Upload a file to an input[type='file'] element on the page", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for the file input element" }, filePath: { type: "string", description: "Absolute path to the file to upload" } }, required: ["selector", "filePath"], }, }, { name: "playwright_evaluate", description: "Execute JavaScript in the browser console", inputSchema: { type: "object", properties: { script: { type: "string", description: "JavaScript code to execute" }, }, required: ["script"], }, }, { name: "playwright_console_logs", description: "Retrieve console logs from the browser with filtering options", inputSchema: { type: "object", properties: { type: { type: "string", description: "Type of logs to retrieve (all, error, warning, log, info, debug, exception)", enum: ["all", "error", "warning", "log", "info", "debug", "exception"] }, search: { type: "string", description: "Text to search for in logs (handles text with square brackets)" }, limit: { type: "number", description: "Maximum number of logs to return" }, clear: { type: "boolean", description: "Whether to clear logs after retrieval (default: false)" } }, required: [], }, }, { name: "playwright_close", description: "Close the browser and release all resources", inputSchema: { type: "object", properties: {}, required: [], }, }, { name: "playwright_get", description: "Perform an HTTP GET request", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to perform GET operation" } }, required: ["url"], }, }, { 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" }, token: { type: "string", description: "Bearer token for authorization" }, headers: { type: "object", description: "Additional headers to include in the request", additionalProperties: { type: "string" } } }, required: ["url", "value"], }, }, { 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"], }, }, { name: "playwright_patch", description: "Perform an HTTP PATCH request", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to perform PUT operation" }, value: { type: "string", description: "Data to PATCH in the body" }, }, required: ["url", "value"], }, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/devskido/customed-playwright'

If you have feedback or need assistance with the MCP directory API, please join our Discord server