Skip to content

Conversation

SandersAaronD
Copy link
Contributor

@SandersAaronD SandersAaronD commented Jul 31, 2025

This seems good to my testing but it's hard to be sure; specifically the edge case around having two conflicting tempo MCP servers available from datasources may be buggy (since we only have one version on it currently!). Anyway, this sets up a flow for proxying tools via datasources and specifically carves out logic for handling tempo. Resolves #222

@SandersAaronD SandersAaronD requested a review from a team as a code owner July 31, 2025 05:30
@SandersAaronD
Copy link
Contributor Author

Remaining test failures are (probably) because the tempo version that implements the mcp server isn't deployed to hosted grafana yet, so this may have to be left to sit for a while.

Copy link
Collaborator

@sd2k sd2k left a comment

Choose a reason for hiding this comment

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

This does look somewhat fiddly... Haven't had time to properly review the two big files yet but I added a few comments. Mostly nits except the one about context/env vars which feels important.

Comment on lines 84 to 148
// Also need Grafana config for the proxy handlers
grafanaURL := os.Getenv("GRAFANA_URL")
grafanaAPIKey := os.Getenv("GRAFANA_API_KEY")
if grafanaURL != "" {
gc := mcpgrafana.GrafanaConfig{
URL: grafanaURL,
APIKey: grafanaAPIKey,
}
ctx = mcpgrafana.WithGrafanaConfig(ctx, gc)

// Create Grafana client
client := mcpgrafana.NewGrafanaClient(ctx, grafanaURL, grafanaAPIKey)
ctx = mcpgrafana.WithGrafanaClient(ctx, client)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm this won't work in some cases where we don't set these settings using env vars, e.g. in the LLM app integration we extract them from context. in those cases we would need to do the proxying at call-time, since that's the only time we have access to a context with the URL/API key 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm chewing on this, but I think I can probably do a small refactor to make it so this is importable into the llm app nicely

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decoupled these variables from the proxied tools thing, so it should be possible to do this without worrying about that now. I poked around the plugin and i think we can actually get credentials on startup though, it looks like backend.GrafanaConfigFromContext works for this

@SandersAaronD SandersAaronD force-pushed the sandersaarond/add-tempo branch from aa31a24 to 6dbad36 Compare August 1, 2025 19:15
@SandersAaronD
Copy link
Contributor Author

Had a conversation with @sd2k about this, I think an extra concern to note is that when/if we have this set up to run as a hosted service that proxies to more than one grafana instance, this pattern is awkward. I don't think that should be blocking here, although it may mean that when we have this set up to work as a hosted service we should port the proxied tools up separately since there's a very different pattern surrounding them.

@SandersAaronD SandersAaronD force-pushed the sandersaarond/add-tempo branch from 58379dd to 188c6f7 Compare August 8, 2025 21:03
@SandersAaronD SandersAaronD force-pushed the sandersaarond/add-tempo branch from 2051453 to 58d0e7d Compare August 8, 2025 21:24
@SandersAaronD SandersAaronD marked this pull request as draft August 20, 2025 05:34
@SandersAaronD SandersAaronD force-pushed the sandersaarond/add-tempo branch from 86e2cf6 to 58d0e7d Compare August 21, 2025 23:58
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.

feat: Support MCP servers defined by datasources
2 participants