Skip to main content
Glama
competlab

competlab-mcp-server

get_ai_visibility_trend

Track how LLM brand perception changes over time. Analyze up to 200 data points per query, with optional provider filter for OpenAI, Claude, or Gemini. Ideal for time-series analysis of AI visibility.

Instructions

Get AI Visibility trend data over time — track how LLM brand perception changes. Returns up to 200 data points. Without provider filter: returns pre-computed aggregate summaries across all LLMs. With provider filter (openai, claude, gemini): computes from raw per-provider results. Use this for time-series analysis; use get_ai_visibility_dashboard for the latest snapshot or get_ai_visibility_check_detail for a specific check. Read-only. Returns JSON array. Dates are ISO-8601 format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID (from list_projects)
dateFromNoStart date in ISO-8601 format (e.g., 2026-01-01)
dateToNoEnd date in ISO-8601 format (e.g., 2026-03-15)
providerNoFilter by LLM provider. Omit for aggregate view across all providers

Implementation Reference

  • Schema definition for get_ai_visibility_trend tool. Defines input parameters (projectId required, dateFrom/dateTo/provider optional) and API endpoint path.
    {
      name: "get_ai_visibility_trend",
      description:
        "Get AI Visibility trend data over time — track how LLM brand perception changes. Returns up to 200 data points. Without provider filter: returns pre-computed aggregate summaries across all LLMs. With provider filter (openai, claude, gemini): computes from raw per-provider results. Use this for time-series analysis; use get_ai_visibility_dashboard for the latest snapshot or get_ai_visibility_check_detail for a specific check. Read-only. Returns JSON array. Dates are ISO-8601 format.",
      parameters: z.object({
        projectId: objectId("Project ID (from list_projects)"),
        dateFrom: z
          .string()
          .optional()
          .describe("Start date in ISO-8601 format (e.g., 2026-01-01)"),
        dateTo: z
          .string()
          .optional()
          .describe("End date in ISO-8601 format (e.g., 2026-03-15)"),
        provider: z
          .enum(["openai", "claude", "gemini"])
          .optional()
          .describe("Filter by LLM provider. Omit for aggregate view across all providers"),
      }),
      path: (a) => `/v1/projects/${a.projectId}/ai-visibility/trend`,
      queryParams: ["dateFrom", "dateTo", "provider"],
    },
  • src/index.ts:16-25 (registration)
    Generic registration loop that registers all tools (including get_ai_visibility_trend) from the tools array via server.tool(). The handler delegates to apiGet with the endpoint path and query params.
    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);
      });
    }
  • Generic HTTP GET helper used by all tools. Makes fetch request to CompetLab API with CL-API-Key header, returns JSON text response or 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,
        };
      }
    }
  • Handler for get_ai_visibility_trend - implemented by the generic tool loop. Calls the API at /v1/projects/{projectId}/ai-visibility/trend with optional query params (dateFrom, dateTo, provider). Returns JSON array of trend data points.
    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);
      });
    }
Behavior4/5

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

The description discloses key behaviors: returns up to 200 data points, read-only, JSON array, ISO-8601 dates, and aggregate vs. per-provider computation. No annotations exist, so the description carries the full burden. Missing details on pagination or truncation, but still transparent.

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?

The description is concise with four sentences, front-loaded with the main purpose. Every sentence adds value: purpose, limit, behavior difference, sibling differentiation, read-only note, and return format. No redundant information.

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?

With no output schema, the description explains return type and format (JSON array, ISO-8601 dates, up to 200 data points). It covers constraints and parameter-dependent behavior. The tool is simple, and the description provides sufficient context for correct invocation.

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?

Schema coverage is 100%, so baseline is 3. The description adds context: explains that omitting provider returns aggregate summaries, and including it computes from raw results. This adds meaning beyond the parameter descriptions 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 gets AI Visibility trend data over time, tracking LLM brand perception. It distinguishes itself from siblings by specifying that get_ai_visibility_dashboard is for the latest snapshot and get_ai_visibility_check_detail is for a specific check.

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 provides when-to-use guidance: 'Use this for time-series analysis; use get_ai_visibility_dashboard for the latest snapshot or get_ai_visibility_check_detail for a specific check.' Also explains behavior with/without provider filter.

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