Skip to main content
Glama
mackenly

MCP Fathom Analytics

by mackenly

get-current-visitors

Retrieve real-time visitor data for a Fathom Analytics site, including optional content and referrer details for current traffic monitoring.

Instructions

Get current visitors for a Fathom Analytics site

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
site_idYesID of the site to retrieve current visitors for
detailedNoWhether to include detailed content and referrer information

Implementation Reference

  • The asynchronous handler function that executes the tool logic: fetches current visitors from Fathom API based on site_id and optional detailed flag, formats the response as markdown text blocks, handles no visitors and errors.
    async ({ site_id, detailed = false }) => {
        try {
            const visitorsData = await fathomClient.api.reports.currentVisitors({
                site_id,
                detailed
            });
            
            if (visitorsData.total === 0) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `No current visitors for site ${site_id}.`,
                        },
                    ],
                };
            }
    
            let responseText = `Current visitors for site ${site_id}: ${visitorsData.total}\n\n`;
            
            // Include detailed information if available and requested
            if (detailed && visitorsData.content && visitorsData.content.length > 0) {
                responseText += "Top Content:\n";
                visitorsData.content.forEach((item, index) => {
                    responseText += `${index + 1}. ${item.hostname}${item.pathname} - ${item.total} visitor(s)\n`;
                });
                responseText += "\n";
            }
            
            if (detailed && visitorsData.referrers && visitorsData.referrers.length > 0) {
                responseText += "Top Referrers:\n";
                visitorsData.referrers.forEach((item, index) => {
                    responseText += `${index + 1}. ${item.referrer_hostname}${item.referrer_pathname} - ${item.total} visitor(s)\n`;
                });
            }
            
            return {
                content: [
                    {
                        type: "text",
                        text: responseText,
                    },
                ],
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: "text",
                        text: `Failed to retrieve current visitors: ${error instanceof FathomApiError ? `${error.status}: ${error.error}` : String(error)}`,
                    },
                ],
            };
        }
    },
  • Zod input schema defining parameters: required site_id (string) and optional detailed (boolean).
        site_id: z.string().describe("ID of the site to retrieve current visitors for"),
        detailed: z.boolean().optional().describe("Whether to include detailed content and referrer information"),
    },
  • MCP server.tool() registration of the 'get-current-visitors' tool, including name, description, input schema, and handler function.
    server.tool(
        "get-current-visitors",
        "Get current visitors for a Fathom Analytics site",
        {
            site_id: z.string().describe("ID of the site to retrieve current visitors for"),
            detailed: z.boolean().optional().describe("Whether to include detailed content and referrer information"),
        },
        async ({ site_id, detailed = false }) => {
            try {
                const visitorsData = await fathomClient.api.reports.currentVisitors({
                    site_id,
                    detailed
                });
                
                if (visitorsData.total === 0) {
                    return {
                        content: [
                            {
                                type: "text",
                                text: `No current visitors for site ${site_id}.`,
                            },
                        ],
                    };
                }
    
                let responseText = `Current visitors for site ${site_id}: ${visitorsData.total}\n\n`;
                
                // Include detailed information if available and requested
                if (detailed && visitorsData.content && visitorsData.content.length > 0) {
                    responseText += "Top Content:\n";
                    visitorsData.content.forEach((item, index) => {
                        responseText += `${index + 1}. ${item.hostname}${item.pathname} - ${item.total} visitor(s)\n`;
                    });
                    responseText += "\n";
                }
                
                if (detailed && visitorsData.referrers && visitorsData.referrers.length > 0) {
                    responseText += "Top Referrers:\n";
                    visitorsData.referrers.forEach((item, index) => {
                        responseText += `${index + 1}. ${item.referrer_hostname}${item.referrer_pathname} - ${item.total} visitor(s)\n`;
                    });
                }
                
                return {
                    content: [
                        {
                            type: "text",
                            text: responseText,
                        },
                    ],
                };
            } catch (error) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `Failed to retrieve current visitors: ${error instanceof FathomApiError ? `${error.status}: ${error.error}` : String(error)}`,
                        },
                    ],
                };
            }
        },
    );
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves current visitors but doesn't explain what 'current' means (e.g., real-time, last hour), whether it's a read-only operation, if there are rate limits, or what the output format looks like. This leaves significant gaps for a tool that likely involves data retrieval.

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, direct sentence that efficiently conveys the core purpose without any wasted words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 the complexity of retrieving analytics data, no annotations, and no output schema, the description is insufficient. It doesn't cover behavioral aspects like data freshness, permissions, or response structure, leaving the agent with incomplete information to use the tool effectively in context with its siblings.

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?

The input schema has 100% description coverage, clearly documenting both parameters. The description adds no additional semantic context beyond what's in the schema (e.g., it doesn't clarify what 'detailed' information includes or provide examples). This meets the baseline for high schema coverage but doesn't enhance understanding.

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 action ('Get') and resource ('current visitors for a Fathom Analytics site'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list-events' or 'get-aggregation' which might also retrieve visitor-related data, so it doesn't reach the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or compare it to siblings like 'list-events' for historical data or 'get-aggregation' for summarized metrics, leaving the agent with no contextual usage information.

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/mackenly/mcp-fathom-analytics'

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