Skip to main content
Glama
localseodata

Local SEO Data

Official

location_search

Read-only

Convert city or region queries into the exact location names required by DataForSEO, enabling accurate local SEO data retrieval.

Instructions

Search for DataForSEO location names. Use this BEFORE other tools to resolve a city/region into the exact location_name format that DataForSEO requires (e.g. 'Orchard Park,New York,United States'). Free — costs 0 credits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesLocation query (e.g. "Orchard Park" or "Austin TX")
limitNoMax results. Default: 10

Implementation Reference

  • The handler function that executes the location_search tool logic: calls API GET /v1/locations/search with query params and formats the result.
      withErrorHandling(async ({ q, limit }) => {
        const params = new URLSearchParams({ q });
        if (limit) params.set("limit", String(limit));
        const result = await callApiGet(`/v1/locations/search?${params}`, getAuth());
        return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
      })
    );
  • Zod schema for location_search tool inputs: 'q' (string, required) and 'limit' (optional integer, 1-50, default 10).
    {
      q: z.string().min(1).describe('Location query (e.g. "Orchard Park" or "Austin TX")'),
      limit: z.number().int().min(1).max(50).optional().describe("Max results. Default: 10"),
    },
  • The registerLocationTools function registers the 'location_search' tool on the MCP server with its name, description, schema, and handler.
    export function registerLocationTools(server: McpServer, getAuth: () => string) {
      server.tool(
        "location_search",
        "Search for DataForSEO location names. Use this BEFORE other tools to resolve a city/region into the exact location_name format that DataForSEO requires (e.g. 'Orchard Park,New York,United States'). Free — costs 0 credits.",
        {
          q: z.string().min(1).describe('Location query (e.g. "Orchard Park" or "Austin TX")'),
          limit: z.number().int().min(1).max(50).optional().describe("Max results. Default: 10"),
        },
        READ_ONLY,
        withErrorHandling(async ({ q, limit }) => {
          const params = new URLSearchParams({ q });
          if (limit) params.set("limit", String(limit));
          const result = await callApiGet(`/v1/locations/search?${params}`, getAuth());
          return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
        })
      );
    }
  • formatResult helper used by the handler to format API response data with metadata (credits used/remaining).
    export function formatResult(
      data: unknown,
      meta: { credits_used: number; credits_remaining: number; cached: boolean }
    ): string {
      const metaLine = `[${meta.credits_used} credit${meta.credits_used !== 1 ? "s" : ""} used | ${meta.credits_remaining} remaining${meta.cached ? " | cached" : ""}]`;
      return `${metaLine}\n\n${JSON.stringify(data, null, 2)}`;
    }
  • callApiGet helper used by the handler to make GET requests to the underlying API.
    export async function callApiGet(
      path: string,
      authHeader: string
    ): Promise<{ data: unknown; credits_used: number; credits_remaining: number; cached: boolean }> {
      const url = `${env.API_BASE_URL}${path}`;
    
      console.log(`[api] GET ${url} (auth: ${authHeader ? `${authHeader.slice(0, 15)}...` : "MISSING"})`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: authHeader,
        },
        signal: AbortSignal.timeout(60_000),
      });
    
      if (!response.ok) {
        const text = await response.text();
        console.error(`[api] ${response.status} ${response.statusText} from ${path}: ${text.slice(0, 200)}`);
        throw new Error(`API returned ${response.status}: ${text.slice(0, 200)}`);
      }
    
      const result = (await response.json()) as ApiResponse;
    
      if (result.status === "error") {
        throw new Error(result.error.message);
      }
    
      console.log(`[api] ${path} OK (${result.credits_used} credits used, ${result.credits_remaining} remaining)`);
    
      return {
        data: result.data,
        credits_used: result.credits_used,
        credits_remaining: result.credits_remaining,
        cached: result.cached,
      };
    }
Behavior4/5

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

Annotations already indicate readOnly and non-destructive. Description adds that it's free (0 credits) and hints at return format. No contradictions.

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, front-loaded with purpose and usage. Every sentence adds value.

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

Completeness5/5

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

No output schema, but description explains the return format (exact location_name string). For a simple search tool, it's complete.

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 already covers both parameters with descriptions (100% coverage). Description doesn't add beyond schema, so baseline 3.

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 it searches for DataForSEO location names and explicitly says to use it before other tools to resolve city/region into exact format. This distinguishes it from sibling tools which are mostly SEO analysis tools.

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

Usage Guidelines5/5

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

Explicit usage guidance: 'Use this BEFORE other tools to resolve a city/region into the exact location_name format'. Also mentions it's free, setting expectations clearly.

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

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