Skip to main content
Glama
nks-hub

rybbit-mcp

by nks-hub

Live User Count

rybbit_live_users
Read-onlyIdempotent

Retrieve the current number of live users on a website by providing the site ID. Get real-time active user count for analytics.

Instructions

Get the current number of live/active users on a site in real-time

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteIdYesSite ID (numeric ID or domain identifier)

Implementation Reference

  • The handler function for the rybbit_live_users tool. It calls client.get on /sites/{siteId}/live-user-count to fetch the live user count from the API, and returns the response wrapped in MCP content.
    async (args) => {
      try {
        const count = await client.get<number>(
          `/sites/${args.siteId}/live-user-count`
        );
    
        return {
          content: [
            {
              type: "text" as const,
              text: truncateResponse({ liveUsers: count }),
            },
          ],
        };
      } catch (err) {
        const message = err instanceof Error ? err.message : String(err);
        return {
          content: [{ type: "text" as const, text: `Error: ${message}` }],
          isError: true,
        };
      }
    }
  • The input schema for rybbit_live_users. It defines siteId using the shared siteIdSchema, plus title, description, and annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint).
    {
      title: "Live User Count",
      description:
        "Get the current number of live/active users on a site in real-time",
      inputSchema: {
        siteId: siteIdSchema,
      },
      annotations: {
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
  • Registration of the rybbit_live_users tool via server.registerTool() with name 'rybbit_live_users', its schema, and the handler function. This is inside the registerOverviewTools() function.
    server.registerTool(
      "rybbit_live_users",
      {
        title: "Live User Count",
        description:
          "Get the current number of live/active users on a site in real-time",
        inputSchema: {
          siteId: siteIdSchema,
        },
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: true,
        },
      },
      async (args) => {
        try {
          const count = await client.get<number>(
            `/sites/${args.siteId}/live-user-count`
          );
    
          return {
            content: [
              {
                type: "text" as const,
                text: truncateResponse({ liveUsers: count }),
              },
            ],
          };
        } catch (err) {
          const message = err instanceof Error ? err.message : String(err);
          return {
            content: [{ type: "text" as const, text: `Error: ${message}` }],
            isError: true,
          };
        }
      }
    );
  • src/index.ts:39-48 (registration)
    Top-level registration: registerOverviewTools(server, client) is called in the main entrypoint, which wires up the rybbit_live_users tool as part of the MCP server.
    registerOverviewTools(server, client);
    registerMetricsTools(server, client);
    registerSessionsTools(server, client);
    registerUsersTools(server, client);
    registerEventsTools(server, client);
    registerErrorsTools(server, client);
    registerPerformanceTools(server, client);
    registerFunnelsTools(server, client);
    registerGoalsTools(server, client);
    registerJourneysTools(server, client);
  • The RybbitClient.get<T>() method used by the handler to make the HTTP GET request to /sites/{siteId}/live-user-count.
    async get<T>(path: string, params?: QueryParams): Promise<T> {
      const url = this.buildUrl(path, params);
      return this.request<T>("GET", url);
    }
    
    async post<T>(path: string, body?: unknown, params?: QueryParams): Promise<T> {
      const url = this.buildUrl(path, params);
      return this.request<T>("POST", url, body);
    }
    
    async put<T>(path: string, body?: unknown, params?: QueryParams): Promise<T> {
      const url = this.buildUrl(path, params);
      return this.request<T>("PUT", url, body);
    }
    
    async delete<T>(path: string, params?: QueryParams): Promise<T> {
      const url = this.buildUrl(path, params);
      return this.request<T>("DELETE", url);
    }
    
    private buildUrl(path: string, params?: QueryParams): string {
      const base = `${this.config.baseUrl}/api${path}`;
      if (!params) return base;
    
      const searchParams = new URLSearchParams();
      for (const [key, value] of Object.entries(params)) {
        if (value !== undefined && value !== null && value !== "") {
          searchParams.set(key, String(value));
        }
      }
    
      const qs = searchParams.toString();
      return qs ? `${base}?${qs}` : base;
    }
    
    private async request<T>(
      method: string,
      url: string,
      body?: unknown,
      isRetry = false
    ): Promise<T> {
      const auth = await getAuthHeaders(this.config, this.sessionCookie);
      const headers = auth.headers;
      this.sessionCookie = auth.sessionCookie;
    
      // Remove Content-Type for requests without body (DELETE, GET)
      if (!body) {
        delete headers["Content-Type"];
      }
    
      const controller = new AbortController();
      const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
    
      let res: Response;
      try {
        res = await fetch(url, {
          method,
          headers,
          body: body ? JSON.stringify(body) : undefined,
          signal: controller.signal,
        });
      } catch (err) {
        clearTimeout(timeout);
        if (err instanceof DOMException && err.name === "AbortError") {
          throw new Error(
            `Request timed out after ${REQUEST_TIMEOUT_MS / 1000}s. Try narrowing the date range or adding filters.`
          );
        }
        throw err;
      } finally {
        clearTimeout(timeout);
      }
    
      if (res.status === 401 && !isRetry && this.config.email) {
        this.sessionCookie = null;
        return this.request<T>(method, url, body, true);
      }
    
      if (!res.ok) {
        const text = await res.text().catch(() => "");
        throw new Error(formatApiError(res.status, text));
      }
    
      const contentType = res.headers.get("content-type") ?? "";
      if (contentType.includes("application/json")) {
        return (await res.json()) as T;
      }
    
      return (await res.text()) as unknown as T;
    }
    
    buildAnalyticsParams(options: {
      startDate?: string;
      endDate?: string;
      timeZone?: string;
      filters?: FilterParam[];
      pastMinutesStart?: number;
      pastMinutesEnd?: number;
      bucket?: string;
      page?: number;
      limit?: number;
      offset?: number;
    }): QueryParams {
      const params: QueryParams = {};
    
      if (options.startDate) params.start_date = options.startDate;
      if (options.endDate) params.end_date = options.endDate;
      if (options.timeZone) params.time_zone = options.timeZone;
      if (options.filters && options.filters.length > 0) {
        params.filters = JSON.stringify(options.filters);
      }
      if (options.pastMinutesStart !== undefined)
        params.past_minutes_start = options.pastMinutesStart;
      if (options.pastMinutesEnd !== undefined)
        params.past_minutes_end = options.pastMinutesEnd;
      if (options.bucket) params.bucket = options.bucket;
      if (options.page !== undefined) params.page = options.page;
      if (options.limit !== undefined) params.limit = options.limit;
      if (options.offset !== undefined) params.offset = options.offset;
    
      return params;
    }
Behavior3/5

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

Annotations already declare readOnlyHint, destructiveHint, and idempotentHint true, so the safety profile is clear. The description adds 'real-time' context, which is helpful, but lacks details on behavior like caching, rate limits, or authentication requirements. With strong annotations, the description adds modest value.

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 concise sentence with no wasted words. It is front-loaded with the core action and resource, making it easy for an AI agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only tool with one parameter and strong annotations, the description adequately conveys the purpose and usage context. It could optionally mention the output format (e.g., returns a number), but this is not critical given the simplicity.

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?

Input schema covers the single parameter siteId with a description, achieving 100% schema coverage. The description does not add further meaning beyond what the schema provides, so baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get', the resource 'current number of live/active users', and the context 'on a site in real-time'. It distinguishes itself from siblings like rybbit_get_metric (historical) and rybbit_list_users (list of users, not live count).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for real-time active user count, but it does not provide explicit guidance on when to use this tool versus alternatives (e.g., rybbit_get_metric for historical data). No when-not-to-use or alternative references are given.

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/nks-hub/rybbit-mcp'

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