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, --grafana-token, --grafana-user and --grafana-password override the environment; the token and password args are password type, so they come through the runspec-console secret channel and never on a command line.

Each auth arg declares the variables above as its env, so runspec-console applies a matching credential with no extra configuration: a token-kind credential labelled Grafana (→ GRAFANA_TOKEN) or Grafana Service Account (→ GRAFANA_SERVICE_ACCOUNT_TOKEN), or a username + password credential labelled Grafana (→ GRAFANA_USERNAME/PASSWORD). The console's Env files window lists the same variables for a venv's .runspec_env.

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.2.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.2.0
File Size Uploaded Provenance Actions
runspec_grafana-0.2.0.tar.gz 17.2 kB With provenance Details for runspec_grafana-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 31.3 kB

Release files / runspec_grafana-0.2.0.tar.gz

Download URL runspec_grafana-0.2.0.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b86004c415e6a62f48018908a95c2476a87971755e4e325b42367c6be38e2e44
BLAKE2b-256 checksum
How to use checksums
431486a83a845c00dcbc67a7b4ed676f76557df19ce5c1f41e6f490abade7d3c
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 18, 2026.

Transparency log

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

Download URL runspec_grafana-0.2.0-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7694bf99a26529fcfd4de2bb39fff128b5ffbeb77da80d5916b43386d83b739a
BLAKE2b-256 checksum
How to use checksums
02b1dc854d6885bd2a972a772f366ac121cd1dadef50ffeee0fdc1e2176c1331
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 18, 2026.

Transparency log

Security for runspec-grafana 0.2.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.2.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 18, 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.2.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