Skip to main content
Glama
localseodata

Local SEO Data

Official

keyword_suggestions

Read-only

Discover keyword ideas for any business or location. Input a seed keyword and geographic area to receive related keywords with search volume and other metrics.

Instructions

Get keyword suggestions for a seed keyword. Returns related keywords with search volume and metrics. Costs 2 credits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYesSeed keyword (e.g. "plumber")
locationYesGeographic location (e.g. "Orchard Park, NY")
limitNoMax suggestions. Default: 50, max: 1000
include_seed_keywordNoInclude seed keyword in results. Default: true

Implementation Reference

  • The handler function for the 'keyword_suggestions' tool. It calls the API endpoint /v1/keywords/suggestions with the keyword, location, optional limit, and optional include_seed_keyword parameters, then formats the result.
    withErrorHandling(async ({ keyword, location, limit, include_seed_keyword }) => {
      const result = await callApi(
        "/v1/keywords/suggestions",
        {
          keyword,
          location,
          ...(limit && { limit }),
          ...(include_seed_keyword !== undefined && { include_seed_keyword }),
        },
        getAuth()
      );
      return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
    })
  • Zod schema for input validation: keyword (required string), location (required string), limit (optional number 1-1000), include_seed_keyword (optional boolean).
    {
      keyword: z.string().min(1).describe('Seed keyword (e.g. "plumber")'),
      location: z.string().min(1).describe('Geographic location (e.g. "Orchard Park, NY")'),
      limit: z.number().int().min(1).max(1000).optional().describe("Max suggestions. Default: 50, max: 1000"),
      include_seed_keyword: z.boolean().optional().describe("Include seed keyword in results. Default: true"),
    },
  • Registration of 'keyword_suggestions' tool via server.tool() inside registerKeywordTools(), with description 'Get keyword suggestions for a seed keyword...' and READ_ONLY hint.
    server.tool(
      "keyword_suggestions",
      "Get keyword suggestions for a seed keyword. Returns related keywords with search volume and metrics. Costs 2 credits.",
      {
        keyword: z.string().min(1).describe('Seed keyword (e.g. "plumber")'),
        location: z.string().min(1).describe('Geographic location (e.g. "Orchard Park, NY")'),
        limit: z.number().int().min(1).max(1000).optional().describe("Max suggestions. Default: 50, max: 1000"),
        include_seed_keyword: z.boolean().optional().describe("Include seed keyword in results. Default: true"),
      },
      READ_ONLY,
      withErrorHandling(async ({ keyword, location, limit, include_seed_keyword }) => {
        const result = await callApi(
          "/v1/keywords/suggestions",
          {
            keyword,
            location,
            ...(limit && { limit }),
            ...(include_seed_keyword !== undefined && { include_seed_keyword }),
          },
          getAuth()
        );
        return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
      })
    );
  • The callApi helper invoked by the handler to make the POST request to the API. It sends the request with auth headers and returns data with credit metadata.
    export async function callApi(
      path: string,
      body: Record<string, unknown>,
      authHeader: string,
      timeoutMs = 60_000
    ): Promise<{ data: unknown; credits_used: number; credits_remaining: number; cached: boolean }> {
      const url = `${env.API_BASE_URL}${path}`;
    
      console.log(`[api] POST ${url} (timeout: ${timeoutMs / 1000}s, auth: ${authHeader ? `${authHeader.slice(0, 15)}...` : "MISSING"})`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: authHeader,
        },
        body: JSON.stringify(body),
        signal: AbortSignal.timeout(timeoutMs),
      });
    
      if (!response.ok) {
        const text = await response.text();
        console.error(`[api] ${response.status} ${response.statusText} from ${path}: ${text.slice(0, 200)}`);
        // Try to parse as structured error
        try {
          const result = JSON.parse(text) as ApiErrorResponse;
          if (result.status === "error") {
            const err = result.error;
            const reqId = result.request_id ? ` [request_id: ${result.request_id}]` : "";
            throw new Error(
              err.required_credits
                ? `${err.message} (requires ${err.required_credits} credits, balance: ${err.current_balance})${reqId}`
                : `${err.message}${reqId}`
            );
          }
        } catch (parseErr) {
          if (parseErr instanceof Error && parseErr.message !== "error") {
            // Re-throw if it's our structured error from above
            if (!text.includes('"status":"error"')) {
              throw new Error(`API returned ${response.status}: ${text.slice(0, 200)}`);
            }
            throw parseErr;
          }
        }
        throw new Error(`API returned ${response.status}: ${text.slice(0, 200)}`);
      }
    
      const result = (await response.json()) as ApiResponse;
    
      if (result.status === "error") {
        const err = (result as ApiErrorResponse).error;
        const reqId = (result as ApiErrorResponse).request_id ? ` [request_id: ${(result as ApiErrorResponse).request_id}]` : "";
        throw new Error(
          err.required_credits
            ? `${err.message} (requires ${err.required_credits} credits, balance: ${err.current_balance})${reqId}`
            : `${err.message}${reqId}`
        );
      }
    
      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,
      };
    }
  • The formatResult helper used by the handler to format the response data into a text string with credit usage metadata.
    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)}`;
    }
Behavior4/5

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

Annotations already indicate readOnlyHint=true and destructiveHint=false. Description adds valuable context about credit cost, which is beyond annotations. No mention of rate limits or error behavior, but acceptable given safe profile.

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?

Three concise sentences: purpose, output description, cost. No wasted words, front-loaded with key action. Exceptionally efficient.

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

Completeness4/5

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

Tool has 4 parameters and no output schema. Description covers core purpose, output type, and cost. Lacks details on default limit or pagination, but schema covers limits. Adequate for basic usage.

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?

Input schema has 100% coverage with descriptions for all parameters. Description adds minimal value beyond schema, only restating 'seed keyword' and 'geographic location' context. Baseline 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?

Clearly states 'Get keyword suggestions for a seed keyword' with specific verb and resource. Distinguishes from siblings like keyword_opportunities and keyword_trends by focusing on suggestions for a single seed keyword.

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

Usage Guidelines3/5

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

Provides cost signal ('Costs 2 credits') but no explicit when-to-use or comparison to sibling tools. Lacks guidance on when to prefer this over related tools like keyword_opportunities.

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