Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_post

Send HTTP POST requests with data payloads and headers using Playwright's browser automation capabilities for web interactions and testing.

Instructions

Perform an HTTP POST request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to perform POST operation
valueYesData to post in the body
tokenNoBearer token for authorization
headersNoAdditional headers to include in the request

Implementation Reference

  • The PostRequestTool class containing the execute method that implements the core logic for performing HTTP POST requests using Playwright's APIRequestContext.
    export class PostRequestTool extends ApiToolBase {
      /**
       * Execute the POST 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.post(args.url, {
            data: typeof args.value === 'string' ? JSON.parse(args.value) : args.value,
            headers: {
              'Content-Type': 'application/json',
              ...(args.token ? { 'Authorization': `Bearer ${args.token}` } : {}),
              ...(args.headers || {})
            }
          });
          
          let responseText;
          try {
            responseText = await response.text();
          } catch (error) {
            responseText = "Unable to get response text";
          }
          
          return createSuccessResponse([
            `POST request to ${args.url}`,
            `Status: ${response.status()} ${response.statusText()}`,
            `Response: ${responseText.substring(0, 1000)}${responseText.length > 1000 ? '...' : ''}`
          ]);
        });
      }
    }
  • Input schema definition for the playwright_post tool, specifying parameters like url, value, token, and headers.
    {
      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"],
      },
    },
  • Switch statement in handleToolCall function that registers and dispatches the playwright_post tool call to postRequestTool.execute.
    // API tools
    case "playwright_get":
      return await getRequestTool.execute(args, context);
      
    case "playwright_post":
      return await postRequestTool.execute(args, context);
      
    case "playwright_put":
      return await putRequestTool.execute(args, context);
      
    case "playwright_patch":
      return await patchRequestTool.execute(args, context);
      
    case "playwright_delete":
      return await deleteRequestTool.execute(args, context);
  • src/tools.ts:476-482 (registration)
    API_TOOLS array listing playwright_post among API tools used for conditional context setup.
    export const API_TOOLS = [
      "playwright_get",
      "playwright_post",
      "playwright_put",
      "playwright_delete",
      "playwright_patch"
    ];
  • Re-export of API_TOOLS including playwright_post for tool categorization.
    export const API_TOOLS = [
      "playwright_get",
      "playwright_post",

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Perform an HTTP POST request' indicates a write operation but doesn't disclose authentication requirements (though the token parameter hints at this), rate limits, error handling, timeout behavior, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is maximally concise - a single clear phrase that communicates the core functionality without any wasted words. It's front-loaded with the essential information and earns its place efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what the tool returns, error conditions, authentication requirements, or how it integrates with the broader playwright automation context. Given the complexity of HTTP operations and the rich sibling tool ecosystem, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, all parameters are well-documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema descriptions. The baseline score of 3 is appropriate when the schema does the heavy lifting for parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Perform an HTTP POST request' clearly states the action (POST) and resource type (HTTP request), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling POST-related tools like playwright_patch or playwright_put, which also perform HTTP operations with different methods.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple HTTP method tools available (POST, PATCH, PUT, DELETE, GET), there's no indication of when POST is appropriate versus other methods or how this tool relates to other playwright tools for browser automation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.