Skip to main content
Glama

api_patch

Execute a PATCH request to update data at an API endpoint. Specify the URL, JSON payload, and headers to modify resources efficiently via the Browser Agent MCP server.

Instructions

Perform a PATCH request to an API endpoint

Input Schema

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

Implementation Reference

  • The core handler function that performs the PATCH HTTP request using Playwright's APIRequestContext, processes the response, and returns the tool result.
    async function handleApiPatch(client: APIRequestContext, args: any): Promise<{ toolResult: CallToolResult }> {
      try {
        const options = {
          data: args.data,
          headers: args.headers || { 'Content-Type': 'application/json' }
        };
    
        const response = await client.patch(args.url, options);
        const responseData = await getResponseData(response);
    
        return {
          toolResult: {
            content: [
              {
                type: "text",
                text: `PATCH ${args.url} - Status: ${response.status()}`,
              },
              ...responseData
            ],
            isError: false,
          },
        };
      } catch (error) {
        return {
          toolResult: {
            content: [{
              type: "text",
              text: `PATCH request failed: ${(error as Error).message}`,
            }],
            isError: true,
          },
        };
      }
    }
  • src/tools.ts:182-197 (registration)
    The tool registration object defining the name, description, and input schema for 'api_patch', returned by registerTools().
      name: "api_patch",
      description: "Perform a PATCH 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"]
      }
    },
  • Input schema defining the parameters for the 'api_patch' tool: url (required), data (required), and optional headers.
    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"]
    }
  • Switch case in executeToolCall that routes 'api_patch' calls to the handleApiPatch function.
    case "api_patch":
      return await handleApiPatch(apiClient!, args);
  • src/tools.ts:14-20 (registration)
    Array listing 'api_patch' among API tools, used to determine if API client initialization is needed.
    export const API_TOOLS = [
      "api_get",
      "api_post",
      "api_put",
      "api_patch",
      "api_delete"
    ];
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/imprvhub/mcp-browser-agent'

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