feat(tools): add tools for InfluxDB datasource#614
feat(tools): add tools for InfluxDB datasource#614Shaik-Sirajuddin wants to merge 27 commits intografana:mainfrom
Conversation
tools/influx_db.go
Outdated
| type influxQueryResponse struct { | ||
| Results map[string]struct { | ||
| Status int `json:"status,omitempty"` | ||
| Frames []struct { | ||
| Schema struct { | ||
| Name string `json:"name,omitempty"` | ||
| RefID string `json:"refId,omitempty"` | ||
| Fields []struct { | ||
| Labels struct { | ||
| Field string `json:"_field,omitempty"` | ||
| } `json:"labels"` | ||
| Name string `json:"name"` | ||
| Type string `json:"type"` | ||
| TypeInfo struct { | ||
| Frame string `json:"frame,omitempty"` | ||
| } `json:"typeInfo,omitempty"` | ||
| Config map[string]interface{} `json:"config,omitempty"` | ||
| } `json:"fields"` | ||
| } `json:"schema,omitempty"` | ||
| Data struct { | ||
| Values [][]interface{} `json:"values"` | ||
| } `json:"data"` | ||
| } `json:"frames,omitempty"` | ||
| Error string `json:"error,omitempty"` | ||
| } `json:"results"` | ||
| } |
There was a problem hiding this comment.
This structure is shared by all responses to /api/ds/query so we shouldn't need to define it multiple times. If other datasources are using it then we can factor it out and reuse it.
There was a problem hiding this comment.
Also /api/ds/query is frequently used by across tools ,
Having a grafana client definition with ds query method to start with may improve reusability
Should i address this via another PR ? ?
tools/influx_db.go
Outdated
|
|
||
| var QueryInflux = mcpgrafana.MustTool( | ||
| "query_influx", | ||
| "Queries InfluxDB datasource, supports one of Flux, SQL, or InfluxQL query languages configured with the datasource.", |
There was a problem hiding this comment.
This could do with being more detailed. In particular, if the type must match that configured on the datasource, then we should include brief instructions for how to find it.
There was a problem hiding this comment.
updated the description to include expected in order tool usage
…flux_datasource
Co-authored-by: Ben Sully <ben.sully88@gmail.com>
Co-authored-by: Ben Sully <ben.sully88@gmail.com>
|
Addressed suggestions , Could you take a look @sd2k when you have a chance |
|
Hi @Shaik-Sirajuddin, I had Claude do another pass of a review here. Here's some feedback I'd like to see before merging: SummaryAdds InfluxDB datasource support with query, bucket, measurement, tag, and field key listing tools across SQL/Flux/InfluxQL query languages. Good refactoring to extract shared DS query response types into pkg/grafana. However, there are several correctness, design, and security issues that should be addressed before merging. Issues
Suggestions
|
|
Sure , I will reflect the suggested improvements |

Introduce InfluxDB Tools with support for SQL , FLUX , INFLUQL Queries
Graphana provides native backend for InfluxDB Datasources ,
Addresses #176 suggestions for datasource support in mcp-grafana
Technical Details :
Utilizes
/api/ds/query/endpoint for queriesTools make use of the parameterized datasource 's query language (one of sql/flux/influxql) to execute queries
Tools Added:
Additional
Note
Medium Risk
Adds a new InfluxDB query surface (SQL/Flux/InfluxQL) with query rewriting/limit enforcement and expands the local dev/test stack, which could affect query correctness and integration behavior across datasources.
Overview
Adds first-class InfluxDB support via new MCP tools:
query_influxdbplus discovery helpers to list buckets (Flux-only), measurements, tag keys, and field keys, with time range parsing and enforced per-query limits.Refactors
/api/ds/queryplumbing by introducing shared types inpkg/grafana/datasource.goand switching ClickHouse, CloudWatch, and Cloud Monitoring Prometheus backend code/tests to usegrafana.DSQueryResponseinstead of bespoke response structs.Extends the integration environment with InfluxDB v2 + v3 services, seeded sample data, and provisioned InfluxDB datasources in
docker-compose.yaml/Grafana provisioning; also wires the new tool category intocmd/mcp-grafanawith a--disable-influxdbflag.Written by Cursor Bugbot for commit 41d23d6. This will update automatically on new commits. Configure here.