Skip to content

Refresh MCP tools before the next model step - #1710

Open
VIOLETee0 wants to merge 1 commit into
CodebuffAI:mainfrom
VIOLETee0:fix/mcp-tool-list-changed-1696
Open

VIOLETee0 wants to merge 1 commit into
CodebuffAI:mainfrom
VIOLETee0:fix/mcp-tool-list-changed-1696

Conversation

@VIOLETee0

Copy link
Copy Markdown

Fixes #1696.

MCP tool catalogs were cached both by the transport and for the lifetime of the agent loop, so a discovery call could not expose its new schemas to the next model request.

Invalidate the shared listing immediately on a valid tools/list_changed notification, keeping the existing paginated listing path. Readers of a listing invalidated in flight join a fresh snapshot. Before subsequent steps, agents that build their own tool set reread the listing cache and rebuild changed model schemas and context-count definitions. Existing filtering and host custom tools are preserved.

One regression drives a real Node stdio server through the runtime loop: paginated discovery, invocation, then removal and schema replacement, all within one user turn. It fails on current main and passes with this patch.

Validation:

  • MCP-focused tests: 68 passed.
  • common, agent-runtime, and SDK TypeScript checks passed.
  • Frozen-lockfile install, SDK build, Windows Freebuff build, version, and official binary smoke passed.
  • Broader affected run: 156 passed, 7 failed; the same 7 existing loop tests fail on unmodified main in this Windows environment.
  • ESLint: 0 errors, 58 warnings (54 in existing production files; each new file has two configured TypeScript-resolver warnings).

Scope: fixed parent-tool snapshots inherited for prompt caching retain their current behavior. The shared Client setup covers stdio/HTTP/SSE, but the behavioral reproduction here uses stdio. No authenticated live-model/TUI test was run.

This branch has not been deployed

No deployments
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.

[Bug] MCP tools/list_changed never reaches the session tool set — tools discovered by a progressive catalog stay uncallable

1 participant