Skip to main content
Glama

api_put

Send data updates to an API endpoint using the PUT method. Specify the URL, JSON data, and headers to modify server-side resources efficiently.

Instructions

Perform a PUT request to an API endpoint

Input Schema

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

Implementation Reference

  • The handler function that implements the core logic of the 'api_put' tool by performing a PUT request using the API client.
    async function handleApiPut(client: APIRequestContext, args: any): Promise<{ toolResult: CallToolResult }> {
      try {
        const options = {
          data: args.data,
          headers: args.headers || { 'Content-Type': 'application/json' }
        };
    
        const response = await client.put(args.url, options);
        const responseData = await getResponseData(response);
    
        return {
          toolResult: {
            content: [
              {
                type: "text",
                text: `PUT ${args.url} - Status: ${response.status()}`,
              },
              ...responseData
            ],
            isError: false,
          },
        };
      } catch (error) {
        return {
          toolResult: {
            content: [{
              type: "text",
              text: `PUT request failed: ${(error as Error).message}`,
            }],
            isError: true,
          },
        };
      }
  • The tool schema definition including name, description, and input validation schema for 'api_put'.
    {
      name: "api_put",
      description: "Perform a PUT 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/registration case in the main executeTool function that maps the 'api_put' tool name to its handler.
    case "api_put":
      return await handleApiPut(apiClient!, args);
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