Skip to main content
Glama

playwright_post

Send an HTTP POST request with specified data, URL, and headers using Playwright. This tool enables browser automation for tasks like submitting forms or interacting with APIs in a web environment.

Instructions

Perform an HTTP POST request

Input Schema

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

Implementation Reference

  • The PostRequestTool class provides the core handler logic for executing the 'playwright_post' tool. It performs an HTTP POST request using Playwright's API request context, handles JSON validation, sets headers including optional bearer token, retrieves the response, and formats the output.
    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 ? '...' : ''}`
          ]);
        });
      }
    }
  • The input schema definition for the 'playwright_post' tool, specifying parameters like url, value (body), 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"],
      },
    },
  • Instantiation of the PostRequestTool instance in the initializeTools function, which creates the handler object used for execution.
    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);
  • Dispatch/registration in the main handleToolCall switch statement, routing 'playwright_post' calls to the postRequestTool.execute method.
    case "playwright_post":
      return await postRequestTool.execute(args, context);
  • The API_TOOLS array categorizes 'playwright_post' as an API tool, which influences browser launching logic (no browser needed). Also listed in src/toolHandler.ts import and other places.
    export const API_TOOLS = [
      "playwright_get",
      "playwright_post",
      "playwright_put",
      "playwright_delete",
      "playwright_patch"
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Perform an HTTP POST request' indicates a write operation but doesn't cover important aspects like authentication requirements (though hinted in schema), rate limits, error handling, or what the response might contain. 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 a single, efficient sentence with zero waste—'Perform an HTTP POST request' is perfectly concise and front-loaded. Every word earns its place, making it easy to parse quickly.

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 this is a mutation tool (POST implies writing) with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns, error conditions, or behavioral nuances. The schema covers parameters well, but overall context for safe and effective use is lacking.

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%, so the schema already documents all four parameters (url, value, headers, token) with clear descriptions. The description adds no additional parameter semantics beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

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 verb ('perform') and resource ('HTTP POST request'), making the purpose immediately understandable. However, it doesn't distinguish this from sibling tools like playwright_patch, playwright_put, or playwright_delete, which are also HTTP methods, so it lacks sibling differentiation.

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 in the sibling list (POST, PATCH, PUT, DELETE, GET), there's no indication of when POST is appropriate versus other methods, nor any context about prerequisites or constraints.

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

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

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