Skip to main content
Glama
gyuco
by gyuco

http_request

Configure and send HTTP requests to REST APIs, specifying method, path, parameters, body, and headers for flexible API interaction.

Instructions

Make an HTTP request to the configured API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodYesHTTP method
pathYesAPI endpoint path
paramsNoQuery parameters (for GET) or request body parameters
bodyNoRequest body (for POST, PUT, PATCH)
headersNoAdditional headers

Implementation Reference

  • The handler function for the http_request tool. It validates that the REST client is configured, extracts method/path/params/body/headers from args, delegates to RestClient.makeRequest(), and formats the response.
    private async makeHttpRequest(args: any) {
      if (!this.restClient) {
        throw new Error(
          "REST client not configured. Use configure_rest_client tool or provide configuration via CLI/environment variables."
        );
      }
    
      const { method, path, params, body, headers } = args;
      const response = await this.restClient.makeRequest({
        method,
        path,
        params,
        body,
        headers,
      });
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                status: response.status,
                statusText: response.statusText,
                data: response.data,
                headers: response.headers,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • The actual HTTP request execution logic in RestClient.makeRequest(). Uses axios to make GET/POST/PUT/DELETE/PATCH requests, handles error formatting, and returns ApiResponse.
    async makeRequest<T = any>(options: RequestOptions): Promise<ApiResponse<T>> {
      const { method, path, params, body, headers } = options;
    
      try {
        let response: AxiosResponse<T>;
        const config = {
          headers: headers || {},
          params: method === "GET" ? params : undefined,
        };
    
        switch (method) {
          case "GET":
            response = await this.httpClient.get(path, config);
            break;
          case "POST":
            response = await this.httpClient.post(path, body || params, config);
            break;
          case "PUT":
            response = await this.httpClient.put(path, body || params, config);
            break;
          case "DELETE":
            response = await this.httpClient.delete(path, config);
            break;
          case "PATCH":
            response = await this.httpClient.patch(path, body || params, config);
            break;
          default:
            throw new Error(`Unsupported HTTP method: ${method}`);
        }
    
        return {
          data: response.data,
          status: response.status,
          statusText: response.statusText,
          headers: response.headers as Record<string, string>,
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new Error(
            `HTTP ${error.response?.status || "Unknown"}: ${
              error.response?.data?.message || error.message
            }`
          );
        }
        throw error;
      }
    }
  • Schema definition and registration of the http_request tool. Defines its name, description, and inputSchema (method enum, path string, optional params, body, headers). Required fields: method and path.
      name: "http_request",
      description: "Make an HTTP request to the configured API",
      inputSchema: {
        type: "object",
        properties: {
          method: {
            type: "string",
            enum: ["GET", "POST", "PUT", "DELETE", "PATCH"],
            description: "HTTP method",
          },
          path: {
            type: "string",
            description: "API endpoint path",
          },
          params: {
            type: "object",
            description:
              "Query parameters (for GET) or request body parameters",
          },
          body: {
            type: "object",
            description: "Request body (for POST, PUT, PATCH)",
          },
          headers: {
            type: "object",
            description: "Additional headers",
          },
        },
        required: ["method", "path"],
      },
    },
  • The RequestOptions interface that defines the type signature for the HTTP request parameters used by the handler.
    // Request options
    export interface RequestOptions {
      method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
      path: string;
      params?: Record<string, any>;
      body?: any;
      headers?: Record<string, string>;
    }
  • src/index.ts:220-262 (registration)
    The tool routing/dispatch in CallToolRequestSchema handler. The 'http_request' case (line 228-229) routes execution to makeHttpRequest().
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        switch (name) {
          case "configure_rest_client":
            return await this.configureRestClient(args);
    
          case "http_request":
            return await this.makeHttpRequest(args);
    
          case "get_swagger_documentation":
            return await this.getSwaggerDocumentation();
    
          case "search_endpoints":
            return await this.searchEndpoints(args);
    
          case "get_endpoint_info":
            return await this.getEndpointInfo(args);
    
          case "check_authentication":
            return await this.checkAuthentication();
    
          case "logout":
            return await this.logout();
    
          default:
            throw new Error(`Unknown tool: ${name}`);
        }
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error: ${
                error instanceof Error ? error.message : "Unknown error"
              }`,
            },
          ],
          isError: true,
        };
      }
    });
Behavior2/5

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

No annotations provided; description does not mention side effects, idempotency, authentication needs, rate limits, or error behavior. For a generic HTTP tool, 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.

Conciseness4/5

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

Description is one short sentence with no wasted words. Could include slightly more detail but remains concise.

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?

Tool has 5 params, includes nested objects, and no output schema. Description does not explain return format, error handling, or usage patterns, leaving the agent underinformed.

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%; each parameter has a clear description. Description adds no additional meaning beyond the schema, so baseline of 3 is appropriate.

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 verb, resource, and context: 'Make an HTTP request to the configured API'. Clearly distinguishes from sibling tools like check_authentication or configure_rest_client.

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 vs alternatives (e.g., search_endpoints, get_swagger_documentation). Missing when-not-to-use or prerequisite conditions.

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/gyuco/mcp-http-client'

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