Skip to main content
Glama
YawLabs

@yawlabs/aws-mcp

Official
by YawLabs

aws_metrics_query

Read-onlyIdempotent

Query CloudWatch metrics across AWS services with multi-metric and expression support, relative time ranges, and automatic period selection.

Instructions

Query CloudWatch metrics via GetMetricData (the modern multi-metric / expression-capable API, not the legacy get-metric-statistics). Pass queries as a flat array of {id, namespace, metricName, dimensions?, statistic?, period?, expression?, label?}; the tool shapes them into MetricDataQueries for you. startTime/endTime accept relative shorthand ('15m', '1h', '1d', '1w'), 'now', or ISO 8601 WITH an explicit offset ('2026-05-16T10:00:00Z' / '...-04:00' -- an offset-less date-time is rejected rather than silently read in the host's local zone; a date-only '2026-05-16' is read as UTC midnight); endTime defaults to 'now'. Period is auto-picked from the time range when omitted (60s for <=3h, 300s for <=24h, 900s for <=15d, 3600s otherwise) to stay under CloudWatch's ~100,800-datapoint response cap. Returns {series: [{id, label?, timestamps, values, period?, statusCode?}], messages?, periodSeconds, profile, region, nextToken, hasMore}. Each series' period is the effective granularity for that query (its explicit period, or the auto-pick it inherited); it is omitted for an expression query that didn't set one. The top-level periodSeconds is always the auto-pick. When CloudWatch truncates a large response, hasMore is true and nextToken carries the resume cursor -- call again with nextToken set to fetch the next page (rare for typical agent queries that stay within the per-request cap). Use for 'show me the CPU on this instance for the last hour', 'sum lambda invocations across these 3 functions', or expression-based 'p99 latency divided by average latency' lookups.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionNoOverride session region for this call.
scanByNoSort order for returned datapoints. Default 'TimestampDescending' (matches CloudWatch's default).
endTimeNoSame forms as startTime: relative shorthand, 'now', or ISO 8601 with an explicit offset. Default 'now'.
profileNoOverride session profile for this call.
queriesYes1-100 queries. Each is either a metric-stat (namespace + metricName) or an expression.
nextTokenNoResume cursor from a previous call's `nextToken`. Omit for the first page. Forwarded as CloudWatch's NextToken; only meaningful when a prior call returned `hasMore: true`.
startTimeNoRelative shorthand ('15m', '1h', '1d', '1w'), 'now', or an ISO 8601 timestamp with an explicit offset ('2026-05-16T10:00:00Z', '2026-05-16T10:00:00-04:00'). A date-only '2026-05-16' is read as UTC midnight; an offset-less date-time is rejected (it would resolve in the server host's local zone). A bare number like '5' is rejected -- write '5m'. Default '1h' (one hour ago).
timeoutMsNoTimeout in milliseconds. Default 60000 (60s).
maxDataPointsNoTarget datapoint count. CloudWatch does not truncate to the first N points -- it widens (coarsens) the period server-side so the series aggregates down to fit this many points. CloudWatch's own ceiling is ~100,800; lower this to make CloudWatch return a coarser, smaller series. Setting it also tells this tool the response is bounded, so a wide range or large batch that would otherwise be rejected locally against that ceiling is passed through (a value ABOVE the ceiling bounds nothing and is still rejected). Forwarded as CloudWatch's MaxDatapoints (single 'p') field; the camelCase schema name follows this server's convention.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.1.0
    • changedInput schema / properties / endTime / description
      Previous value: -"ISO 8601 timestamp or relative shorthand. Default 'now'."New value: +"Same forms as startTime: relative shorthand, 'now', or ISO 8601 with an explicit offset. Default 'now'."
    • changedInput schema / properties / maxDataPoints / description
      Previous value: -"Target datapoint count. CloudWatch does not truncate to the first N points -- it widens (coarsens) the period server-side so the series aggregates down to fit this many points. CloudWatch's own ceiling is ~100,800; lower this to make CloudWatch return a coarser, smaller series. Forwarded as CloudWatch's MaxDatapoints (single 'p') field; the camelCase schema name follows this server's convention."New value: +"Target datapoint count. CloudWatch does not truncate to the first N points -- it widens (coarsens) the period server-side so the series aggregates down to fit this many points. CloudWatch's own ceiling is ~100,800; lower this to make CloudWatch return a coarser, smaller series. Setting it also tells this tool the response is bounded, so a wide range or large batch that would otherwise be rejected locally against that ceiling is passed through (a value ABOVE the ceiling bounds nothing and is still rejected). Forwarded as CloudWatch's MaxDatapoints (single 'p') field; the camelCase schema name follows this server's convention."
    • changedInput schema / properties / startTime / description
      Previous value: -"ISO 8601 timestamp or relative shorthand ('15m', '1h', '1d', '1w'). Default '1h' (one hour ago)."New value: +"Relative shorthand ('15m', '1h', '1d', '1w'), 'now', or an ISO 8601 timestamp with an explicit offset ('2026-05-16T10:00:00Z', '2026-05-16T10:00:00-04:00'). A date-only '2026-05-16' is read as UTC midnight; an offset-less date-time is rejected (it would resolve in the server host's local zone). A bare number like '5' is rejected -- write '5m'. Default '1h' (one hour ago)."
  2. Changed2 schema fields changedv1.5.3
    • changedInput schema / properties / queries / items / properties / expression / description
      Previous value: -"CloudWatch metric math expression, e.g. 'SUM([m1, m2])' or 'AVG(METRICS(\"AWS/Lambda\"))'. Mutually exclusive with namespace/metricName/dimensions."New value: +"CloudWatch metric math expression, e.g. 'SUM([m1, m2])' or 'AVG(METRICS(\"AWS/Lambda\"))'. Mutually exclusive with namespace/metricName/dimensions. Validated server-side by CloudWatch; malformed values surface as a downstream ValidationError rather than a local rejection."
    • changedInput schema / properties / queries / items / properties / unit / description
      Previous value: -"Restrict to a specific Unit (e.g. 'Seconds', 'Bytes'). Default: no filter. Only meaningful on metric-stat queries."New value: +"Restrict to a specific Unit (e.g. 'Seconds', 'Bytes'). Default: no filter. Only meaningful on metric-stat queries. Validated server-side by CloudWatch; malformed values surface as a downstream ValidationError rather than a local rejection."
  3. Changed1 schema field changedv1.5.1
    • changedInput schema / properties / maxDataPoints / description
      Previous value: -"Soft cap on returned datapoints across all queries. CloudWatch's hard cap is ~100,800; lower this to keep response sizes manageable. Forwarded as CloudWatch's MaxDatapoints (single 'p') field; the camelCase schema name follows this server's convention."New value: +"Target datapoint count. CloudWatch does not truncate to the first N points -- it widens (coarsens) the period server-side so the series aggregates down to fit this many points. CloudWatch's own ceiling is ~100,800; lower this to make CloudWatch return a coarser, smaller series. Forwarded as CloudWatch's MaxDatapoints (single 'p') field; the camelCase schema name follows this server's convention."
  4. First observedv1.3.2

TDQS

A5/5.0
Behavior5/5

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

Beyond the readOnly/idempotent annotations, the description thoroughly discloses behavioral details: relative time parsing rules, rejection of offset-less date-times, automatic period selection, response shape, effective vs inherited periods, pagination via nextToken, and server-side period widening for maxDataPoints. This gives the agent an unusually complete model of how the tool behaves before calling it.

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 long but densely packed with actionable information and is well organized: API identity, query shape, time semantics, period auto-pick, response format, pagination, and example queries. Every sentence adds a behavioral or semantic detail that an agent needs, and the most important scoping information appears first.

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?

Despite having no output schema, the description fully documents the return shape, including per-series period semantics, top-level periodSeconds, statusCode, and pagination fields. It also covers edge cases like date-only input, offset-less rejection, and maxDataPoints ceiling behavior. Given the tool's complexity, the description is complete enough for correct invocation.

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

Parameters5/5

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

Even though schema coverage is 100%, the description adds significant semantic value beyond the schema: exact period auto-pick thresholds, detailed startTime/endTime format rules, mutual exclusivity between expression and namespace/metricName, and the counterintuitive maxDataPoints behavior where CloudWatch coarsens the period rather than truncating points. This is rich, non-redundant parameter guidance.

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 opens with a specific verb and resource: 'Query CloudWatch metrics via GetMetricData'. It also distinguishes this from the legacy get-metric-statistics API and gives concrete example use cases ('show me the CPU on this instance', 'sum lambda invocations across these 3 functions'). This makes the tool's purpose unmistakable and differentiates it from any alternative.

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 explicitly states when to use the tool: for single-metric queries, multi-metric queries, and expression-based metric math. It explicitly contrasts with the legacy get-metric-statistics API, and the 'Use for' examples give an agent direct pattern-matching guidance. No other sibling tool handles CloudWatch metrics, so the usage boundary is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.