Skip to main content
Glama
colintoh
by colintoh

get_total_visitors

Retrieve total visitor counts for a specified date range from Clicky analytics to monitor website traffic performance and analyze audience engagement patterns.

Instructions

Get total visitors for a date range from Clicky analytics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_dateYesEnd date in YYYY-MM-DD format
start_dateYesStart date in YYYY-MM-DD format

Implementation Reference

  • The handleGetTotalVisitors function implements the core logic of the get_total_visitors tool: it constructs a DateRange from input arguments, fetches data using ClickyClient, and returns formatted JSON response or error.
    export async function handleGetTotalVisitors( args: { start_date: string; end_date: string }, clickyClient: ClickyClient ) { try { const dateRange: DateRange = { startDate: args.start_date, endDate: args.end_date }; const data = await clickyClient.getTotalVisitors(dateRange); return { content: [ { type: 'text', text: JSON.stringify(data, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching total visitors: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
  • Tool definition for 'get_total_visitors' including name, description, and input schema requiring start_date and end_date in YYYY-MM-DD format.
    export const getTotalVisitorsTool: Tool = { name: 'get_total_visitors', description: 'Get total visitors for a date range from Clicky analytics', inputSchema: { type: 'object', properties: { 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' } }, required: ['start_date', 'end_date'] } };
  • src/index.ts:91-99 (registration)
    Registers the getTotalVisitorsTool in the MCP server's listTools request handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ getTotalVisitorsTool, getDomainVisitorsTool, getTopPagesTool, getTrafficSourcesTool, getPageTrafficTool, ], }));
  • src/index.ts:105-107 (registration)
    Dispatches calls to 'get_total_visitors' by invoking the handleGetTotalVisitors function in the CallToolRequestSchema handler.
    switch (name) { case 'get_total_visitors': return await handleGetTotalVisitors(args as any, this.clickyClient);
  • ClickyClient.getTotalVisitors method performs the actual API request to Clicky for total visitors data within the specified date range.
    async getTotalVisitors(dateRange: DateRange): Promise<any> { this.validateDateRange(dateRange); const response = await this.client.get('', { params: { site_id: this.siteId, sitekey: this.siteKey, type: 'visitors', date: `${dateRange.startDate},${dateRange.endDate}`, output: 'json' } }); return response.data; }

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