Skip to content

fix(agent-core): refresh MCP tools on list changes#1350

Open
Pluviobyte wants to merge 1 commit into
MoonshotAI:mainfrom
Pluviobyte:codex/mcp-list-changed-refresh
Open

fix(agent-core): refresh MCP tools on list changes#1350
Pluviobyte wants to merge 1 commit into
MoonshotAI:mainfrom
Pluviobyte:codex/mcp-list-changed-refresh

Conversation

@Pluviobyte

Copy link
Copy Markdown

Related Issue

Resolve #1138

Problem

See linked issue. Connected MCP servers can advertise tools.listChanged, but the active session kept the startup tool registry after notifications/tools/list_changed.

What changed

  • Wire SDK tool-list change callbacks into the stdio, streamable HTTP, and SSE MCP clients.
  • Refresh the current connected server entry in McpConnectionManager while ignoring stale reconnect attempts and preserving existing tools on refresh errors.
  • Add a dynamic stdio MCP fixture plus manager and session-level tests proving new tools become visible in the active agent.
  • Add a patch changeset for the CLI and agent-core packages.

Validation:

  • pnpm -C packages/agent-core exec vitest run test/mcp/connection-manager.test.ts
  • pnpm --filter @moonshot-ai/agent-core run typecheck
  • pnpm exec oxlint --type-aware packages/agent-core/src/mcp/client-shared.ts packages/agent-core/src/mcp/client-stdio.ts packages/agent-core/src/mcp/client-http.ts packages/agent-core/src/mcp/client-sse.ts packages/agent-core/src/mcp/connection-manager.ts packages/agent-core/test/mcp/connection-manager.test.ts packages/agent-core/test/mcp/fixtures/dynamic-tools-stdio-server.mjs
  • pnpm changeset status --since main

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.

@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 63654b8

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

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@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

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.

MCP tools/list_changed notifications do not refresh session-visible tool registry

1 participant