[BUG] Chart's kagent-api RemoteMCPServer never discovers tools under server.auth.mode: trusted-proxy (401 on initialize)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go, helm, kubernetes
- Lĩnh vực
- authentication, backend, distributed-systems
Hướng nghiên cứu
Start with go/core/internal/service/tool/mcp.go and go/core/internal/httpserver/auth/proxy_authn.go, then inspect helm/kagent/templates/toolserver-api.yaml and the service account authentication configuration. Trace how control-plane discovery authenticates to the controller's own MCP endpoint and confirm the intended credential and audience. Done means kagent-api is accepted and discovers its tools in trusted-proxy mode without a user token.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
📋 Prerequisites
- I have searched the existing issues to avoid creating a duplicate
- By submitting this issue, you agree to follow our Code of Conduct
- I am using the latest version of the software
- I have tried to clear cache/cookies or used incognito mode (if ui-related)
- I can consistently reproduce this issue
🎯 Affected Service(s)
Controller Service
🚦 Impact/Severity
Minor inconvenience
🐛 Bug Description
With config.server.auth.mode: trusted-proxy, the controller can't discover the tools on its own MCP endpoint. The Helm chart creates the RemoteMCPServer kagent-api (helm/kagent/templates/toolserver-api.yaml), and that object stays Accepted=False with reason DiscoveryFailed. The sessions, checkpoints and sandboxes tools never show up, so agents can't use them.
The controller authenticates /mcp with ProxyAuthenticator. That authenticator rejects any request without exactly one Authorization: Bearer <JWT> header (go/core/internal/httpserver/auth/proxy_authn.go:28-36). Discovery comes from the controller itself, through RuntimeMCPClient.connect (go/core/internal/service/tool/mcp.go:124). The only headers it sends are the ones the RemoteMCPServer resolves (server.ResolveHeaders, line 138), and the chart's kagent-api server defines none. connect also explicitly refuses actorJwt for control-plane calls (line 130). So the call reaches the controller with no credential and gets a 401.
Enabling config.server.auth.serviceAccount (the ServiceAccountProvider, audience kagent-invocation) doesn't help, because the discovery client never sends a service account token.
My guess is that this went unnoticed because trusted-proxy was only wired end to end recently (#2968). Before that the controller always ran unsecure, so self-discovery never had to authenticate.
🔄 Steps To Reproduce
Reproduced on 2026-11-03 on a local kind cluster, from a clean checkout of main at e3b80793, using the repository's own dev targets.
- Create the cluster and install kagent with Substrate and the dev database. The default auth mode is
insecure.git clone https://github.com/kagent-dev/kagent && cd kagent make create-kind-cluster make build kagent-cli-deploy - Confirm that
kagent-apidiscovers its tools in the default mode:kubectl --context kind-kagent -n kagent get remotemcpserver kagent-api \ -o jsonpath='{.status.conditions[?(@.type=="Accepted")].message}{"\n"}' # Discovered 19 MCP tools - Switch the controller to
trusted-proxy.grpcReflectionis only needed for the optionalgrpcurlcheck in step 6.helm --kube-context kind-kagent -n kagent upgrade kagent "dist/kagent-$(git describe --tags --always).tgz" \ --reuse-values \ --set config.server.auth.mode=trusted-proxy \ --set config.server.auth.userIdClaim=email \ --set config.server.grpcReflection=true --wait kubectl --context kind-kagent -n kagent rollout status deploy/kagent-controller - Force a fresh discovery, so the status doesn't still come from the
insecurerun. The reconciler watches label changes.kubectl --context kind-kagent -n kagent label remotemcpserver kagent-api repro="$(date +%s)" --overwrite - Read the status and the controller logs:
kubectl --context kind-kagent -n kagent get remotemcpserver kagent-api \ -o jsonpath='{range .status.conditions[*]}{.type}={.status} {.reason}: {.message}{"\n"}{end}' # Accepted=False DiscoveryFailed: Failed to connect to MCP server: failed to connect MCP client: calling "initialize": sending "initialize": Unauthorized kubectl --context kind-kagent -n kagent logs deploy/kagent-controller | grep -m1 'Reconciler error' - (Optional) A signed-in user calling a
kagent-apitool through the API fails the same way. Undertrusted-proxythe controller reads the token'semailclaim without verifying the signature, so an unsigned test token works:
Settingb64() { printf '%s' "$1" | base64 | tr '+/' '-_' | tr -d '='; } TOKEN="$(b64 '{"alg":"HS256","typ":"JWT"}').$(b64 '{"email":"[email protected]"}').dGVzdA" kubectl --context kind-kagent -n kagent run grpcurl --rm -i --restart=Never --image=fullstorydev/grpcurl:v1.9.3 -- \ -plaintext -H "authorization: Bearer $TOKEN" \ -d '{"server":{"ref":{"namespace":"kagent","name":"kagent-api"},"group_kind":"RemoteMCPServer.api.kagent.dev"},"tool_name":"list_agents"}' \ kagent-controller.kagent.svc.cluster.local:8083 kagent.api.v1.ToolService/CallMCPAppTool # ERROR: Code: Internal Message: internal server errorconfig.server.auth.mode=insecureagain and repeating step 4 brings backAccepted=Truewith 19 tools.
🤔 Expected Behavior
kagent-api is Accepted=True and its tools are discovered, the same as with mode: insecure. The controller's calls to its own endpoint authenticate with a credential the controller can verify, without a user token and without needing an authenticating proxy in front of the controller.
📱 Actual Behavior
The RemoteMCPServer status:
Accepted=False reason=DiscoveryFailed
message: Failed to connect to MCP server: failed to connect MCP client: calling "initialize": sending "initialize": Unauthorized
The controller logs Reconciler error for RemoteMCPServer kagent/kagent-api, retrying with backoff.
💻 Environment
- Kubernetes version: 1.37
- Kubernetes provider: AWS (EKS)
- Application version: kagent 1.0.0-rc1 (chart and images). The code involved is unchanged on
mainat 3b28b6b7. - Agent Substrate 1.0.0-rc1
- Also reproduced on kind (Kubernetes 1.35,
make create-kind-cluster) frommainate3b80793, with the steps above.
🔍 Additional Context
- Did this work before? On 1.0.0-alpha17 with the same values,
kagent-apidiscovered its tools. That release never actually appliedtrusted-proxy(#2968), so it wasn't really a working configuration. - Workarounds:
mode: insecuremakes discovery work, but it gives up per-user identity, so it isn't usable for us.- Putting a static
Authorizationheader on theRemoteMCPServerthroughheadersFromwould mean minting a long-lived token. Undertrusted-proxythat token would be an unverified user JWT. We don't want either.
- Possible fix, for maintainers to confirm: for control-plane MCP calls to the controller's own endpoint,
RuntimeMCPClientcould attach a projected service account token with audiencekagent-invocation, and the existingServiceAccountProviderwould verify it. The chart would then enableserver.auth.serviceAccountwhenevermodeistrusted-proxy, or the controller would always trust its own service account. I'm happy to work through the approach here or in#kagent-devbefore opening a PR.
📋 Logs
$ kubectl -n kagent get remotemcpserver kagent-api
NAME PROTOCOL URL ACCEPTED
kagent-api STREAMABLE_HTTP http://kagent-controller.kagent.svc.cluster.local:8083/mcp False
🙋 Are you willing to contribute?
- I am willing to submit a PR to fix this issue
- Ngôn ngữ chính
- Go
- Star
- 4.5k
- Fork
- 937
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 150
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của kagent-dev/kagent
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
kagent-dev/kagent#3792 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kagent-dev/kagent#3790 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
kagent-dev/kagent#3789 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] A2A lookups by task or context ID reveal whether another user's resource existsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
kagent-dev/kagent#3787 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Python memory summarization fails for Gemini models: the request has no model nameCó thể đã có người làm @BahaaMattar đã nhận 7 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
kagent-dev/kagent#3710 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của kagent-dev/kagent
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
limitlessprojects/Go-Hybrid#4764 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[bug]: lint fails on main, generated CLI docs out of dateCó thể đã có người làm @bupd đã nhận hôm nay. Đang mởbug documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
goharbor/harbor-cli#1180 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
crane: mutate --env adds duplicate PATH on Windows images when key case differsCó thể đã có người làm @aad1tyaaaaa đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
google/go-containerregistry#2523 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
bosh_io_stemcell_type: regular does not work for noble and resolute as it adds -go_agent as suffixĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
cloudfoundry/bosh-deployment-resource#138 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100