Skip to content

feat(agent-core-v2): support per-server deferred disclosure of MCP tools - #3455

Open
sailist wants to merge 3 commits into
MoonshotAI:mainfrom
sailist:feat-133-09-02-mcp-deferred-tools
Open

feat(agent-core-v2): support per-server deferred disclosure of MCP tools#3455
sailist wants to merge 3 commits into
MoonshotAI:mainfrom
sailist:feat-133-09-02-mcp-deferred-tools

Conversation

@sailist

@sailist sailist commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — internal feature request (per-server control over deferred MCP tool disclosure).

Problem

The experimental progressive tool disclosure (tool-select flag + a model that declares dynamically_loaded_tools) defers every MCP server's tools: none of them appear in the top-level tools[], and the model must load each one on demand via select_tools. There is no way to pin a specific server's tools inline — for example a core server whose tools the model should see without a select_tools round-trip, while the rest stay deferred to preserve the prompt cache.

What changed

  • MCP server entries (all three transports, plus session-ephemeral and plugin-declared servers) accept a new optional deferred boolean. With the tool-select gate active, servers default to deferred as before; deferred: false keeps that server's tools inline in the top-level tool list. The field is ignored while the gate is off, and v1 config parsing ignores the unknown key as well.
  • The resolved server view now carries the flag to the agent MCP adapter, which registers every MCP tool with an explicit disclosure — deferred by default, inline for opted-out servers. The synthetic OAuth authenticate tool stays deferred, matching current behavior.
  • Tool selection now keys purely on the registered disclosure instead of hard-coding source === 'mcp' as dynamically loadable. Default behavior is unchanged; the deferral decision is now an explicit registration-time declaration.
  • Tests: resolved-view passthrough, inline registration for deferred: false servers, and shaping/manifest behavior for inline tools; existing fixtures updated to the explicit-disclosure registration contract. Docs (en/zh) document the field; changeset included.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (no issue — internal request, see Problem).
  • 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.

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc3b658

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 Patch

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 Sep 2, 2026

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

commit: fc3b658

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b18d344bdf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


const McpServerCommonFields = {
enabled: z.boolean().optional(),
deferred: z.boolean().optional(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Mirror deferred in the public client schemas

When callers configure an MCP server through @moonshot-ai/klient or the v2 node SDK, this option cannot reach the new engine field: packages/klient/src/contract/mcp.ts omits deferred, and Klient's Zod input/output parsing strips unknown properties before sending or returning configs; the node SDK also routes these operations through that contract. Consequently session-ephemeral, add/update, and test calls silently revert to the default deferred behavior, while reading and subsequently updating an existing deferred: false config can erase the setting. Add the field to the mirrored client schema/types and preserve it through node SDK validation.

AGENTS.md reference: AGENTS.md:L30-L30

Useful? React with 👍 / 👎.

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