Commit 3ba0e2e
authored
feat(crd): add default timeout field to MCPServerSpec (#121)
### Summary
Adds a `Timeout` field to `MCPServerSpec` with a kubebuilder default of
`30s`.
This addresses
[kagent-dev/kagent#1272](kagent-dev/kagent#1272):
MCP servers deployed via the MCPServer CRD use a sidecar gateway that
spawns a new stdio process (e.g. via `uvx`/`npx`) for each session.
Process startup can take 2–8 seconds depending on package cache state,
which exceeds the default 5-second timeout used by some ADK clients
(e.g. Python ADK `StreamableHTTPConnectionParams`), causing intermittent
`"Failed to create MCP session"` errors.
### Context
An initial fix was proposed in
[kagent-dev/kagent#1275](kagent-dev/kagent#1275)
by making the timeout configurable via the Helm chart (env var →
controller flag → handler threading). A maintainer [correctly pointed
out](kagent-dev/kagent#1275 (comment)) that
the proper fix is to add this field to the MCPServer CRD itself, which:
- Follows existing CRD patterns (`Port` has `+kubebuilder:default=3000`,
`Replicas` has `+kubebuilder:default=1`)
- Provides **per-resource granularity** (each MCPServer can specify its
own timeout)
- Eliminates complex threading through Helm/env/flags/handlers
- Is the Kubernetes-idiomatic approach
### Changes
| File | Description |
|------|-------------|
| `api/v1alpha1/mcpserver_types.go` | Add `Timeout *metav1.Duration`
field with `+kubebuilder:default="30s"` |
| `api/v1alpha1/zz_generated.deepcopy.go` | Regenerated via `make
generate` |
| `config/crd/bases/kagent.dev_mcpservers.yaml` | CRD manifest
regenerated via `make manifests` |
| `helm/kmcp-crds/templates/mcpserver-crd.yaml` | Helm CRD template
updated to match |
### Backward Compatibility
- The default value is `30s` — existing MCPServer resources without an
explicit timeout will automatically get this default applied by the API
server.
- No breaking changes to existing CRs.
### Companion PR
Once this is merged and released, I will create a new PR and the kagent
controller will be updated to propagate this field:
`ConvertMCPServerToRemoteMCPServer` propagates `MCPServer.Spec.Timeout`
→ `RemoteMCPServer.Spec.Timeout`
Ref:
[kagent-dev/kagent#1272](kagent-dev/kagent#1272)
Signed-off-by: skhedim <sebastien.khedim@gmail.com>1 parent 161b9fe commit 3ba0e2e
4 files changed
Lines changed: 39 additions & 1 deletion
File tree
- api/v1alpha1
- config/crd/bases
- helm/kmcp-crds/templates
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
151 | 162 | | |
152 | 163 | | |
153 | 164 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5282 | 5282 | | |
5283 | 5283 | | |
5284 | 5284 | | |
| 5285 | + | |
| 5286 | + | |
| 5287 | + | |
| 5288 | + | |
| 5289 | + | |
| 5290 | + | |
| 5291 | + | |
| 5292 | + | |
| 5293 | + | |
| 5294 | + | |
| 5295 | + | |
5285 | 5296 | | |
5286 | 5297 | | |
5287 | 5298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2014 | 2014 | | |
2015 | 2015 | | |
2016 | 2016 | | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
2017 | 2028 | | |
2018 | 2029 | | |
2019 | 2030 | | |
| |||
0 commit comments