Skip to main content
Glama
colintoh

Clicky MCP Server

by colintoh

get_domain_visitors

Retrieve visitor analytics for specific domains from Clicky, including visitor counts and page data within customizable date ranges and segmentation options.

Instructions

Get visitors filtered by domain from Clicky analytics with optional segmentation data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesDomain name to filter by (e.g., "facebook.com", "google.com")
start_dateYesStart date in YYYY-MM-DD format
end_dateYesEnd date in YYYY-MM-DD format
segmentsNoOptional array of segments to include (pages, visitors). Defaults to visitors only. "visitors" gets the total number of visitors from the domain. "pages" get the list of pages and its visited count from the domain.
limitNoOptional limit for results (max 1000)

Implementation Reference

  • The main handler function that executes the tool's logic: parses input arguments, constructs DateRange, calls the ClickyClient's getDomainVisitors method, formats the JSON response, and handles errors.
    export async function handleGetDomainVisitors(
      args: { domain: string; start_date: string; end_date: string; segments?: string[]; limit?: number },
      clickyClient: ClickyClient
    ) {
      try {
        const dateRange: DateRange = {
          startDate: args.start_date,
          endDate: args.end_date
        };
    
        const data = await clickyClient.getDomainVisitors(args.domain, dateRange, args.segments, args.limit);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(data, null, 2)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching domain visitors: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • The tool definition object including the input schema for validating tool call parameters: domain (required), start_date/end_date (YYYY-MM-DD required), optional segments (pages/visitors), and limit.
    export const getDomainVisitorsTool: Tool = {
      name: 'get_domain_visitors',
      description: 'Get visitors filtered by domain from Clicky analytics with optional segmentation data',
      inputSchema: {
        type: 'object',
        properties: {
          domain: {
            type: 'string',
            description: 'Domain name to filter by (e.g., "facebook.com", "google.com")'
          },
          start_date: {
            type: 'string',
            pattern: '^\\d{4}-\\d{2}-\\d{2}$',
            description: 'Start date in YYYY-MM-DD format'
          },
          end_date: {
            type: 'string',
            pattern: '^\\d{4}-\\d{2}-\\d{2}$',
            description: 'End date in YYYY-MM-DD format'
          },
          segments: {
            type: 'array',
            items: {
              type: 'string',
              enum: ['pages', 'visitors']
            },
            description: 'Optional array of segments to include (pages, visitors). Defaults to visitors only. "visitors" gets the total number of visitors from the domain. "pages" get the list of pages and its visited count from the domain.'
          },
          limit: {
            type: 'number',
            minimum: 1,
            maximum: 1000,
            description: 'Optional limit for results (max 1000)'
          }
        },
        required: ['domain', 'start_date', 'end_date']
      }
    };
  • src/index.ts:91-99 (registration)
    Registration of the getDomainVisitorsTool in the list of available tools for the ListToolsRequestHandler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        getTotalVisitorsTool,
        getDomainVisitorsTool,
        getTopPagesTool,
        getTrafficSourcesTool,
        getPageTrafficTool,
      ],
    }));
  • src/index.ts:109-110 (registration)
    Dispatch/registration of the handler for 'get_domain_visitors' tool calls in the CallToolRequestHandler switch statement.
    case 'get_domain_visitors':
      return await handleGetDomainVisitors(args as any, this.clickyClient);
  • Supporting ClickyClient method that performs the actual API request to fetch domain visitors data using segmentation endpoint.
    async getDomainVisitors(domain: string, dateRange: DateRange, segments?: string[], limit?: number): Promise<any> {
      this.validateDateRange(dateRange);
    
      const params: any = {
        site_id: this.siteId,
        sitekey: this.siteKey,
        type: 'segmentation',
        domain: domain,
        segments: segments ? segments.join(',') : 'visitors',
        date: `${dateRange.startDate},${dateRange.endDate}`,
        output: 'json'
      };
    
      if (limit) {
        params.limit = Math.min(limit, 1000); // API max is 1000
      }
    
      const response = await this.client.get('', { params });
    
      return response.data;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it 'gets' data, implying a read-only operation without confirming safety or permissions. It mentions optional segmentation but doesn't disclose behavioral traits like rate limits, authentication needs, or what happens if parameters are invalid. This leaves significant gaps for a tool with 5 parameters.

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 a single, efficient sentence that front-loads the core purpose ('Get visitors filtered by domain') and adds a useful detail ('with optional segmentation data'). There is zero waste, and every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a tool with 5 parameters. It doesn't explain return values, error conditions, or behavioral constraints like rate limits or authentication requirements. For a data retrieval tool in analytics, more context is needed to use it effectively.

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 description coverage is 100%, so the schema fully documents all 5 parameters. The description adds minimal value beyond the schema by mentioning 'optional segmentation data', which loosely relates to the 'segments' parameter but doesn't provide additional meaning or context. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('visitors filtered by domain from Clicky analytics'), specifying the filtering mechanism. It distinguishes from siblings like 'get_total_visitors' by mentioning domain filtering, but doesn't explicitly contrast with 'get_traffic_sources' or 'get_page_traffic' which might also involve visitor data.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives like 'get_total_visitors' or 'get_traffic_sources' is provided. The description mentions optional segmentation data but doesn't clarify when segmentation is beneficial or when other tools might be more appropriate.

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/colintoh/clicky-mcp'

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