Skip to main content
Glama
DeanWard

HAL (HTTP API Layer)

HTTP GET Request

http-get

Make HTTP GET requests to retrieve data from any URL, with built-in secret substitution for secure API calls.

Instructions

Make an HTTP GET request to a specified URL. Supports secret substitution using {secrets.key} syntax where 'key' corresponds to HAL_SECRET_KEY environment variables.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
headersNo

Implementation Reference

  • src/index.ts:571-584 (registration)
    Registration of the 'http-get' tool on the MCP server, defining its name, description, input schema (url as required string, headers as optional record), and handler callback that delegates to makeHttpRequest.
    server.registerTool(
      "http-get",
      {
        title: "HTTP GET Request",
        description: "Make an HTTP GET request to a specified URL. Supports secret substitution using {secrets.key} syntax 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('GET', url, { headers });
      }
    );
  • Input schema for http-get: requires a valid URL string, accepts optional headers as a record of strings.
    inputSchema: { 
      url: z.string().url(),
      headers: z.record(z.string()).optional()
    }
  • Core HTTP request handler used by http-get (and all other http-* tools). Handles secret substitution, URL validation, global whitelist/blacklist checks, fetch execution, response parsing (JSON/text), and secret redaction from responses.
    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
         };
      }
    }
  • Helper that matches URLs against wildcard patterns, used by URL validation checks that protect http-get requests.
    function matchesUrlPattern(url: string, pattern: string): boolean {
      // Convert pattern to regex
      // Escape special regex characters except *
      const escapedPattern = pattern
        .replace(/[.+?^${}()|[\]\\]/g, '\\$&')
        .replace(/\*/g, '.*');
      
      const regex = new RegExp(`^${escapedPattern}$`, 'i');
      return regex.test(url);
    }
  • Helper that enforces global URL whitelist/blacklist filters (HAL_WHITELIST_URLS, HAL_BLACKLIST_URLS) for http-get requests.
    function isUrlAllowedGlobal(url: string): { allowed: boolean; reason?: string } {
      const { whitelist, blacklist } = loadGlobalUrlFilters();
      
      // If both whitelist and blacklist are provided, prioritize whitelist
      if (whitelist && blacklist) {
        console.error('Warning: Both HAL_WHITELIST_URLS and HAL_BLACKLIST_URLS are set. Whitelist takes precedence.');
      }
      
      // Check whitelist first (if present, only whitelisted URLs are allowed)
      if (whitelist) {
        for (const pattern of whitelist) {
          if (matchesUrlPattern(url, pattern)) {
            return { allowed: true };
          }
        }
        return { 
          allowed: false, 
          reason: `URL '${url}' is not in the whitelist. Allowed patterns: ${whitelist.join(', ')}` 
        };
      }
      
      // Check blacklist (if present, blacklisted URLs are denied)
      if (blacklist) {
        for (const pattern of blacklist) {
          if (matchesUrlPattern(url, pattern)) {
            return { 
              allowed: false, 
              reason: `URL '${url}' is blacklisted. Blocked patterns: ${blacklist.join(', ')}` 
            };
          }
        }
        return { allowed: true };
      }
      
      // If neither whitelist nor blacklist is set, allow all URLs
      return { allowed: true };
    }
Behavior3/5

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

Discloses secret substitution feature using {secrets.key} syntax, which is a notable behavior. However, lacks other behavioral details such as idempotency, error handling, or response format. Since annotations are absent, more transparency is needed.

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?

Extremely concise with two sentences conveying essential purpose and a key feature (secret substitution). No redundancy.

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?

Given no output schema and complex nested parameter (headers), the description omits important context like return values, error responses, or behavior of headers. Incomplete for effective use.

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

Parameters2/5

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

Schema coverage is 0%, meaning the description does not elaborate on parameter usage beyond the schema. The description mentions secret substitution but does not relate it to parameters. No information on how headers affect the request.

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?

Clearly states 'Make an HTTP GET request to a specified URL', specifying exact verb and resource. Implicitly differentiates from sibling tools like http-post or http-delete by naming the method.

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 siblings (e.g., when a GET vs POST is appropriate). No prerequisites or exclusions provided.

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

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