-
Notifications
You must be signed in to change notification settings - Fork 152
feat: Add proxied tools functionality, specifically make sure it proxies tempo correctly #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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. |
There was a problem hiding this 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.
tools/proxied_tools.go
Outdated
// 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) | ||
} |
There was a problem hiding this comment.
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 😞
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
aa31a24
to
6dbad36
Compare
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. |
58379dd
to
188c6f7
Compare
2051453
to
58d0e7d
Compare
86e2cf6
to
58d0e7d
Compare
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