Skip to main content
Glama
localseodata

Local SEO Data

Official

ping

Read-only

Test your API key connectivity and authentication by making a lightweight health check call to the backend. Diagnose connection or auth issues.

Instructions

Test connectivity and auth. Verifies the API key works end-to-end by making a lightweight call to the backend API health endpoint with your credentials. Use this to diagnose connection or authentication issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The async handler function that executes the 'ping' tool logic — validates auth header, checks health endpoint, tests direct key validation, and tests authenticated API call via middleware.
      async () => {
        const lines: string[] = [];
    
        // Check auth header
        let authHeader: string;
        let rawKey: string;
        try {
          authHeader = getAuth();
          lines.push(`Auth header format: ${authHeader.startsWith("Bearer ") ? "Bearer <key>" : "UNEXPECTED: " + authHeader.slice(0, 20)}`);
    
          rawKey = authHeader.startsWith("Bearer ") ? authHeader.slice(7) : authHeader;
          lines.push(`Key prefix: ${rawKey.slice(0, 12)}`);
          lines.push(`Key length: ${rawKey.length}`);
          lines.push(`Key suffix: ...${rawKey.slice(-4)}`);
    
          const keyHash = createHash("sha256").update(rawKey).digest("hex");
          lines.push(`Key SHA256: ${keyHash.slice(0, 16)}...`);
        } catch (err) {
          lines.push(`Auth error: ${err instanceof Error ? err.message : String(err)}`);
          return { content: [{ type: "text" as const, text: lines.join("\n") }], isError: true };
        }
    
        lines.push(`API base URL: ${env.API_BASE_URL}`);
    
        // Test 1: Health endpoint (unauthenticated)
        try {
          const healthRes = await fetch(`${env.API_BASE_URL}/health`);
          lines.push(`Health check: ${healthRes.status} ${healthRes.statusText}`);
        } catch (err) {
          lines.push(`Health check FAILED: ${err instanceof Error ? err.message : String(err)}`);
        }
    
        // Test 2: Direct key validation (bypasses auth middleware)
        try {
          const debugRes = await fetch(`${env.API_BASE_URL}/debug/auth-test?key=${encodeURIComponent(rawKey)}`);
          const debugText = await debugRes.text();
          lines.push(`Direct validation: ${debugRes.status} — ${debugText.slice(0, 300)}`);
        } catch (err) {
          lines.push(`Direct validation FAILED: ${err instanceof Error ? err.message : String(err)}`);
        }
    
        // Test 3: Authenticated call through middleware
        try {
          const res = await fetch(`${env.API_BASE_URL}/v1/account/balance`, {
            method: "GET",
            headers: { Authorization: authHeader },
          });
          const text = await res.text();
          if (res.ok) {
            lines.push(`Auth middleware: OK (${res.status})`);
            try {
              const data = JSON.parse(text);
              if (data.credits_remaining !== undefined) {
                lines.push(`Credits remaining: ${data.credits_remaining}`);
              }
              if (data.data?.plan) {
                lines.push(`Plan: ${data.data.plan.name}`);
              }
            } catch { /* ignore parse errors */ }
          } else {
            lines.push(`Auth middleware: FAILED ${res.status} — ${text.slice(0, 300)}`);
          }
        } catch (err) {
          lines.push(`Auth middleware error: ${err instanceof Error ? err.message : String(err)}`);
        }
    
        const hasError = lines.some((l) => l.includes("FAILED") || l.includes("error"));
        return {
          content: [{ type: "text" as const, text: lines.join("\n") }],
          ...(hasError && { isError: true }),
        };
      }
    );
  • The tool registration with name 'ping', description, empty input schema ({}), and READ_ONLY metadata.
    server.tool(
      "ping",
      "Test connectivity and auth. Verifies the API key works end-to-end by making a lightweight call to the backend API health endpoint with your credentials. Use this to diagnose connection or authentication issues.",
      {},
  • The function registerDiagnosticTools that registers the 'ping' tool (and potentially others) on the McpServer instance.
    export function registerDiagnosticTools(server: McpServer, getAuth: () => string) {
      server.tool(
        "ping",
        "Test connectivity and auth. Verifies the API key works end-to-end by making a lightweight call to the backend API health endpoint with your credentials. Use this to diagnose connection or authentication issues.",
        {},
        READ_ONLY,
        async () => {
          const lines: string[] = [];
    
          // Check auth header
          let authHeader: string;
          let rawKey: string;
          try {
            authHeader = getAuth();
            lines.push(`Auth header format: ${authHeader.startsWith("Bearer ") ? "Bearer <key>" : "UNEXPECTED: " + authHeader.slice(0, 20)}`);
    
            rawKey = authHeader.startsWith("Bearer ") ? authHeader.slice(7) : authHeader;
            lines.push(`Key prefix: ${rawKey.slice(0, 12)}`);
            lines.push(`Key length: ${rawKey.length}`);
            lines.push(`Key suffix: ...${rawKey.slice(-4)}`);
    
            const keyHash = createHash("sha256").update(rawKey).digest("hex");
            lines.push(`Key SHA256: ${keyHash.slice(0, 16)}...`);
          } catch (err) {
            lines.push(`Auth error: ${err instanceof Error ? err.message : String(err)}`);
            return { content: [{ type: "text" as const, text: lines.join("\n") }], isError: true };
          }
    
          lines.push(`API base URL: ${env.API_BASE_URL}`);
    
          // Test 1: Health endpoint (unauthenticated)
          try {
            const healthRes = await fetch(`${env.API_BASE_URL}/health`);
            lines.push(`Health check: ${healthRes.status} ${healthRes.statusText}`);
          } catch (err) {
            lines.push(`Health check FAILED: ${err instanceof Error ? err.message : String(err)}`);
          }
    
          // Test 2: Direct key validation (bypasses auth middleware)
          try {
            const debugRes = await fetch(`${env.API_BASE_URL}/debug/auth-test?key=${encodeURIComponent(rawKey)}`);
            const debugText = await debugRes.text();
            lines.push(`Direct validation: ${debugRes.status} — ${debugText.slice(0, 300)}`);
          } catch (err) {
            lines.push(`Direct validation FAILED: ${err instanceof Error ? err.message : String(err)}`);
          }
    
          // Test 3: Authenticated call through middleware
          try {
            const res = await fetch(`${env.API_BASE_URL}/v1/account/balance`, {
              method: "GET",
              headers: { Authorization: authHeader },
            });
            const text = await res.text();
            if (res.ok) {
              lines.push(`Auth middleware: OK (${res.status})`);
              try {
                const data = JSON.parse(text);
                if (data.credits_remaining !== undefined) {
                  lines.push(`Credits remaining: ${data.credits_remaining}`);
                }
                if (data.data?.plan) {
                  lines.push(`Plan: ${data.data.plan.name}`);
                }
              } catch { /* ignore parse errors */ }
            } else {
              lines.push(`Auth middleware: FAILED ${res.status} — ${text.slice(0, 300)}`);
            }
          } catch (err) {
            lines.push(`Auth middleware error: ${err instanceof Error ? err.message : String(err)}`);
          }
    
          const hasError = lines.some((l) => l.includes("FAILED") || l.includes("error"));
          return {
            content: [{ type: "text" as const, text: lines.join("\n") }],
            ...(hasError && { isError: true }),
          };
        }
      );
    }
  • src/server.ts:48-48 (registration)
    Invocation of registerDiagnosticTools in the main server setup, which registers the 'ping' tool.
    registerDiagnosticTools(server, getAuth);
  • Configuration helper that provides env.API_BASE_URL used by the ping handler to make API calls.
    function getEnv(key: string, fallback?: string): string {
      const value = process.env[key] ?? fallback;
      if (value === undefined) {
        throw new Error(`Missing required environment variable: ${key}`);
      }
      return value;
    }
    
    export const env = {
      API_BASE_URL: getEnv("API_BASE_URL", "https://api.localseodata.com"),
      PORT: parseInt(getEnv("PORT", "3003"), 10),
    } as const;
Behavior5/5

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

Annotations already declare readOnlyHint, destructiveHint, openWorldHint. The description adds value by stating it's lightweight and end-to-end, expanding on the behavioral traits beyond annotations. No contradiction.

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 with no wasted words. The first sentence front-loads the primary purpose; the second adds specific use case. Every sentence earns its place.

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?

For a simple health-check tool with no output schema, the description is complete. It explains what the tool does, why to use it, and what it verifies. No additional context needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters exist, and schema coverage is 100%. The description does not need to add parameter info; baseline for 0 params is 4.

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 tests connectivity and authentication, using verbs 'test' and 'verifies' with specific resources (connectivity, auth, API key). It distinguishes well from sibling tools, which are all SEO/analytics related.

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

Usage Guidelines4/5

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

Explicitly says 'Use this to diagnose connection or authentication issues,' providing clear context for when to use. No exclusions or alternatives are mentioned, but the tool's purpose is narrow enough that this is sufficient.

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