Skip to content

fix(controller): expose RemoteMCPServers before discovery - #3844

Open
xixi-box wants to merge 1 commit into
kagent-dev:mainfrom
xixi-box:fix/issue-2849-940d28b-22bc6d0b
Open

xixi-box wants to merge 1 commit into
kagent-dev:mainfrom
xixi-box:fix/issue-2849-940d28b-22bc6d0b

Conversation

@xixi-box

@xixi-box xixi-box commented Dec 1, 2026

Copy link
Copy Markdown

Fixes #2849

Summary

Creating a RemoteMCPServer writes it to Kubernetes. The list and delete RPCs previously depended on a PostgreSQL catalog row that the discovery reconciler writes after contacting the server. During that gap, the list omitted the new server and delete returned NotFound.

Use live Kubernetes reads for remote server list membership and allow delete to resolve a remote server without a catalog row. The API joins discovered tools by namespace, name, and kind. Projected core Service entries remain supported, and deletion rejects an ambiguous reference. The protobuf response stays compatible and returns an empty tool list before discovery.

Refs #2849

Testing

Tests: /bin/sh -c 'cd go && KUBEBUILDER_ASSETS="$(make -s envtest-path)" go test -count=1 -v ./core/internal/grpcserver -run '"'"'^TestToolServerBeforeDiscovery$'"'"''.
Result: cd go && KUBEBUILDER_ASSETS="$(make -s envtest-path)" go test -count=1 ./core/internal/service/tool ./core/internal/grpcserver -run 'TestService.|TestToolServiceGeneratedClient|TestListToolServers.|TestDiscoveryScopes.|TestAmbiguousServerDeletion.' — passed on the initial production code in both packages.
Result: cd go && KUBEBUILDER_ASSETS="$(make -s envtest-path)" go test -count=1 -v ./core/internal/grpcserver -run '^TestToolServerBeforeDiscovery$' — base exit 1. Create returned OK, the following list contained zero servers, and delete returned NotFound.
Result: cd go && KUBEBUILDER_ASSETS="$(make -s envtest-path)" go test -count=1 -v ./core/internal/grpcserver -run '^TestToolServerBeforeDiscovery$' — patched exit 0. TestToolServerBeforeDiscovery passed in 8.28s, including the final empty list.
Result: cd go && KUBEBUILDER_ASSETS="$(make -s envtest-path)" go test -count=1 ./core/internal/service/tool ./core/internal/grpcserver ./core/internal/controller/remotemcpserver ./core/internal/controller/toolcatalog ./core/pkg/app — passed in all five packages. The full grpcserver package completed in 67.838s.
Result: cd go && go test -count=1 ./core/internal/database -run '^Test(ToolCatalogLifecycle|ConcurrentToolCatalogReplacement|ToolCatalogWritesRollbackTogether)$' — passed against PostgreSQL in 2.219s.
Result: make -C go lint LINT_ARGS='./core/internal/service/tool ./core/internal/grpcserver ./core/pkg/app' — passed on the final patch with 0 issues.
Result: git diff --check — passed. gofmt -l returned no changed Go files.
Regression coverage: go/core/internal/grpcserver/tool_test.go.

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
@xixi-box
xixi-box requested a review from a team as a code owner December 1, 2026 11:08
@github-actions github-actions Bot added the bug Something isn't working label Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] A newly registered MCP server is invisible — and undeletable — until the controller reaches it

1 participant