Skip to main content

runspec-grafana

A Grafana runnable for runspec, ported from the read tools of the Grafana MCP server onto the Grafana HTTP API — not proxying that server. One runnable — grafana — with a verb per tool. pip install it into a venv and it's discoverable by runspec local, runspec serve (MCP), and runspec-console.

runspec serve flattens each verb into a leaf MCP tool (grafana_search-dashboards, grafana_query-prometheus, …).

Install

pip install runspec-grafana

Verbs

All autonomous (read-only) except create-annotation, which is confirm.

Area Verbs
Identity whoami, health
Dashboards search-dashboards, search-folders, get-dashboard, list-dashboard-versions
Datasources list-datasources, get-datasource, check-datasource
Prometheus query-prometheus, query-prometheus-histogram, list-prometheus-metric-names, list-prometheus-label-names, list-prometheus-label-values, list-prometheus-metric-metadata
Loki query-loki-logs, list-loki-label-names, list-loki-label-values, query-loki-stats, query-loki-patterns
Alerting list-alert-rules, get-alert-rule, list-contact-points, list-silences
Annotations get-annotations, get-annotation-tags, create-annotation
Anything else api-get (GET any /api/ path, returned as-is)

PromQL and LogQL run through Grafana's datasource proxy, so only the Grafana token is needed — never the datasource's own credentials. --datasource takes a UID or a name; without it the default (or only) Prometheus or Loki datasource is used.

Output

Results are compact by default, because an agent re-reads every tool result on each later step:

  • get-dashboard returns a summary: folder, tags, variables, and one row per panel. --include queries adds each panel's query text, --panel <id> keeps one panel, --raw returns the full dashboard JSON.
  • query-prometheus --query-type range summarises each series (points, first, last, min, max); --include-values returns every sample.
  • query-loki-logs lists each stream's labels once and gives the lines newest first, each cut to --max-line-chars (500).
  • list-alert-rules puts firing rules first with counts by state; --include alerts adds the active alert instances.
  • Every list takes --limit and says truncated: true when it cut something.

A person at a terminal gets readable text; agents, pipes, the console's Forms tab and schedulers get JSON.

Times accept Unix seconds or milliseconds, RFC 3339, now-1h, or a duration back from now (5m, 1h30m).

Auth — env vars

export GRAFANA_URL=https://grafana.example.com            # default http://127.0.0.1:3000
export GRAFANA_SERVICE_ACCOUNT_TOKEN=glsa_...             # or GRAFANA_TOKEN, or:
export GRAFANA_USERNAME=<user> GRAFANA_PASSWORD=<password>
export GRAFANA_ORG_ID=2                                   # X-Grafana-Org-Id
export GRAFANA_CA_BUNDLE=/etc/pki/internal-ca.pem         # private CA

Use a service account token. The Viewer role covers every read except list-dashboard-versions; that and create-annotation need Editor.

--env <label> reads GRAFANA_<LABEL>_* first (--env prod-eu → GRAFANA_PROD_EU_URL). --url, --org-id and --grafana-token override the environment; the token arg is a password type, so it comes through the runspec-console secret channel and never on a command line. A runspec-console credential labelled Grafana of the token kind supplies GRAFANA_TOKEN, and one of the username + password kind supplies GRAFANA_USERNAME/PASSWORD, with no extra configuration.

Building your own runnables

The logic lives in runspec-grafana-core, which has no runspec dependency and surfaces no runnables. A private package can depend on it alone, build a GrafanaConfig in code, and wrap the helpers as narrower runnables — for example a checkout-errors runnable that runs one fixed LogQL query for a team:

from runspec_grafana_core import config_from_env, query_loki_logs

cfg = config_from_env("prod")
errors = query_loki_logs(cfg, '{app="checkout"} |= "level=error"', start="30m", limit=20)

Metadata

Release files for runspec-grafana 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for runspec-grafana 0.1.0
File Size Uploaded Provenance Actions
runspec_grafana-0.1.0.tar.gz 15.8 kB With provenance Details for runspec_grafana-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for runspec-grafana 0.1.0
File Interpreter ABI Platform Actions
runspec_grafana-0.1.0-py3-none-any.whl Python 3 none any Details for runspec_grafana-0.1.0-py3-none-any.whl

Total release size: 29.3 kB

Release files / runspec_grafana-0.1.0.tar.gz

Download URL runspec_grafana-0.1.0.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9df626b34c5e6339552dacd3f57fefd51567ed0309bf07ed472dce132354a20e
BLAKE2b-256 checksum
How to use checksums
26e3d20c98653f8ab2afe37d63fe812dc54897928bf761a8347ab2ada6cee12f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / runspec_grafana-0.1.0-py3-none-any.whl

Download URL runspec_grafana-0.1.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccf178320ec1928bca9daa0279fa1deb6dbb37a3b4d2fdd21ad55f5d38124b49
BLAKE2b-256 checksum
How to use checksums
a4cc0a47577d6473c4d882e87eaa2c60839f59f820b305f55bcc38c590c555df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Security for runspec-grafana 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for runspec_grafana-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page