Skip to content

Graphite tools#741

Open
99cardz wants to merge 3 commits intografana:mainfrom
99cardz:graphite-tools
Open

Graphite tools#741
99cardz wants to merge 3 commits intografana:mainfrom
99cardz:graphite-tools

Conversation

@99cardz
Copy link
Copy Markdown

@99cardz 99cardz commented Apr 13, 2026

Note

Medium Risk
Adds new datasource-querying MCP tools (Graphite) and related HTTP/proxy logic, which can affect server behavior and load when enabled. Risk is moderated by read-only semantics and extensive unit tests, but it introduces new external API interactions and response parsing.

Overview
Adds a new Graphite tool suite: list_graphite_metrics, list_graphite_tags, query_graphite, and query_graphite_density, all executed via Grafana’s datasource proxy with auth/org-aware transport and response-size limiting.

Introduces parsing/typing for Graphite render/find/tag APIs, plus a density-analysis path that optionally uses summarize(isNonNull()) for efficiency and falls back to raw datapoints when unsupported/mismatched.

Wires graphite into the server’s --enabled-tools default and adds --disable-graphite, and extends empty-result hint generation with Graphite-specific causes/actions. Includes comprehensive unit tests for parsing, HTTP handling, and density calculations.

Reviewed by Cursor Bugbot for commit 70430c8. Bugbot is set up for automated code reviews on this repo. Configure here.

99cardz added 3 commits April 12, 2026 10:52
- Implement GraphiteClient for handling queries to a Graphite datasource via Grafana proxy.
- Add functions for querying metrics, listing metrics, and retrieving tags.
- Enhance error handling and provide hints for empty results specific to Graphite.
- Include unit tests for Graphite functionalities to ensure reliability.
@99cardz 99cardz requested a review from a team as a code owner April 13, 2026 13:54
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 70430c8. Configure here.

// Primary path: fetch summarize(isNonNull(<target>), <bucket>, "sum") to
// obtain a compact per-bucket count of non-null points for each series.
// This avoids downloading full-resolution data for long windows.
bucketSize := graphiteDensityBucketSize(args.From)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Density bucket size ignores default when From is empty

Medium Severity

graphiteDensityBucketSize is called with raw args.From instead of the default-applied value. When args.From is empty, the query defaults to "-1h" (line 491-492), but graphiteDensityBucketSize("") returns "1h" because an empty string doesn't start with "-". If the defaulted "-1h" were passed instead, it would correctly return "5m". This means the summarize call uses a 1-hour bucket for a 1-hour window, producing ~1 data bucket instead of the targeted 12, significantly degrading density analysis accuracy.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 70430c8. Configure here.

@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Apr 13, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant