Skip to content

feat: add confirmed Grafana dashboard imports - #178

Open
laozhej wants to merge 1 commit into
TMHSDigital:mainfrom
laozhej:feat/171-grafana-dashboard-import
Open

laozhej wants to merge 1 commit into
TMHSDigital:mainfrom
laozhej:feat/171-grafana-dashboard-import

Conversation

@laozhej

@laozhej laozhej commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Adds homelab_grafanaImport, accepting either raw dashboard JSON or the complete homelab_grafanaSnapshot export. It requires confirmation, limits input to 1 MiB of UTF-8, posts to /api/dashboards/db using the existing Grafana auth helper, and returns the saved UID and URL.

  • Send the request body through SSH stdin (curl --data-binary @-), keeping dashboard contents out of shell commands and previews. An optional ExecOptions.stdin sends input followed by EOF without changing existing callers.
  • Default overwrite to false. Retain the UID but reset database-local IDs and versions so exported values cannot bypass that choice. Allow an explicit folder UID, otherwise preserve the exported folder or use root; an empty string explicitly selects root.
  • Mask auth in previews, errors and dry runs, and quote Grafana credentials containing shell metacharacters safely. Validate success responses before reporting an import.
  • Update the registry, catalog, counts, security lists, changelog and Grafana skill workflow.

Why

Closes #171. The Grafana skill already describes export/import workflows, but the MCP server only implements export. This completes the round trip with an explicit overwrite choice and confirmation preview.

The request and response follow the documented dashboard API. The returned URL can be relative to the Grafana base URL.

Type

  • New MCP tool
  • New skill
  • New rule
  • Bug fix
  • Documentation
  • Other

Testing

  • cd mcp-server && npm run build && npm test passes
  • pytest tests/ -v --tb=short passes
  • Tested against a live Pi (if applicable)

Node 22.23.0: build and npm run typecheck pass; 659 TypeScript tests pass, with 10 live-Pi tests skipped. All 273 Python structure tests pass. No live Grafana or Pi was used.

Coverage includes raw and exported JSON, UTF-8 byte limits, folder precedence, overwrite defaults, per-node settings, confirmation and dry-run behavior, credential quoting/masking, and malformed/truncated/error responses. A local SSH server verifies empty and large UTF-8 stdin payloads arrive intact with EOF. git diff --check passes.

Checklist

  • No secrets or credentials committed
  • CHANGELOG.md updated
  • README.md updated (if adding tools/skills/rules)
  • CLAUDE.md updated (if adding tools/skills/rules)

Implemented and checked with Codex assistance. Commit includes the required DCO sign-off.

@laozhej
laozhej requested a review from TMHSDigital as a code owner November 21, 2026 04:08
@github-actions github-actions Bot added documentation Improvements or additions to documentation mcp skill labels Nov 21, 2026
@TMHSDigital

Copy link
Copy Markdown
Owner

Thanks for this, the code looks good. #175 just merged and #176, #177 and #179 now need a quick rebase for a CHANGELOG conflict. Once those land, please rebase this one too. With #177's two tools in, the tool count becomes 58, so it needs updating in plugin.json, AGENTS.md, CLAUDE.md, README.md, SECURITY.md, mcp-server/README.md, package.json and site.json, plus the dry-run, input-validation and service-http tests. Then I'll merge it.


Generated by Claude Code

@laozhej
laozhej force-pushed the feat/171-grafana-dashboard-import branch from 495752f to 623d929 Compare November 27, 2026 06:04

This branch has not been deployed

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

Labels

documentation Improvements or additions to documentation mcp skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grafana dashboard import to complete the export/import round trip

2 participants