Skip to content

query_prometheus: omitted endTime fails with a PromQL parser error #1344

Closed

Description

@MehmetSecgin

What happened?

When a client calls query_prometheus without endTime, the tool returns parsing end time: syntax error: unexpected $end, expecting tNOW or tDIGIT at character 2 starting with "". The parameter is marked required, so as in #252 the client is at fault, but the message reads like a broken PromQL expression and the model rewrites the query instead of adding the time. In our logs this caused four failed retries across two agents, each swapping the metric name. Expected: endTime defaults to now (as parseEndTime already does for the label and metric-name tools), or the error names the missing argument, such as endTime is required.

Steps to reproduce

  1. Call query_prometheus with {"datasourceUid":"<prometheus uid>","expr":"up","queryType":"instant"}
  2. Observe parsing end time: syntax error: unexpected $end, expecting tNOW or tDIGIT at character 2 starting with ""
  3. Add "endTime":"now": the same call succeeds

Reproduced on v2.0.2 built from source with a stubbed Prometheus datasource. Still present on main at 5ea0cc3: tools/prometheus.go:136 passes args.EndTime straight to parseTime, which fails on an empty string.

mcp-grafana version

v2.0.2 (also main at 5ea0cc3)

Grafana version

13.1.1, self-hosted

MCP client

Claude Code 2.1.301

Transport

streamable-http

How did you install it?

Built from source with go build or make build

Operating system and CPU architecture

macOS 26.6.2, arm64

Logs

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions