Skip to content

feat: add global default MCP server timeout configs#2065

Merged
7Sageer merged 10 commits into
mainfrom
mcp-global-startup-timeout
Jul 23, 2026
Merged

feat: add global default MCP server timeout configs#2065
7Sageer merged 10 commits into
mainfrom
mcp-global-startup-timeout

Conversation

@7Sageer

@7Sageer 7Sageer commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below.

Problem

The MCP server connection (startup + tool discovery) timeout and the single tool-call timeout were only configurable per server via startupTimeoutMs / toolTimeoutMs in mcp.json. When the whole environment is slow (cold npx starts, corporate proxies), users had to edit every server entry by hand; there was no global default and no env-level override.

What changed

  • New [mcp] section in config.toml with startup_timeout_ms and tool_timeout_ms, plus KIMI_MCP_STARTUP_TIMEOUT_MS / KIMI_MCP_TOOL_TIMEOUT_MS env overrides. Precedence: per-server fields in mcp.json > env var > config.toml > built-in defaults (30s startup, 60s tool call). Invalid env values are ignored.
  • Implemented in both engines with identical semantics:
    • agent-core-v2: the mcp config section follows the registry + env-binding pattern (same as [subagent] timeout_ms); the env overlay is stripped before persistence so it never leaks into config.toml. The session MCP service resolves the section into the connection manager's new global defaults.
    • agent-core (v1): mcp added to the config schema with explicit TOML read/write mappings; the connection manager takes the resolved defaults at both construction sites (Session and the testGlobalMcpServer RPC).
  • Tests: connection-manager cases for the defaults applying and the per-server fields overriding them (new slow-tool stdio fixture on both engines); v2 config-section env/TOML/strip cases; v1 TOML parse + env-resolution cases.
  • Docs: [mcp] section in config-files, env var rows in env-vars, and a global-default note on the MCP page (zh + en kept in sync).

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Add a `[mcp] startup_timeout_ms` config.toml section with a
`KIMI_MCP_STARTUP_TIMEOUT_MS` env override as the global default MCP
server connection (startup + tool discovery) timeout. Precedence:
per-server `startupTimeoutMs` in mcp.json > env var > config.toml >
built-in 30s default.
@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4f1797b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@4f1797b
npx https://pkg.pr.new/@moonshot-ai/kimi-code@4f1797b

commit: 4f1797b

Extend the `[mcp]` section with `tool_timeout_ms` and the
`KIMI_MCP_TOOL_TIMEOUT_MS` env override as the global default for
single MCP tool calls, mirroring the startup timeout: a per-server
`toolTimeoutMs` in mcp.json still wins, and unset entries fall back to
the SDK built-in 60s default.
@7Sageer 7Sageer changed the title feat: add global default MCP server startup timeout config feat: add global default MCP server timeout configs Jul 22, 2026
7Sageer and others added 8 commits July 22, 2026 20:19
Port the `[mcp]` section (`startup_timeout_ms` / `tool_timeout_ms`)
and the `KIMI_MCP_STARTUP_TIMEOUT_MS` / `KIMI_MCP_TOOL_TIMEOUT_MS` env
overrides to agent-core (v1), mirroring the v2 semantics: per-server
fields in mcp.json > env vars > config.toml > built-in defaults. The
v1 TOML loader gains explicit `mcp` read/write mappings, and both
connection-manager construction sites (Session, testGlobalMcpServer RPC)
pass the resolved defaults through.
Keep the session connection manager synchronously lazy instead of gating
its existence on config readiness: resolveDefaultTimeouts is read from the
mcp config section at each (re)connect, so AgentMcpService's eager
construction stays unconditionally safe and reconnects pick up changed
preferences. The initial connect still awaits config.ready for a
deterministic snapshot. Also restore the ISessionMcpService method docs,
bump the changeset to minor, and fix the v1 env-parse comment.
…timeout

# Conflicts:
#	.agents/skills/agent-core-dev/config.md
Specify the new global default MCP server timeouts in both the config file and environment variables.

Signed-off-by: 7Sageer <sag77r@hotmail.com>
@7Sageer
7Sageer merged commit 527d485 into main Jul 23, 2026
14 checks passed
@7Sageer
7Sageer deleted the mcp-global-startup-timeout branch July 23, 2026 04:41
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.

1 participant