list-sites
Retrieve all analytics sites from your Fathom Analytics account to manage and monitor website performance data.
Instructions
List all Fathom Analytics sites on the account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Optional limit on the number of sites to return |
Implementation Reference
- src/tools/sites.ts:12-50 (handler)Handler function that executes the 'list-sites' tool logic: fetches sites from Fathom Analytics API, formats the list or handles empty/error cases.async ({ limit }) => { try { const sites = await fathomClient.api.getAllSites(limit); if (sites.length === 0) { return { content: [ { type: "text", text: "No sites found.", }, ], }; } const sitesText = sites.map(site => `ID: ${site.id}\nName: ${site.name}\nSharing: ${site.sharing}\nCreated: ${site.created_at}\n` ).join("\n---\n\n"); return { content: [ { type: "text", text: `Sites (${sites.length}):\n\n${sitesText}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to retrieve sites: ${error instanceof FathomApiError ? `${error.status}: ${error.error}` : String(error)}`, }, ], }; } }, );
- src/tools/sites.ts:10-11 (schema)Input schema for the 'list-sites' tool, defining an optional positive integer limit using Zod.limit: z.number().positive().optional().describe("Optional limit on the number of sites to return") },
- src/tools/sites.ts:5-51 (registration)Registration of the 'list-sites' tool via server.tool() call within the registerSitesTool function.export function registerSitesTool(server: McpServer, fathomClient: FathomApi): void { server.tool( "list-sites", "List all Fathom Analytics sites on the account", { limit: z.number().positive().optional().describe("Optional limit on the number of sites to return") }, async ({ limit }) => { try { const sites = await fathomClient.api.getAllSites(limit); if (sites.length === 0) { return { content: [ { type: "text", text: "No sites found.", }, ], }; } const sitesText = sites.map(site => `ID: ${site.id}\nName: ${site.name}\nSharing: ${site.sharing}\nCreated: ${site.created_at}\n` ).join("\n---\n\n"); return { content: [ { type: "text", text: `Sites (${sites.length}):\n\n${sitesText}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to retrieve sites: ${error instanceof FathomApiError ? `${error.status}: ${error.error}` : String(error)}`, }, ], }; } }, ); }
- src/index.ts:34-34 (registration)Top-level call to register the sites tool during MCP server setup.registerSitesTool(server, fathomClient);