Skip to main content
Glama
localseodata

Local SEO Data

Official

business_listings

Read-only

Search for businesses by category and location. Retrieve names, ratings, reviews, addresses, phone numbers, and categories for local SEO analysis.

Instructions

Search for businesses by category and location. Returns a list of businesses with name, rating, reviews, address, phone, place_id, and categories. Costs 10 credits per 50 results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesBusiness category (e.g. "plumber", "dentist")
locationYesCity and state
limitNoNumber of results (1-200). Default: 50

Implementation Reference

  • The 'business_listings' tool handler. Calls /v1/business/listings API with category, location, and optional limit. Returns up to 200 results (default 50). Costs 10 credits per 50 results.
    server.tool(
      "business_listings",
      "Search for businesses by category and location. Returns a list of businesses with name, rating, reviews, address, phone, place_id, and categories. Costs 10 credits per 50 results.",
      {
        category: z.string().describe('Business category (e.g. "plumber", "dentist")'),
        location: z.string().describe("City and state"),
        limit: z.number().int().min(1).max(200).optional().describe("Number of results (1-200). Default: 50"),
      },
      READ_ONLY,
      withErrorHandling(async ({ category, location, limit }) => {
        const result = await callApi(
          "/v1/business/listings",
          { category, location, ...(limit && { limit }) },
          getAuth()
        );
        return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
      })
    );
  • Input schema for 'business_listings': category (string), location (string), and optional limit (int 1-200, default 50).
    {
      category: z.string().describe('Business category (e.g. "plumber", "dentist")'),
      location: z.string().describe("City and state"),
      limit: z.number().int().min(1).max(200).optional().describe("Number of results (1-200). Default: 50"),
    },
  • Tool registered via server.tool() with the name 'business_listings' and read-only hints.
    server.tool(
      "business_listings",
      "Search for businesses by category and location. Returns a list of businesses with name, rating, reviews, address, phone, place_id, and categories. Costs 10 credits per 50 results.",
      {
        category: z.string().describe('Business category (e.g. "plumber", "dentist")'),
        location: z.string().describe("City and state"),
        limit: z.number().int().min(1).max(200).optional().describe("Number of results (1-200). Default: 50"),
      },
      READ_ONLY,
      withErrorHandling(async ({ category, location, limit }) => {
        const result = await callApi(
          "/v1/business/listings",
          { category, location, ...(limit && { limit }) },
          getAuth()
        );
        return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
      })
    );
  • src/server.ts:36-36 (registration)
    Registration call: registerBusinessTools(server, getAuth) wires the tools into the MCP server.
    registerBusinessTools(server, getAuth);
  • The callApi helper and withErrorHandling wrapper used by the business_listings handler to call the external API and format results.
    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,
      };
    }
    
    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,
      };
    }
    
    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)}`;
    }
    
    type ToolResult = { content: { type: "text"; text: string }[]; isError?: boolean };
    
    /** Wrap an MCP tool handler so thrown errors always surface 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,
          };
        }
      };
    }
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. The description adds value by stating the cost (10 credits per 50 results) and listing return fields, which are behavioral traits not covered by annotations.

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 concise sentences: first describes action and output, second adds cost. No filler, efficient and front-loaded.

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?

For a search tool with 3 well-documented parameters and annotations, the description is sufficient. It could include an example output or usage hint, but overall 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 coverage is 100%, so the description does not need to add parameter details. It adds no extra parameter meaning beyond what is already in the schema.

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 businesses by category and location, listing specific return fields. It is distinct from siblings like 'business_profile' or 'local_finder'.

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?

The description mentions credits cost and default limit, providing usage context. However, it lacks explicit guidance on when to use this tool versus siblings like 'local_finder' or 'business_profile'.

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