Skip to main content
Glama

Query Time-Series Data

tacit_timeseries
Read-onlyIdempotent

Query historical sensor data for building equipment using timeseries IDs, with options for time ranges and aggregation functions to analyze trends.

Instructions

Query historical or live sensor data for one or more points.

Points are identified by their timeseriesId (UUID). Use tacit_graphql first to find points and their timeseriesId values.

Args:

  • site_id (string, required): The site ID

  • point_ids (string, required): Comma-separated timeseriesId UUIDs (max 200)

  • start (string, optional): Start time, relative like "-1h", "-24h", "-7d" or ISO 8601. Default: "-1h"

  • end (string, optional): End time, "now()" or ISO 8601. Default: "now()"

  • window (string, optional): Aggregation window like "5m", "1h", "1d". Only with aggregate.

  • aggregate (string, optional): Aggregation function: mean, min, max, sum, count, first, last. Default: "mean"

  • limit (number, optional): Max records per point (1-10000). Default: 1000

Common patterns:

  • Last hour raw: start="-1h" (default)

  • Daily averages for a week: start="-7d", window="1d", aggregate="mean"

  • Last 24h at 15-min intervals: start="-24h", window="15m"

For current/live values, use tacit_graphql with the currentValue { value timestamp quality } field on Point instead of this tool.

Returns: Array of series, each with timeseriesId, name, type, unit, equipment, and data records [{t, v}].

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
site_idYesSite ID
point_idsYesComma-separated timeseriesId UUIDs (from tacit_graphql Point.timeseriesId)
startNoStart time: "-1h", "-24h", "-7d", or ISO 8601
endNoEnd time: "now()" or ISO 8601. Default: "now()"
windowNoAggregation window: "5m", "1h", "1d"
aggregateNoAggregation: mean, min, max, sum, count, first, last
limitNoMax records per point (1-10000)

Implementation Reference

  • Registration of the 'tacit_timeseries' tool.
      server.registerTool(
        "tacit_timeseries",
        {
          title: "Query Time-Series Data",
          description: `Query historical or live sensor data for one or more points.
    
    Points are identified by their timeseriesId (UUID). Use tacit_graphql first to find points and their timeseriesId values.
    
    Args:
      - site_id (string, required): The site ID
      - point_ids (string, required): Comma-separated timeseriesId UUIDs (max 200)
      - start (string, optional): Start time, relative like "-1h", "-24h", "-7d" or ISO 8601. Default: "-1h"
      - end (string, optional): End time, "now()" or ISO 8601. Default: "now()"
      - window (string, optional): Aggregation window like "5m", "1h", "1d". Only with aggregate.
      - aggregate (string, optional): Aggregation function: mean, min, max, sum, count, first, last. Default: "mean"
      - limit (number, optional): Max records per point (1-10000). Default: 1000
    
    Common patterns:
      - Last hour raw: start="-1h" (default)
      - Daily averages for a week: start="-7d", window="1d", aggregate="mean"
      - Last 24h at 15-min intervals: start="-24h", window="15m"
    
    For current/live values, use tacit_graphql with the currentValue { value timestamp quality } field on Point instead of this tool.
    
    Returns: Array of series, each with timeseriesId, name, type, unit, equipment, and data records [{t, v}].`,
          inputSchema: {
            site_id: z.string().describe("Site ID"),
            point_ids: z
              .string()
              .describe("Comma-separated timeseriesId UUIDs (from tacit_graphql Point.timeseriesId)"),
            start: z.string().optional().describe('Start time: "-1h", "-24h", "-7d", or ISO 8601'),
            end: z.string().optional().describe('End time: "now()" or ISO 8601. Default: "now()"'),
            window: z.string().optional().describe('Aggregation window: "5m", "1h", "1d"'),
            aggregate: z
              .string()
              .optional()
              .describe("Aggregation: mean, min, max, sum, count, first, last"),
            limit: z.number().optional().describe("Max records per point (1-10000)"),
          },
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: true,
          },
        },
        async ({ site_id, point_ids, start, end, window, aggregate, limit }) => {
          try {
            const ids = point_ids.split(",").map((s) => s.trim()).filter(Boolean);
            if (ids.length === 0) {
              return {
                content: [{ type: "text" as const, text: "Error: No point IDs provided." }],
                isError: true,
              };
            }
    
            const body: Record<string, unknown> = { timeseriesIds: ids };
            if (start) body.start = start;
            if (end) body.end = end;
            if (window) body.window = window;
            if (aggregate) body.aggregate = aggregate;
            if (limit) body.limit = limit;
    
            const data = await restPost<TimeseriesResponse>(
              `/api/sites/${site_id}/timeseries`,
              body,
            );
    
            if (!data.series.length && Object.keys(data.errors).length) {
              const errLines = Object.entries(data.errors).map(
                ([id, msg]) => `- ${id}: ${msg}`,
              );
              return {
                content: [
                  {
                    type: "text" as const,
                    text: `No data returned. Errors:\n${errLines.join("\n")}`,
                  },
                ],
              };
            }
    
            const lines: string[] = [];
            lines.push(`# Time-Series Data (${data.query.start} → ${data.query.end})`);
            if (data.query.window) {
              lines.push(`Aggregation: ${data.query.aggregate} every ${data.query.window}`);
            }
            lines.push("");
    
            for (const s of data.series) {
              const unit = s.unit ? ` (${s.unit})` : "";
              lines.push(`## ${s.name}${unit}`);
              lines.push(`Type: ${s.type} | Equipment: ${s.equipment}`);
              if (s.data.length === 0) {
                lines.push("_No data in range_");
              } else if (s.data.length <= 20) {
                for (const d of s.data) {
                  const time = d.t ? new Date(d.t).toISOString() : "N/A";
                  lines.push(`- ${time}: ${d.v ?? "null"}`);
                }
              } else {
                // Summarize large datasets
                const values = s.data.filter((d) => d.v != null).map((d) => d.v as number);
                const first = s.data[0];
                const last = s.data[s.data.length - 1];
                lines.push(`${s.data.length} records`);
                lines.push(
                  `- First: ${first.t ? new Date(first.t).toISOString() : "N/A"} → ${first.v}`,
                );
                lines.push(
                  `- Last: ${last.t ? new Date(last.t).toISOString() : "N/A"} → ${last.v}`,
                );
                if (values.length) {
                  lines.push(`- Min: ${Math.min(...values)}`);
                  lines.push(`- Max: ${Math.max(...values)}`);
                  lines.push(
                    `- Avg: ${(values.reduce((a, b) => a + b, 0) / values.length).toFixed(2)}`,
                  );
                }
              }
              lines.push("");
            }
    
            if (Object.keys(data.errors).length) {
              lines.push("## Errors");
              for (const [id, msg] of Object.entries(data.errors)) {
                lines.push(`- ${id}: ${msg}`);
              }
            }
    
            return { content: [{ type: "text" as const, text: lines.join("\n") }] };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
              isError: true,
            };
          }
        },
      );
  • The handler function for 'tacit_timeseries' which processes the request, calls the backend API, and formats the result.
    async ({ site_id, point_ids, start, end, window, aggregate, limit }) => {
      try {
        const ids = point_ids.split(",").map((s) => s.trim()).filter(Boolean);
        if (ids.length === 0) {
          return {
            content: [{ type: "text" as const, text: "Error: No point IDs provided." }],
            isError: true,
          };
        }
    
        const body: Record<string, unknown> = { timeseriesIds: ids };
        if (start) body.start = start;
        if (end) body.end = end;
        if (window) body.window = window;
        if (aggregate) body.aggregate = aggregate;
        if (limit) body.limit = limit;
    
        const data = await restPost<TimeseriesResponse>(
          `/api/sites/${site_id}/timeseries`,
          body,
        );
    
        if (!data.series.length && Object.keys(data.errors).length) {
          const errLines = Object.entries(data.errors).map(
            ([id, msg]) => `- ${id}: ${msg}`,
          );
          return {
            content: [
              {
                type: "text" as const,
                text: `No data returned. Errors:\n${errLines.join("\n")}`,
              },
            ],
          };
        }
    
        const lines: string[] = [];
        lines.push(`# Time-Series Data (${data.query.start} → ${data.query.end})`);
        if (data.query.window) {
          lines.push(`Aggregation: ${data.query.aggregate} every ${data.query.window}`);
        }
        lines.push("");
    
        for (const s of data.series) {
          const unit = s.unit ? ` (${s.unit})` : "";
          lines.push(`## ${s.name}${unit}`);
          lines.push(`Type: ${s.type} | Equipment: ${s.equipment}`);
          if (s.data.length === 0) {
            lines.push("_No data in range_");
          } else if (s.data.length <= 20) {
            for (const d of s.data) {
              const time = d.t ? new Date(d.t).toISOString() : "N/A";
              lines.push(`- ${time}: ${d.v ?? "null"}`);
            }
          } else {
            // Summarize large datasets
            const values = s.data.filter((d) => d.v != null).map((d) => d.v as number);
            const first = s.data[0];
            const last = s.data[s.data.length - 1];
            lines.push(`${s.data.length} records`);
            lines.push(
              `- First: ${first.t ? new Date(first.t).toISOString() : "N/A"} → ${first.v}`,
            );
            lines.push(
              `- Last: ${last.t ? new Date(last.t).toISOString() : "N/A"} → ${last.v}`,
            );
            if (values.length) {
              lines.push(`- Min: ${Math.min(...values)}`);
              lines.push(`- Max: ${Math.max(...values)}`);
              lines.push(
                `- Avg: ${(values.reduce((a, b) => a + b, 0) / values.length).toFixed(2)}`,
              );
            }
          }
          lines.push("");
        }
    
        if (Object.keys(data.errors).length) {
          lines.push("## Errors");
          for (const [id, msg] of Object.entries(data.errors)) {
            lines.push(`- ${id}: ${msg}`);
          }
        }
    
        return { content: [{ type: "text" as const, text: lines.join("\n") }] };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    },
  • Input schema definition for the 'tacit_timeseries' tool.
    inputSchema: {
      site_id: z.string().describe("Site ID"),
      point_ids: z
        .string()
        .describe("Comma-separated timeseriesId UUIDs (from tacit_graphql Point.timeseriesId)"),
      start: z.string().optional().describe('Start time: "-1h", "-24h", "-7d", or ISO 8601'),
      end: z.string().optional().describe('End time: "now()" or ISO 8601. Default: "now()"'),
      window: z.string().optional().describe('Aggregation window: "5m", "1h", "1d"'),
      aggregate: z
        .string()
        .optional()
        .describe("Aggregation: mean, min, max, sum, count, first, last"),
      limit: z.number().optional().describe("Max records per point (1-10000)"),
    },
Behavior4/5

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

Annotations already declare readOnlyHint=true, openWorldHint=true, idempotentHint=true, and destructiveHint=false, covering safety and idempotency. The description adds valuable context beyond this: it explains that points are identified by UUIDs, mentions the max limit of 200 point IDs, provides common usage patterns with examples, and describes the return format. While it doesn't detail rate limits or auth needs, it enriches the behavioral understanding significantly.

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 well-structured and front-loaded with the core purpose. It efficiently uses bullet points for parameters and common patterns, avoiding redundancy. Every sentence adds value, such as clarifying sibling tool relationships and providing usage examples, with no wasted words.

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

Completeness5/5

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

Given the tool's complexity (7 parameters, 2 required) and rich annotations, the description is highly complete. It covers purpose, usage guidelines, parameter details, behavioral context, and return values. Although there's no output schema, the description specifies the return format ('Array of series, each with timeseriesId, name, type, unit, equipment, and data records [{t, v}]'), filling that gap effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds meaningful semantics: it clarifies that point_ids are 'comma-separated timeseriesId UUIDs (max 200)', provides default values for optional parameters (e.g., start: '-1h', end: 'now()', aggregate: 'mean'), and gives practical examples like 'Last hour raw: start="-1h" (default)'. This enhances understanding beyond the schema's basic descriptions.

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 tool's purpose: 'Query historical or live sensor data for one or more points.' It specifies the resource (sensor data/points), the action (query), and distinguishes it from sibling tools by mentioning that point IDs come from 'tacit_graphql' and that for current/live values, 'tacit_graphql' should be used instead. This provides specific verb+resource differentiation.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives. It states: 'Use tacit_graphql first to find points and their timeseriesId values' and 'For current/live values, use tacit_graphql with the currentValue { value timestamp quality } field on Point instead of this tool.' This clearly defines prerequisites and exclusions, helping the agent choose correctly.

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/ucl-sbde/tacit-mcp'

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