Skip to main content
Glama
Defilan

Plausible Analytics MCP Server

by Defilan

get-current-visitors

Retrieve the real-time count of active visitors on a website. Monitor live traffic for any domain to gauge current engagement.

Instructions

Get the number of people currently on a site (real-time)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
site_idYesDomain of the site (e.g. 'example.com')

Implementation Reference

  • src/index.ts:42-61 (registration)
    Registration (and handler) of the 'get-current-visitors' MCP tool using server.tool(). Defines input schema with 'site_id' string parameter and calls client.getCurrentVisitors().
    // --- Tool: get-current-visitors ---
    
    server.tool(
      "get-current-visitors",
      "Get the number of people currently on a site (real-time)",
      {
        site_id: z.string().describe("Domain of the site (e.g. 'example.com')"),
      },
      async ({ site_id }) => {
        const visitors = await client.getCurrentVisitors(site_id);
        return {
          content: [
            {
              type: "text",
              text: `Current visitors on ${site_id}: ${visitors}`,
            },
          ],
        };
      }
    );
  • Actual implementation of getCurrentVisitors() in PlausibleClient. Makes a GET request to Plausible's real-time visitors API endpoint and returns the visitor count as a number.
    async getCurrentVisitors(siteId: string): Promise<number> {
      const response = await fetch(
        `${this.baseUrl}/api/v1/stats/realtime/visitors?site_id=${encodeURIComponent(siteId)}`,
        {
          headers: {
            Authorization: `Bearer ${this.apiKey}`,
          },
        }
      );
    
      if (!response.ok) {
        const body = await response.text();
        throw new Error(
          `Plausible API error (${response.status}): ${body}`
        );
      }
    
      return response.json() as Promise<number>;
    }
Behavior3/5

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

With no annotations, the description must cover behavioral traits. It states it returns a real-time count, which implies non-destructive read. However, it omits details like error handling (e.g., invalid site_id), rate limits, or whether the count is approximate. Basic transparency but lacks depth.

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 action and resource.

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

Completeness3/5

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

The tool is simple (one param, no output schema), but the description does not specify the return format (e.g., integer, object). No mention of edge cases or performance. Adequate but could be more complete given the lack of output schema.

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?

Schema coverage is 100%, and the parameter site_id has its own description. The tool description does not add new meaning beyond the schema, so baseline 3 applies. No extra constraints or context provided.

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' and the resource 'number of people currently on a site', adding 'real-time' to specify immediacy. This distinguishes it from sibling tools like get-aggregate-stats (likely historical) or get-breakdown.

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?

No guidance is provided on when to use this tool versus alternatives. There is no mention of prerequisites, exclusions, or comparison with sibling tools like get-timeseries or query.

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/Defilan/plausible-mcp'

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