list-sites
Retrieve a list of all websites you have access to in Plausible Analytics for quick navigation and management.
Instructions
List all sites you have access to in Plausible Analytics
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list-sites"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:25-40 (handler)The 'list-sites' tool registration and handler. Calls client.listSites() and returns the result as JSON text.
server.tool( "list-sites", "List all sites you have access to in Plausible Analytics", {}, async () => { const sites = await client.listSites(); return { content: [ { type: "text", text: JSON.stringify(sites, null, 2), }, ], }; } ); - src/plausible-client.ts:101-130 (helper)The listSites() method on PlausibleClient that calls the Plausible API v1 /api/v1/sites endpoint with pagination, collecting and returning all sites.
async listSites(): Promise<PlausibleSite[]> { const sites: PlausibleSite[] = []; let hasMore = true; let page = 1; while (hasMore) { const response = await fetch( `${this.baseUrl}/api/v1/sites?page=${page}&limit=100`, { headers: { Authorization: `Bearer ${this.apiKey}`, }, } ); if (!response.ok) { const body = await response.text(); throw new Error( `Plausible API error (${response.status}): ${body}` ); } const data = (await response.json()) as { sites: PlausibleSite[] }; sites.push(...data.sites); hasMore = data.sites.length === 100; page++; } return sites; } - src/plausible-client.ts:47-50 (schema)The PlausibleSite interface used as the return type for listSites(), containing domain and timezone.
export interface PlausibleSite { domain: string; timezone: string; } - src/index.ts:25-40 (registration)Registration of the 'list-sites' tool using server.tool() on the McpServer instance. No input schema (empty object {}) since no parameters are needed.
server.tool( "list-sites", "List all sites you have access to in Plausible Analytics", {}, async () => { const sites = await client.listSites(); return { content: [ { type: "text", text: JSON.stringify(sites, null, 2), }, ], }; } );