Skip to main content
Glama

api_post

Execute POST API requests by providing endpoint URL, JSON body, and optional headers. Integrates with browser automation for data submission and API testing.

Instructions

Perform a POST request to an API endpoint

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesAPI endpoint URL
dataYesRequest body data (JSON string)
headersNoRequest headers

Implementation Reference

  • The actual handler function that executes the api_post tool logic. It sends a POST request using Playwright's APIRequestContext, passing the data and headers from the arguments, and returns the response status and body.
    async function handleApiPost(client: APIRequestContext, args: any): Promise<{ toolResult: CallToolResult }> {
      try {
        const options = {
          data: args.data,
          headers: args.headers || { 'Content-Type': 'application/json' }
        };
    
        const response = await client.post(args.url, options);
        const responseData = await getResponseData(response);
    
        return {
          toolResult: {
            content: [
              {
                type: "text",
                text: `POST ${args.url} - Status: ${response.status()}`,
              },
              ...responseData
            ],
            isError: false,
          },
        };
      } catch (error) {
        return {
          toolResult: {
            content: [{
              type: "text",
              text: `POST request failed: ${(error as Error).message}`,
            }],
            isError: true,
          },
        };
      }
    }
  • The schema registration for api_post. It defines the tool name, description, and input schema requiring 'url' (string) and 'data' (string - JSON body), with optional 'headers' (object).
    {
      name: "api_post",
      description: "Perform a POST request to an API endpoint",
      inputSchema: {
        type: "object",
        properties: {
          url: { type: "string", description: "API endpoint URL" },
          data: { type: "string", description: "Request body data (JSON string)" },
          headers: { 
            type: "object", 
            description: "Request headers",
            additionalProperties: { type: "string" }
          }
        },
        required: ["url", "data"]
      }
    },
  • The dispatch case in executeToolCall that routes the 'api_post' tool name to the handleApiPost handler function.
    case "api_post":
      return await handleApiPost(apiClient!, args);
  • src/tools.ts:14-20 (registration)
    The API_TOOLS list that declares 'api_post' as one of the available API tools.
    export const API_TOOLS = [
      "api_get",
      "api_post",
      "api_put",
      "api_patch",
      "api_delete"
    ];
  • Helper function getResponseData used by handleApiPost to parse and format the HTTP response body based on content type.
    async function getResponseData(response: any): Promise<TextContent[]> {
      const contentType = response.headers()['content-type'] || '';
      let responseText: string;
      if (contentType.includes('application/json')) {
        try {
          const json = await response.json();
          responseText = JSON.stringify(json, null, 2);
        } catch (e) {
          responseText = await response.text();
        }
      } else {
        responseText = await response.text();
      }
      return [{
        type: "text",
        text: `Response body:\n${responseText}`,
      } as TextContent];
    }
Behavior2/5

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

No annotations provided, so description must disclose behavior. It fails to mention typical POST behavior (resource creation), data validation, or error handling.

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

Conciseness3/5

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

Single sentence is concise and front-loaded, but it is too brief and lacks substance for a practical tool description.

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 simple HTTP tool, description should mention typical use (e.g., 'sends data to URL'). Schema covers parameters but context is missing.

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 coverage is 100% (all parameters described), so baseline is 3. Description adds no additional meaning beyond the schema.

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

Purpose5/5

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

Description states 'POST request' verb and 'API endpoint' resource, clearly distinguishing from sibling tools like api_get, api_put, etc.

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?

No guidance on when to use this tool versus alternatives, no mention of prerequisites or context such as authentication or data format.

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/imprvhub/mcp-browser-agent'

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