Skip to content

feat(mcp): choose tool exposure automatically / 自动选择 MCP 工具暴露模式 - #7775

Draft
SivanCola wants to merge 2 commits into
esengine:main-v2from
SivanCola:feature/auto-mcp-exposure
Draft

feat(mcp): choose tool exposure automatically / 自动选择 MCP 工具暴露模式#7775
SivanCola wants to merge 2 commits into
esengine:main-v2from
SivanCola:feature/auto-mcp-exposure

Conversation

@SivanCola

@SivanCola SivanCola commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary / 摘要

  • Choose configured MCP exposure automatically at session boot; no new config or environment option.
  • Keep small, cache-valid surfaces direct for low-latency concrete calls.
  • Route large surfaces (at least 16 cached tools), oversized schema surfaces (16 KiB floor, scaled with the model context window), and missing/stale caches through the existing stable use_capability proxy.
  • Freeze the choice for the session. Cache-miss discovery still runs in the background through a private registry, so it warms diagnostics and cache state without adding dynamic mcp__* tools to the provider-visible registry.

在会话启动时自动决定配置 MCP 使用直接工具还是 use_capability 代理,不增加用户设置项;小型且缓存命中的工具面保持直连,大型、schema 过大或缓存未知的工具面自动使用稳定代理,并在整个会话内固定选择。

Required impact declarations

Documentation-impact: updated - documented automatic MCP exposure selection in English and Chinese.

Cache-impact: medium - large or unknown MCP surfaces receive a one-time stable proxy prefix; the decision is fixed for the session.

Cache-guard: go test ./internal/boot -run 'TestChooseMCPExposure|TestBuildAutomaticallyUsesCapabilityForLargeMCPSurface|TestBuildKeepsSmallMCPSurfaceDirect'

System-prompt-review: Codex review completed - no system-prompt text changes; only boot-time provider tool selection changes.

Why

Large MCP catalogs can consume a substantial provider tool prefix. A cache miss can also complete its handshake after boot and mutate the visible tool list. The automatic boundary keeps the ordinary path zero-configuration while preserving direct calls where their schema cost is small.

This adapts the MCP surface-collapse direction proposed by @bfxh in #7743. It intentionally does not include the user-facing meta-tool toggle or the unrelated long-horizon/navigation changes from that PR.

Refs #7743

Compatibility and cache impact

  • Small configured MCP surfaces with matching caches keep the existing direct mcp__* behavior.
  • Large or unknown configured surfaces receive one stable use_capability schema instead of many MCP schemas.
  • The exposure decision is boot-scoped, so reconnects cannot change it mid-session.
  • Explicit host-session MCP servers remain direct and session-scoped.
  • Economy mode keeps its existing on-demand connector behavior.
  • Upgrading can cause a one-time provider cache-prefix change when an existing MCP setup crosses the automatic boundary.

Verification

  • go test ./...
  • go test -race ./internal/boot
  • go vet ./internal/boot ./internal/capability ./internal/plugin ./internal/agent
  • Integration coverage verifies large surfaces expose only use_capability, small surfaces retain direct tools, and cold/stale caches choose the stable proxy while preserving background discovery diagnostics.

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development config Configuration & setup (internal/config) labels Aug 6, 2026
Large MCP catalogs can consume a substantial provider tool prefix, while cache-miss handshakes can change the visible schema after boot. The previous behavior had no automatic boundary between direct per-tool exposure and the existing use_capability proxy.

Choose the exposure mode once per session from cached tool counts and estimated schema bytes. Keep small, cache-valid surfaces direct; route large or unknown surfaces through the stable use_capability proxy without adding a user setting. Cache-miss discovery still warms the cache and records failures through a private registry, so it cannot mutate the provider-visible registry.

Add bounded diagnostics, bilingual documentation, and boot/integration coverage for small, large, stale, and cold MCP surfaces.

Tests: go test ./...

Tests: go test -race ./internal/boot

Checks: go vet ./internal/boot ./internal/capability ./internal/plugin ./internal/agent
Co-authored-by: bfxh <243242559+bfxh@users.noreply.github.com>
@SivanCola
SivanCola force-pushed the feature/auto-mcp-exposure branch from 0f49f9a to 9880a2e Compare August 6, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration & setup (internal/config) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant