Skip to main content
Glama

geolocate

Find geographic location details for IP addresses or domains to identify origin and network information.

Instructions

Get geolocation information for an IP address or domain

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesIP address or domain to lookup

Implementation Reference

  • The handler function for the 'geolocate' tool. It checks cache, enforces rate limiting, fetches geolocation data from ip-api.com, caches successful results, and returns formatted JSON response.
    handler: async ({ query }: { query: string }) => {
      // Check cache first
      const cached = geoCache.get(query);
      if (cached) {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              data: cached,
              source: 'cache'
            }, null, 2)
          }]
        };
      }
    
      // Check rate limit
      if (!rateLimiter.canMakeRequest()) {
        const timeToReset = rateLimiter.getTimeToReset();
        throw new Error(`Rate limit exceeded. Please try again in ${Math.ceil(timeToReset / 1000)} seconds.`);
      }
    
      try {
        const { data, rateLimit } = await fetchGeoData(query);
        
        // Update rate limiter based on response headers
        rateLimiter.incrementRequests();
        
        // Cache successful responses
        if (data.status === 'success') {
          geoCache.set(query, data);
        }
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              data,
              rateLimit,
              source: 'api'
            }, null, 2)
          }]
        };
      } catch (error) {
        throw new Error(`Geolocation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • Input schema definition for the 'geolocate' tool, requiring a 'query' parameter (IP or domain).
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'IP address or domain to lookup'
        }
      },
      required: ['query']
    },
  • src/index.ts:28-35 (registration)
    Registration of all tools including geoTools (which contains 'geolocate') into the allTools object used for tool listing and execution.
    const allTools: ToolKit = {
      ...systemTools,
      ...networkTools,
      ...geoTools,
      ...generatorTools,
      ...dateTimeTools,
      ...securityTools
    };
  • src/index.ts:149-150 (registration)
    Specific rate limiter selection for the 'geolocate' tool during tool execution dispatch.
    } else if (request.params.name === 'geolocate') {
      rateLimiter = geoRateLimiter;
  • Helper function to fetch geolocation data from ip-api.com API, including rate limit headers.
    async function fetchGeoData(query: string): Promise<{ data: GeoLocation; rateLimit: RateLimitInfo }> {
      const fields = [
        'status',
        'message',
        'country',
        'countryCode',
        'region',
        'regionName',
        'city',
        'zip',
        'lat',
        'lon',
        'timezone',
        'offset',
        'isp',
        'org',
        'as',
        'query'
      ].join(',');
    
      const url = `http://ip-api.com/json/${encodeURIComponent(query)}?fields=${fields}`;
      
      const response = await fetch(url);
      const data = await response.json() as GeoLocation;
      
      const remaining = Number(response.headers.get('X-Rl') ?? '0');
      const ttl = Number(response.headers.get('X-Ttl') ?? '0');
    
      return {
        data,
        rateLimit: { remaining, ttl }
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't mention rate limits, data sources, accuracy, caching behavior, or error handling. For a lookup tool with external dependencies, this leaves significant gaps in understanding operational constraints.

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?

The description is a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a simple lookup tool and front-loads the essential information.

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 simple single-parameter lookup tool with no output schema, the description covers the basic purpose adequately. However, without annotations or output details, it lacks information about return format, error cases, or performance characteristics that would help an agent use it effectively in complex scenarios.

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%, with the single parameter 'query' well-documented in the schema. The description adds minimal value beyond the schema by confirming the parameter accepts 'IP address or domain', but doesn't provide additional context like format requirements or examples. Baseline 3 is appropriate given the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'geolocation information', specifying the target as 'IP address or domain'. It's specific about what the tool does, though it doesn't explicitly differentiate from sibling tools like 'getPublicIP' or 'pingHost' which have related but distinct purposes.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'getPublicIP' (which might provide IP information) or 'pingHost' (which tests connectivity), leaving the agent to infer usage context without explicit direction.

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/cyanheads/toolkit-mcp-server'

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