Skip to main content
Glama
mikusnuz

umami-mcp

get_sessions

Retrieve website session data filtered by date range, search query, pagination, and sorting parameters.

Instructions

Get session data for a website

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
websiteIdYesWebsite UUID
startAtYesStart timestamp in milliseconds
endAtYesEnd timestamp in milliseconds
queryNoSearch query
pageNoPage number (1-based)
pageSizeNoResults per page
orderByNoField to order by

Implementation Reference

  • The 'get_sessions' tool handler function that calls the Umami API to retrieve session data for a website. It accepts websiteId, startAt, endAt, and optional query, page, pageSize, and orderBy parameters, then makes a GET request to /api/websites/{websiteId}/sessions.
    server.tool(
      "get_sessions",
      "Get session data for a website",
      {
        websiteId: z.string().describe("Website UUID"),
        ...dateRange,
        query: z.string().optional().describe("Search query"),
        page: z.number().optional().describe("Page number (1-based)"),
        pageSize: z.number().optional().describe("Results per page"),
        orderBy: z.string().optional().describe("Field to order by"),
      },
      async ({ websiteId, startAt, endAt, query, page, pageSize, orderBy }) => {
        const data = await client.call("GET", `/api/websites/${websiteId}/sessions`, undefined, {
          startAt,
          endAt,
          query,
          page,
          pageSize,
          orderBy,
        });
        return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
      }
    );
  • The Zod schema defining the input parameters for the 'get_sessions' tool: websiteId (required string), startAt/endAt (required numbers from dateRange spread), and optional query, page, pageSize, orderBy.
    {
      websiteId: z.string().describe("Website UUID"),
      ...dateRange,
      query: z.string().optional().describe("Search query"),
      page: z.number().optional().describe("Page number (1-based)"),
      pageSize: z.number().optional().describe("Results per page"),
      orderBy: z.string().optional().describe("Field to order by"),
    },
  • The tool is registered via server.tool() call inside registerStatsTools(), which is exported and called from src/index.ts on line 30.
    server.tool(
      "get_sessions",
      "Get session data for a website",
      {
        websiteId: z.string().describe("Website UUID"),
        ...dateRange,
        query: z.string().optional().describe("Search query"),
        page: z.number().optional().describe("Page number (1-based)"),
        pageSize: z.number().optional().describe("Results per page"),
        orderBy: z.string().optional().describe("Field to order by"),
      },
      async ({ websiteId, startAt, endAt, query, page, pageSize, orderBy }) => {
        const data = await client.call("GET", `/api/websites/${websiteId}/sessions`, undefined, {
          startAt,
          endAt,
          query,
          page,
          pageSize,
          orderBy,
        });
        return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
      }
    );
  • The dateRange helper object spread into the schema to provide startAt and endAt timestamp parameters. Also used by other tools in this file.
    const dateRange = {
      startAt: z.number().describe("Start timestamp in milliseconds"),
      endAt: z.number().describe("End timestamp in milliseconds"),
    };
  • The UmamiClient.call() method that actually executes the HTTP request to the Umami API, handling authentication, query parameters, and JSON serialization.
      async call(
        method: string,
        path: string,
        body?: Record<string, unknown>,
        query?: Record<string, string | number | boolean | undefined>
      ): Promise<unknown> {
        this.ensureConfigured();
    
        const token = await this.getToken();
    
        let url = `${this.config.baseUrl}${path}`;
        if (query) {
          const params = new URLSearchParams();
          for (const [k, v] of Object.entries(query)) {
            if (v !== undefined && v !== null && v !== "") {
              params.set(k, String(v));
            }
          }
          const qs = params.toString();
          if (qs) url += `?${qs}`;
        }
    
        const headers: Record<string, string> = {
          Authorization: `Bearer ${token}`,
        };
        if (body) {
          headers["Content-Type"] = "application/json";
        }
    
        const res = await fetch(url, {
          method,
          headers,
          body: body ? JSON.stringify(body) : undefined,
          signal: AbortSignal.timeout(30_000),
        });
    
        if (!res.ok) {
          const text = await res.text().catch(() => "");
          throw new Error(`Umami API error ${method} ${path} (${res.status}): ${text}`);
        }
    
        // Some endpoints return 200 with no body (e.g. DELETE)
        const contentType = res.headers.get("content-type") || "";
        if (contentType.includes("application/json")) {
          return res.json();
        }
        const text = await res.text();
        return text || { success: true };
      }
    }
Behavior2/5

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

No annotations are provided, and the description only states 'Get session data'. It does not disclose read-only nature, response format, pagination, or any side effects. Minimal behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence, but it is too short to convey necessary information. It could be improved without adding much length.

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

Completeness2/5

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

Given 7 parameters, no output schema, and no annotations, the description is incomplete. It lacks details on response structure, pagination, or filtering behavior, which are critical for an AI agent.

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 description coverage is 100%, so baseline is 3. The description adds no additional meaning beyond the schema's parameter descriptions.

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

Purpose3/5

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

The description 'Get session data for a website' is a clear verb+resource but is too generic. It does not distinguish from sibling tools like 'get_session' (singular) or 'get_session_activity', leaving ambiguity about scope.

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 on when to use this tool vs alternatives. The description provides no context for usage or when to prefer it over 'get_session' or 'get_session_stats'.

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/mikusnuz/umami-mcp'

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