Skip to main content
Glama
colintoh
by colintoh
get-page-traffic.ts1.56 kB
import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { ClickyClient, DateRange } from '../clicky-client.js'; export const getPageTrafficTool: Tool = { name: 'get_page_traffic', description: 'Get traffic data for a specific page by filtering with its URL', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'Full URL or path of the page to get traffic for (e.g., https://example.com/path or /path)' }, 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: ['url', 'start_date', 'end_date'] } }; export async function handleGetPageTraffic( args: { url: string; start_date: string; end_date: string }, clickyClient: ClickyClient ) { try { const dateRange: DateRange = { startDate: args.start_date, endDate: args.end_date }; const data = await clickyClient.getPageTraffic(args.url, dateRange); return { content: [ { type: 'text', text: JSON.stringify(data, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching page traffic: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }

Implementation Reference

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