Repository navigation
Description
📋 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
Blocker
🐛 Bug Description
When an agent references MCP tools via MCPServer CRDs, the agent pod intermittently fails with:
Failed to create MCP session: Failed to connect to MCP server at http://localhost:8081/mcp: [Errno 111] Connection refused
or times out silently, causing the entire tool call to fail.
Root cause: The Python ADK's StreamableHTTPConnectionParams has a hardcoded default timeout: float = 5.0 (see mcp_session_manager.py). When users deploy a MCPServer CRD, the kagent controller automatically generates a corresponding RemoteMCPServer resource. However:
- The
MCPServerCRD does not expose atimeoutfield for users to configure - The auto-generated
RemoteMCPServertherefore hasspec.timeout: nil - The controller does not populate a default timeout in the agent's
config.json - The Python ADK falls back to its own 5-second default
Why 5 seconds is insufficient: MCP servers deployed via the MCPServer CRD use a sidecar agentgateway container that spawns a new stdio process (e.g. via uvx or npx) for each MCP session. Process startup time depends heavily on:
- Package cache state: Cold starts (first invocation, new pod, or cache miss) require downloading/installing the MCP server package via
uvxornpx. Even well-known MCP servers likeawslabs.eks-mcp-servercan take 2–8 seconds on cold starts. - Sequential initialization: When an agent references multiple
MCPServertools, each tool's sidecar spawns its own stdio process. These initializations happen sequentially during tool discovery (list_tools), compounding startup time. - PR feat(kagent-adk): Use new mcp session for a2a requests #1220 impact: Since #1220 (v0.7.10), a new MCP session is created for every A2A request rather than being reused across calls. This means the stdio process startup penalty is paid on every single request, not just the first one.
Typical failure pattern observed:
- Cold starts (first call after pod creation): frequently timeout — stdio process installation + initialization exceeds 5s
- Warm calls: intermittently timeout — natural variability in stdio process spawn time via the sidecar gateway causes 10-30% of requests to exceed 5s, even when the package is cached
The timeout is per-MCP-server, but a single slow initialization is enough to fail the entire agent request.
🔄 Steps To Reproduce
- Deploy kagent with the default configuration
- Create a
MCPServerCRD (e.g. any stdio-based MCP server like@modelcontextprotocol/server-filesystem):Note: TheapiVersion: kagent.dev/v1alpha1 kind: MCPServer metadata: name: eks-mcp spec: transportType: stdio stdioTransport: command: uvx args: ["awslabs.eks-mcp-server@latest"]
MCPServerCRD does not have atimeoutfield — users cannot configure this directly. - Create an
Agentthat references this MCPServer as a tool - Send a message to the agent that requires using the MCP tool
- Observe intermittent
"Failed to create MCP session"errors, especially on:- The first call after pod creation (cold start)
- Under load when multiple agents are spawning stdio processes simultaneously
- After the agentgateway sidecar restarts or cache is cleared
🤔 Expected Behavior
Agents using MCPServer CRDs should connect reliably to their MCP tool servers. Since the MCPServer CRD does not expose a timeout field, the controller should apply a sensible default that accommodates stdio process startup time via the sidecar gateway.
Proposed Solution: Make the default configurable via Helm values / controller config (recommended)
Add a global defaultMCPServerTimeout setting to the kagent controller configuration (exposed via Helm values). This allows cluster operators to tune the default without modifying code:
# values.yaml
controller:
defaultMCPServerTimeout: 30s📱 Actual Behavior
Agents intermittently fail to create MCP sessions because the 5-second default timeout from the Python ADK is too low for the sidecar gateway architecture where a new stdio process is spawned per session.
💻 Environment
- kagent version: 0.7.13 (also affects all versions since feat(kagent-adk): Use new mcp session for a2a requests #1220 / v0.7.10)
- Python ADK version: latest (confirmed
timeout: float = 5.0default inStreamableHTTPConnectionParams) - Kubernetes: EKS 1.34
- MCP servers affected: Any stdio-based MCP server deployed via
MCPServerCRD, especially those usingnpxoruvx - agentgateway version: 0.10.2
🔧 CLI Bug Report
No response
🔍 Additional Context
- Related issues: [BUG] One broken ToolServer can break all agents #631 (one broken ToolServer breaks all agents), [BUG] client timeout when invoking and agent referencing other agents #892 (client timeout with multi-agent), Fix for kagent controller locking up with bad mcp server config #1232 (controller locking up with bad MCP config)
- Related PRs: feat(kagent-adk): Use new mcp session for a2a requests #1220 (new MCP session per request — increases exposure to this timeout), Fix UI/streaming timeouts for long running LLM requests #907 (streaming timeout fix — different timeout, A2A level)
- Key architectural detail:
MCPServerCRDs do not expose atimeoutfield to users. The controller auto-generates aRemoteMCPServerfrom eachMCPServer, and only theRemoteMCPServerCRD has aspec.timeoutfield (which is optional). When nil, no default is currently applied by the controller, causing the Python ADK to fall back to 5s. - The
terminateOnClosefield defaults totruein the Python ADK already, so no change is needed there
📋 Logs
📷 Screenshots
No response
🙋 Are you willing to contribute?
- I am willing to submit a PR to fix this issue
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog
Activity
EItanya commentedon Feb 9, 2026
This is a great point! Good catch
feat(crd): add default timeout field to MCPServerSpec (#121)
fix: propagate MCPServer CRD timeout to RemoteMCPServer (#1277)
fix: propagate MCPServer CRD timeout to RemoteMCPServer (kagent-dev#1277