Skip to main content
Glama
localseodata

Local SEO Data

Official

ai_mode

Read-only

Retrieve Google AI Mode responses for local search queries. Returns AI-generated text, reference links, and shopping items to assess AI visibility in search results.

Instructions

Get Google AI Mode response for a keyword and location. Returns the AI-generated response text, reference links, and shopping items. Costs 2 credits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYesSearch keyword (e.g. "best plumber near me")
locationYesCity and state (e.g. "Orchard Park, NY")

Implementation Reference

  • The registerSerpTools function is called from server.ts, which registers the 'ai_mode' tool via server.tool()
    export function registerSerpTools(server: McpServer, getAuth: () => string) {
  • The 'ai_mode' tool handler: calls the API endpoint /v1/serp/ai-mode with keyword/location and returns formatted results.
    server.tool(
      "ai_mode",
      "Get Google AI Mode response for a keyword and location. Returns the AI-generated response text, reference links, and shopping items. Costs 2 credits.",
      {
        keyword: z.string().describe('Search keyword (e.g. "best plumber near me")'),
        location: z.string().describe('City and state (e.g. "Orchard Park, NY")'),
      },
      READ_ONLY,
      withErrorHandling(async ({ keyword, location }) => {
        const result = await callApi("/v1/serp/ai-mode", { keyword, location }, getAuth());
        return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
      })
    );
  • Zod schema for 'ai_mode' tool inputs: keyword (string) and location (string), both required.
    {
      keyword: z.string().describe('Search keyword (e.g. "best plumber near me")'),
      location: z.string().describe('City and state (e.g. "Orchard Park, NY")'),
    },
  • withErrorHandling wrapper that catches errors from the handler and returns them as MCP error content.
    export function withErrorHandling<T>(
      fn: (args: T) => Promise<ToolResult>
    ): (args: T) => Promise<ToolResult> {
      return async (args) => {
        try {
          return await fn(args);
        } catch (err) {
          const message = err instanceof Error ? err.message : String(err);
          console.error(`[mcp] Tool error: ${message}`);
          return {
            content: [{ type: "text" as const, text: `Error: ${message}` }],
            isError: true,
          };
        }
      };
    }
  • formatResult helper that formats API response data along with credit metadata into a display string.
    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?

Beyond annotations (readOnlyHint=true, destructiveHint=false), the description adds that the tool costs 2 credits and returns specific content (text, links, shopping items). This provides valuable behavioral and cost context.

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: first defines purpose, second enumerates outputs and cost. No wasted words, front-loaded with core information.

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?

With no output schema, the description adequately lists return types (text, links, shopping items). Lacks details on pagination or error handling, but sufficient for a simple 2-param tool.

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 already covers both parameters with descriptions (keyword, location). The description echoes 'keyword and location' without adding new detail or constraints. Baseline 3 due to full schema coverage.

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 tool retrieves Google AI Mode responses for a keyword and location, specifying the exact resource and action. It distinguishes from siblings like ai_keyword_data or ai_compare by naming 'AI Mode' specifically.

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?

No explicit guidance on when to use this tool versus alternatives, but the name and description imply a specific use case. Among many AI sibling tools, explicit context would improve selection accuracy.

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