playwright_get
Execute an HTTP GET request to retrieve web content using the Playwright MCP Server, enabling browser automation and interaction with web pages.
Instructions
Perform an HTTP GET request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to perform GET operation |
Implementation Reference
- src/tools/api/requests.ts:7-29 (handler)The execute method of GetRequestTool performs the HTTP GET request using Playwright's APIRequestContext, retrieves the response text, and formats a success response with status and truncated body.export class GetRequestTool extends ApiToolBase { /** * Execute the GET request tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { return this.safeExecute(context, async (apiContext) => { const response = await apiContext.get(args.url); let responseText; try { responseText = await response.text(); } catch (error) { responseText = "Unable to get response text"; } return createSuccessResponse([ `GET request to ${args.url}`, `Status: ${response.status()} ${response.statusText()}`, `Response: ${responseText.substring(0, 1000)}${responseText.length > 1000 ? '...' : ''}` ]); }); } }
- src/tools.ts:243-253 (schema)Input schema definition for the 'playwright_get' tool, specifying the required 'url' parameter.{ name: "playwright_get", description: "Perform an HTTP GET request", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to perform GET operation" } }, required: ["url"], }, },
- src/toolHandler.ts:524-525 (registration)Registration and dispatch of 'playwright_get' tool call to the GetRequestTool's execute method in the main handleToolCall switch statement.case "playwright_get": return await getRequestTool.execute(args, context);
- src/toolHandler.ts:336-340 (registration)Instantiation of GetRequestTool instance during tool initialization.if (!getRequestTool) getRequestTool = new GetRequestTool(server); if (!postRequestTool) postRequestTool = new PostRequestTool(server); if (!putRequestTool) putRequestTool = new PutRequestTool(server); if (!patchRequestTool) patchRequestTool = new PatchRequestTool(server); if (!deleteRequestTool) deleteRequestTool = new DeleteRequestTool(server);
- src/tools/api/base.ts:50-62 (helper)The safeExecute method in ApiToolBase (superclass of GetRequestTool) handles API context validation and error wrapping for the GET request execution.protected async safeExecute( context: ToolContext, operation: (apiContext: APIRequestContext) => Promise<ToolResponse> ): Promise<ToolResponse> { const apiError = this.validateApiContextAvailable(context); if (apiError) return apiError; try { return await operation(context.apiContext!); } catch (error) { return createErrorResponse(`API operation failed: ${(error as Error).message}`); } }