Skip to main content
Glama

playwright_post

Send HTTP POST requests with data payloads and authorization headers for browser automation tasks using the MCP Playwright server.

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

  • PostRequestTool class with execute method implementing the HTTP POST request logic using Playwright's request context, handling JSON parsing, headers including auth token, and response formatting.
    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: string;
          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, defining required url and value, optional 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"],
      },
    },
  • Dispatch in handleToolCall switch statement that calls the postRequestTool handler for 'playwright_post'.
    case "playwright_post":
      return await postRequestTool.execute(args, context);
  • Instantiation of PostRequestTool instance in initializeTools function.
    if (!postRequestTool) postRequestTool = new PostRequestTool(server);
  • Example of ApiToolBase extension (GetRequestTool), showing the base class provides safeExecute for API tools.
    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: string;
          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 ? "..." : ""}`,
          ]);
        });
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose error handling, timeout behavior, response format (e.g., JSON, HTML), rate limits, or side effects. 'Perform an HTTP POST request' is minimal and doesn't add context beyond the basic action, leaving the agent to infer behavior from the tool name alone.

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 a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse. Every word earns its place by directly stating the tool's function without redundancy or unnecessary elaboration.

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?

Given no annotations, no output schema, and a tool that performs HTTP operations (which can have complex behaviors like authentication, errors, and response formats), the description is incomplete. It doesn't address what the tool returns, error conditions, or environmental needs (e.g., network connectivity), leaving significant gaps for an AI agent to use it effectively.

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?

Schema description coverage is 100%, with clear parameter descriptions in the schema (e.g., 'URL to perform POST operation', 'Data to post in the body'). The description adds no additional meaning beyond what the schema provides, such as examples or constraints. Baseline 3 is appropriate since the schema adequately documents parameters.

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. It distinguishes from siblings like playwright_get (GET) and playwright_put (PUT) by specifying the HTTP method, though it doesn't explicitly mention what distinguishes it from playwright_patch or playwright_delete beyond the method.

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. It doesn't mention typical POST use cases (e.g., creating resources, submitting forms), prerequisites like authentication, or comparisons to siblings like playwright_put for updates or playwright_patch for partial updates. Usage is implied only by the HTTP method name.

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

Install Server

Other Tools

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/aakashH242/mcp-playwright'

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