Commit 9c56216
authored
fix: propagate MCPServer CRD timeout to RemoteMCPServer (#1277)
Closes #1272
Supersedes #1275
### Summary
Propagates the new `Timeout` field from the MCPServer CRD (added in
[kagent-dev/kmcp#121](kagent-dev/kmcp#121)) to
the generated `RemoteMCPServer` resources, fixing intermittent `"Failed
to create MCP session"` errors for sidecar gateway deployments.
### Context
[#1272](#1272) reported that
the default 5s MCP connection timeout is too low for MCPServer CRD
deployments where the sidecar gateway spawns stdio processes (via
`uvx`/`npx`) with 2–8s cold starts.
An initial approach
([#1275](#1275)) made the
timeout configurable via Helm chart values, threading it through 6+
layers (Helm → ConfigMap → env → flag → handlers → translator). Per
[maintainer
feedback](#1275 (comment)),
the proper fix is to add the timeout directly to the MCPServer CRD.
### Approach
Instead of global controller-level configuration, the timeout is now a
**per-resource field** on the MCPServer CRD with a kubebuilder default
of `30s` (see
[kagent-dev/kmcp#121](kagent-dev/kmcp#121)).
`ConvertMCPServerToRemoteMCPServer` now propagates:
- **`Timeout`** from `MCPServerSpec` → `RemoteMCPServerSpec` (defaults
to 30s via CRD)
- **`TerminateOnClose: true`** (matches ADK expected behavior for
managed servers)
### Changes
| File | Description |
|------|-------------|
| `go/go.mod` | Bump kmcp dependency to version with `Timeout` field
(kmcp version 0.2.6) |
| `go/internal/controller/translator/agent/adk_api_translator.go` |
`ConvertMCPServerToRemoteMCPServer` propagates `Timeout` and sets
`TerminateOnClose: true` |
|
`go/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver.json`
| Golden test updated |
### Backward Compatibility
- Default timeout is `30s`, matching the previous hardcoded behavior
from #1275.
- When `MCPServer.Spec.Timeout` is explicitly set, that value takes
precedence.
- `RemoteMCPServer` resources created directly (not via MCPServer CRD)
are unaffected — they continue using their own `Spec.Timeout` field.
### Depends on
- [x] [kagent-dev/kmcp#121](kagent-dev/kmcp#121)
must be merged and released first
- [x] Update `go.mod` to replace the `replace` directive with the actual
released version
### Testing
- All existing unit tests pass
- Golden test outputs regenerated
- `go build ./...` and `go test ./internal/controller/...` pass cleanly
Signed-off-by: skhedim <sebastien.khedim@gmail.com>1 parent 391c73c commit 9c56216
File tree
6 files changed
+378
-9
lines changed- go
- internal/controller/translator/agent
- testdata
- inputs
- outputs
6 files changed
+378
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 168 | + | |
| 169 | + | |
172 | 170 | | |
173 | 171 | | |
174 | 172 | | |
| |||
Lines changed: 22 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| |||
1259 | 1266 | | |
1260 | 1267 | | |
1261 | 1268 | | |
1262 | | - | |
| 1269 | + | |
1263 | 1270 | | |
1264 | 1271 | | |
1265 | 1272 | | |
| |||
1268 | 1275 | | |
1269 | 1276 | | |
1270 | 1277 | | |
1271 | | - | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
1272 | 1292 | | |
1273 | 1293 | | |
1274 | 1294 | | |
| |||
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
141 | | - | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| |||
0 commit comments