Skip to main content
Glama
competlab

competlab-mcp-server

get_ai_visibility_history

Browse paginated history of AI Visibility checks with completion timestamps. Each check runs 3 prompts across 3 LLMs. Retrieve past checks by project, page, and limit. Returns JSON with pagination metadata.

Instructions

Get paginated history of AI Visibility checks with completion timestamps. Note: uses checkId (not runId) — AI Visibility has a different data model where each check is one 3-prompt x 3-LLM query cycle. Use this to browse past checks; retrieve full detail with get_ai_visibility_check_detail, or use get_ai_visibility_trend for aggregate time-series. Read-only. Returns paginated JSON array with pagination.hasMore flag.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID (from list_projects)
pageNoPage number (1-indexed, default: 1)
limitNoItems per page (default: 20, max: 100)

Implementation Reference

  • Generic handler function that is used for ALL tools including get_ai_visibility_history. It iterates over all tools and registers them with the MCP server using server.tool(). For each tool call, it constructs the API path from the tool definition and calls apiGet with optional query params. There is no separate handler function for this tool — the generic loop handles it.
    for (const tool of tools) {
      server.tool(tool.name, tool.description, tool.parameters.shape, async (args: Record<string, any>) => {
        const path = tool.path(args);
        const query: Record<string, any> = {};
        for (const key of tool.queryParams ?? []) {
          if (args[key] !== undefined) query[key] = args[key];
        }
        return apiGet(path, Object.keys(query).length ? query : undefined);
      });
    }
  • Schema definition for get_ai_visibility_history tool. Defines the Zod schema with projectId (24-char hex ObjectId) and pagination (page, limit) params. The API path is /v1/projects/{projectId}/ai-visibility/history with query params page and limit.
    {
      name: "get_ai_visibility_history",
      description:
        "Get paginated history of AI Visibility checks with completion timestamps. Note: uses checkId (not runId) — AI Visibility has a different data model where each check is one 3-prompt x 3-LLM query cycle. Use this to browse past checks; retrieve full detail with get_ai_visibility_check_detail, or use get_ai_visibility_trend for aggregate time-series. Read-only. Returns paginated JSON array with pagination.hasMore flag.",
      parameters: z.object({
        projectId: objectId("Project ID (from list_projects)"),
        ...pagination,
      }),
      path: (a) => `/v1/projects/${a.projectId}/ai-visibility/history`,
      queryParams: ["page", "limit"],
    },
  • src/index.ts:16-25 (registration)
    Registration loop that registers all tools (including get_ai_visibility_history) with the MCP server via server.tool(tool.name, tool.description, tool.parameters.shape, handler). The tool definition from tools.ts is used to wire up name, description, schema, path, and handler.
    for (const tool of tools) {
      server.tool(tool.name, tool.description, tool.parameters.shape, async (args: Record<string, any>) => {
        const path = tool.path(args);
        const query: Record<string, any> = {};
        for (const key of tool.queryParams ?? []) {
          if (args[key] !== undefined) query[key] = args[key];
        }
        return apiGet(path, Object.keys(query).length ? query : undefined);
      });
    }
  • The apiGet helper function that executes the actual HTTP request for all tools. It reads the COMPETLAB_API_KEY env var, builds the full URL from API_BASE (https://api.competlab.com) + path, passes optional query params, and returns JSON content or an error.
    export async function apiGet(
      path: string,
      query?: Record<string, string | number>,
    ): Promise<{ content: Array<{ type: "text"; text: string }>; isError?: true }> {
      const apiKey = process.env.COMPETLAB_API_KEY;
      if (!apiKey) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                error: "api_key_missing",
                message: "COMPETLAB_API_KEY environment variable is not set",
              }),
            },
          ],
          isError: true,
        };
      }
    
      const url = new URL(`${API_BASE}${path}`);
      if (query) {
        for (const [k, v] of Object.entries(query)) {
          if (v !== undefined) url.searchParams.set(k, String(v));
        }
      }
    
      try {
        const res = await fetch(url, {
          headers: { "CL-API-Key": apiKey },
        });
    
        const body = await res.text();
    
        if (!res.ok) {
          return { content: [{ type: "text", text: body }], isError: true };
        }
    
        return { content: [{ type: "text", text: body }] };
      } catch (err) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                error: "api_unreachable",
                message:
                  err instanceof Error ? err.message : "Failed to reach CompetLab API",
                status: 503,
              }),
            },
          ],
          isError: true,
        };
      }
    }
Behavior4/5

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

Discloses read-only nature and pagination behavior with 'hasMore' flag. No annotations provided, so description bears full burden. Could mention sorting order or rate limits, but current detail is adequate for a paginated list tool.

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?

Description is compact, front-loaded with purpose, and uses clear sentences. Every sentence adds value, and the note about checkId vs runId is crucial. No redundancy or filler.

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?

Given the tool's moderate complexity (3 parameters, simple pagination), the description covers all necessary aspects: purpose, data model nuance, pagination behavior, and sibling differentiation. No obvious gaps.

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 baseline is 3. Description adds minimal value beyond parameter names and types; it does imply that projectId comes from list_projects, which is already in the schema description. No extra constraints or usage notes added.

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 it retrieves paginated history of AI Visibility checks with completion timestamps. Distinguishes from sibling tools by noting differences in data model and providing alternative tool names for detail and trend views.

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?

Explicitly advises when to use this tool ('browse past checks') and when to use alternatives ('get_ai_visibility_check_detail' for detail, 'get_ai_visibility_trend' for aggregate time-series). Also clarifies the unique data model with checkId vs runId.

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

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