Skip to content

Support Grafana's new Kubernetes-style HTTP API for dashboard operations #588

@igor-raits

Description

@igor-raits

Summary

Grafana is transitioning to a new Kubernetes-style HTTP API that follows the pattern:

/apis/<group>/<version>/namespaces/<namespace>/<resource>[/<name>]

For dashboards specifically, the new API is documented at:
https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/dashboard/

Currently, mcp-grafana uses the legacy API endpoints via grafana-openapi-client-go (e.g., POST /api/dashboards/db, GET /api/dashboards/uid/:uid). It would be beneficial to add support for (or migrate to) the new API.

New Dashboard API Endpoints

Operation Legacy API New API
Get GET /api/dashboards/uid/:uid GET /apis/dashboard.grafana.app/v1beta1/namespaces/:ns/dashboards/:name
Get (with access info) GET /apis/dashboard.grafana.app/v1beta1/namespaces/:ns/dashboards/:name/dto
Create POST /api/dashboards/db POST /apis/dashboard.grafana.app/v1beta1/namespaces/:ns/dashboards
Update POST /api/dashboards/db PUT /apis/dashboard.grafana.app/v1beta1/namespaces/:ns/dashboards/:name

The new API uses a k8s-style resource envelope:

{
  "apiVersion": "dashboard.grafana.app/v1beta1",
  "kind": "Dashboard",
  "metadata": {
    "name": "my-dashboard-uid",
    "annotations": {
      "grafana.app/folder": "<folder-uid>",
      "grafana.app/message": "commit message"
    }
  },
  "spec": { ... }
}

Considerations

  • Namespace resolution: The new API requires a namespace parameter (default for OSS, org-<id> for multi-org, stacks-<id> for Grafana Cloud).
  • No existing Go client: There doesn't appear to be a dedicated Go client library for consuming the new API (the grafana-app-sdk is for building Grafana apps, not consuming the API). Raw HTTP calls would likely be needed, similar to the pattern already used for Sift, CloudWatch, Loki, etc.
  • Stability: The new API is currently at v1beta1.
  • Backwards compatibility: The legacy API still works. It may make sense to support both and detect which is available, or require a minimum Grafana version.
  • Scope: Beyond dashboards, the new API pattern also covers folders, playlists, and other resources that mcp-grafana interacts with.

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