fix: set --allowed-hosts for bundled grafana-mcp deployment#2260
Open
muskiteer wants to merge 2 commits into
Open
fix: set --allowed-hosts for bundled grafana-mcp deployment#2260muskiteer wants to merge 2 commits into
muskiteer wants to merge 2 commits into
Conversation
Fixes kagent-dev#2166 Signed-off-by: muskiteer <agarwal.vansh3110@gmail.com>
Signed-off-by: muskiteer <agarwal.vansh3110@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the bundled grafana-mcp Helm deployment so it can be initialized successfully as a RemoteMCPServer when using streamable-http, by automatically adding an --allowed-hosts value that matches the chart-generated Kubernetes Service DNS name.
Changes:
- Add
--allowed-hosts=<fullname>.<namespace>:<service.port>to thegrafana-mcpcontainer args in the Helm Deployment template. - Add a Helm unit test assertion verifying the rendered Deployment includes the expected
--allowed-hostsargument.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| helm/tools/grafana-mcp/templates/deployment.yaml | Automatically injects --allowed-hosts based on the chart’s generated Service hostname and port. |
| helm/tools/grafana-mcp/tests/deployment_test.yaml | Adds coverage to ensure --allowed-hosts is present in the rendered container args. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What does this PR do?
This PR fixes an out-of-the-box initialization failure for the bundled
grafana-mcpdeployment.Why is it needed?
Currently, when
kagent-grafana-mcpis enabled in the default Helm chart, it fails to initialize as aRemoteMCPServerbecause of aForbiddenerror. This happens because recent versions ofmcp-grafanavalidate the HTTP Host header forstreamable-httptransports as DNS rebinding protection (introduced ingrafana/mcp-grafana#957). Without passing--allowed-hostsmatching the internal Kubernetes service DNS name, requests from the Kagent controller are rejected.How does this fix it?
This automatically resolves the Kubernetes Service DNS name natively generated by the chart (
<fullname>.<namespace>:<port>) and appends it to the container's--allowed-hostsarguments in the deployment spec. This ensures the bundled integration works immediately without manual configuration.Testing
How was this tested?
make create-kind-cluster).make helm-install), which enabledgrafana-mcp.kagent-grafana-mcpRemoteMCPServer successfully transitions toAccepted: Trueinstead ofReconcileFailed: Forbidden.Fixes #2166