Get Site ID by Domain
rybbit_get_site_idFind the numeric site ID for a domain to query Rybbit Analytics data. Input a domain name to get the identifier needed for API requests.
Instructions
Look up a site by domain name. Returns the numeric siteId used for analytics API queries. Note: for SDK tracking setup, use the hash siteId returned by rybbit_create_site instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain to search for (e.g. 'example.com'). Partial match supported. |
Implementation Reference
- src/tools/config.ts:192-262 (handler)The 'rybbit_get_site_id' tool is registered and implemented in src/tools/config.ts. It fetches organizations, iterates through sites, and returns matches for a given domain.
server.registerTool( "rybbit_get_site_id", { title: "Get Site ID by Domain", description: "Look up a site by domain name. Returns the numeric siteId used for analytics API queries. Note: for SDK tracking setup, use the hash siteId returned by rybbit_create_site instead.", inputSchema: { domain: z .string() .describe( "Domain to search for (e.g. 'example.com'). Partial match supported." ), }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, }, async ({ domain }) => { try { const orgs = await client.get<Organization[]>("/organizations"); const matches: { siteId: string; domain: string; name: string; organization: string }[] = []; for (const org of orgs) { for (const site of org.sites ?? []) { if ( site.domain.toLowerCase().includes(domain.toLowerCase()) || domain.toLowerCase().includes(site.domain.toLowerCase()) ) { matches.push({ siteId: site.id, domain: site.domain, name: site.name, organization: String(org.name), }); } } } if (matches.length === 0) { return { content: [ { type: "text" as const, text: `No site found matching '${domain}'. Use rybbit_list_sites to see all available sites, or rybbit_create_site to create one.`, }, ], }; } return { content: [ { type: "text" as const, text: truncateResponse( matches.length === 1 ? matches[0] : matches ), }, ], }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } } );