Skip to content

feat(mcp-server): add keep-alive support#2624

Open
tdabasinskas wants to merge 1 commit intodocker:mainfrom
cogvel:feat/mcp-keepalive
Open

feat(mcp-server): add keep-alive support#2624
tdabasinskas wants to merge 1 commit intodocker:mainfrom
cogvel:feat/mcp-keepalive

Conversation

@tdabasinskas
Copy link
Copy Markdown
Contributor

Enables keep-alive support for serve mcp. Defaults to 0 to keep the existing behavior and be opt-in.

@tdabasinskas tdabasinskas requested a review from a team as a code owner May 4, 2026 11:57
@tdabasinskas tdabasinskas force-pushed the feat/mcp-keepalive branch 2 times, most recently from ce7ee48 to 984b997 Compare May 4, 2026 13:08
dgageot
dgageot previously approved these changes May 4, 2026
@dgageot
Copy link
Copy Markdown
Member

dgageot commented May 4, 2026

@tdabasinskas not sure why, GitHub doesn't want to merge this one, because of hypothetical merge conflicts. Could you rebase?

- Add `MCPKeepAlive time.Duration` to `config.RuntimeConfig` and forward it to `mcp.NewServer` via `mcp.ServerOptions.KeepAlive`
- Wire a `--mcp-keepalive` flag on the `serve mcp` subcommand; accepts a duration string (e.g. `30s`)
- Default `0` preserves the previous behaviour (no keepalive) — opt-in only
- The MCP SDK guards keepalive activation with `KeepAlive > 0`, so passing `0` cleanly disables without any extra branching
- Useful when the MCP transport sits behind load balancers / NAT gateways that close idle connections; the next tool call would otherwise fail with a transport error rather than transparently reconnecting
@tdabasinskas
Copy link
Copy Markdown
Contributor Author

@tdabasinskas not sure why, GitHub doesn't want to merge this one, because of hypothetical merge conflicts. Could you rebase?

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants