Skip to main content
Glama
DeanWard

HAL (HTTP API Layer)

HTTP HEAD Request

http-head

Send an HTTP HEAD request to retrieve headers from a specified URL, optionally including custom headers. Supports secure secret substitution using environment variables for sensitive data.

Instructions

Make an HTTP HEAD request to a specified URL with optional headers (returns only headers, no body). Supports secret substitution using {secrets.key} syntax in URL and headers where 'key' corresponds to HAL_SECRET_KEY environment variables.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
headersNo
urlYes

Implementation Reference

  • src/index.ts:664-677 (registration)
    Registration of the 'http-head' MCP tool, including input schema (url: string url, optional headers object) and handler that delegates to shared makeHttpRequest('HEAD', ...).
    server.registerTool(
      "http-head",
      {
        title: "HTTP HEAD Request",
        description: "Make an HTTP HEAD request to a specified URL with optional headers (returns only headers, no body). Supports secret substitution using {secrets.key} syntax in URL and headers where 'key' corresponds to HAL_SECRET_KEY environment variables.",
        inputSchema: {
          url: z.string().url(),
          headers: z.record(z.string()).optional()
        }
      },
      async ({ url, headers = {} }: { url: string; headers?: Record<string, string> }) => {
        return makeHttpRequest('HEAD', url, { headers });
      }
    );
  • Input schema for 'http-head' tool: requires a valid URL, optional headers as string record.
    inputSchema: {
      url: z.string().url(),
      headers: z.record(z.string()).optional()
    }
  • Core handler function implementing all HTTP tool logic, called by 'http-head' with method='HEAD'. Handles secret substitution, URL allowlisting/blacklisting, fetch request, special HEAD response (headers only, no body), secret redaction in output.
    async function makeHttpRequest(
      method: string,
      url: string,
      options: {
        headers?: Record<string, string>;
        body?: string;
        queryParams?: Record<string, any>;
      } = {}
    ) {
      try {
        const { headers = {}, body, queryParams = {} } = options;
        
        // First, substitute secrets in URL to get the final URL for validation
        // We need to do this in two passes to handle URL restrictions properly
        const processedUrl = substituteSecrets(url, url);
        
        // Now substitute secrets in headers, body, and query parameters using the processed URL
        const processedHeaders = substituteSecretsInObject(headers, processedUrl);
        const processedBody = body ? substituteSecrets(body, processedUrl) : body;
        const processedQueryParams = substituteSecretsInObject(queryParams, processedUrl);
        
        // Build URL with query parameters
        const urlObj = new URL(processedUrl);
        Object.entries(processedQueryParams).forEach(([key, value]) => {
          if (value !== undefined && value !== null) {
            urlObj.searchParams.set(key, String(value));
          }
        });
        
        const finalUrl = urlObj.toString();
        
        // Check global URL whitelist/blacklist
        const urlCheck = isUrlAllowedGlobal(finalUrl);
        if (!urlCheck.allowed) {
          throw new Error(urlCheck.reason || 'URL is not allowed');
        }
        
        const defaultHeaders = {
          'User-Agent': 'HAL-MCP/1.0.0',
          ...processedHeaders
        };
        
             // Add Content-Type for methods that typically send data
         if (['POST', 'PUT', 'PATCH'].includes(method.toUpperCase()) && processedBody && !('Content-Type' in processedHeaders)) {
           (defaultHeaders as any)['Content-Type'] = 'application/json';
         }
        
        const response = await fetch(finalUrl, {
          method: method.toUpperCase(),
          headers: defaultHeaders,
          body: processedBody
        });
    
        const contentType = response.headers.get('content-type') || 'text/plain';
        let content: string;
        
        // HEAD requests don't have a body by design
        if (method.toUpperCase() === 'HEAD') {
          content = '(No body - HEAD request)';
        } else {
          try {
            if (contentType.includes('application/json')) {
              const text = await response.text();
              if (text.trim()) {
                content = JSON.stringify(JSON.parse(text), null, 2);
              } else {
                content = '(Empty response)';
              }
            } else {
              content = await response.text();
            }
          } catch (parseError) {
            // If JSON parsing fails, try to get text
            try {
              content = await response.text();
            } catch (textError) {
              content = '(Unable to parse response)';
            }
          }
        }
    
        // Redact secrets from response headers and content before returning
        const redactedHeaders = Array.from(response.headers.entries())
          .map(([key, value]) => `${key}: ${redactSecretsFromText(value)}`)
          .join('\n');
        const redactedContent = redactSecretsFromText(content);
    
             return {
           content: [{
             type: "text" as const,
             text: `Status: ${response.status} ${response.statusText}\n\nHeaders:\n${redactedHeaders}\n\nBody:\n${redactedContent}`
           }]
         };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        const redactedErrorMessage = redactSecretsFromText(errorMessage);
             return {
           content: [{
             type: "text" as const,
             text: `Error making ${method.toUpperCase()} request: ${redactedErrorMessage}`
           }],
           isError: true
         };
      }
    }
  • HEAD-specific handling in makeHttpRequest: sets content to note no body, processes headers.
    // HEAD requests don't have a body by design
    if (method.toUpperCase() === 'HEAD') {
      content = '(No body - HEAD request)';
    } else {
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the secret substitution feature and clarifies that only headers are returned, which are useful behavioral traits. However, it doesn't mention error handling, timeout behavior, authentication requirements beyond secrets, or rate limits.

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?

Two sentences with zero waste - first sentence states core functionality, second adds crucial secret substitution feature. Perfectly front-loaded with essential information first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 2-parameter tool with no annotations and no output schema, the description covers basic functionality well but lacks details about response format, error cases, and operational constraints. The secret substitution explanation is valuable but doesn't fully compensate for missing behavioral context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for 2 parameters, the description compensates well by explaining the 'url' parameter accepts secret substitution syntax and 'headers' are optional. It provides meaningful context about how parameters can be used, though doesn't detail header format constraints.

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?

The description clearly states the specific action ('Make an HTTP HEAD request') and resource ('to a specified URL'), distinguishing it from siblings by specifying it 'returns only headers, no body'. This differentiates it from other HTTP methods that return bodies.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool (for HEAD requests that return only headers) and implicitly distinguishes it from other HTTP methods. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools.

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/DeanWard/HAL'

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