Skip to content

initializeAndValidate() is a no-op for extension sessions via joinSession() #1496

@lowdrag84

Description

@lowdrag84

Summary

session.rpc.tools.initializeAndValidate() is callable from extensions that join sessions via joinSession(), but it behaves as a no-op — returning {} instantly without rebuilding the LLM's tool list. This prevents extensions from refreshing the tool list mid-turn after dynamically enabling/disabling MCP servers.

Expected Behavior

After an extension calls rpc.mcp.enable({ serverName }) and the MCP server connects (confirmed via mcp_server_status_changed event), calling initializeAndValidate() should rebuild the LLM's active tool list so that newly available tools are usable in the same turn.

Actual Behavior

  • initializeAndValidate() returns {} in ~29ms (consistent with the base-class no-op documented in rpc.ts:9235: "Default base-class implementation is a no-op for sessions that don't support tool validation")
  • Tools only become available via tools_changed_notice, which fires exclusively between turns
  • Extensions have no mechanism to trigger a mid-turn tool list rebuild

Diagnostic Evidence

Built a diagnostic tool (mcp_api_probe) inside an extension to test the full rpc.tools namespace:

session.rpc.tools exists: true
.initializeAndValidate: function    ← callable but no-op
.getCurrentMetadata: undefined      ← not available
.handlePendingToolCall: function
all keys: [handlePendingToolCall, initializeAndValidate]

Full enable+verify cycle (mail MCP):

[17:08:09.150Z] calling rpc.mcp.enable...
[17:08:11.261Z] rpc.mcp.enable resolved
status events received: 2 — both "connected"
tools_updated events received: 0
[17:08:16.274Z] calling tools.initializeAndValidate()...
[17:08:17.126Z] initializeAndValidate returned: {}
Result: tools NOT visible same-turn

Live test results across 3 MCP servers:

MCP Server Connected? Tools Same-Turn? Appeared Via
mail tools_changed_notice (next turn)
workiq tools_changed_notice (~90s)
s360-breeze tools_changed_notice (~90s)

Request

Make initializeAndValidate() functional for extension sessions via joinSession(), or provide an alternative API (e.g., session.rpc.tools.rebuild()) that extensions can call to force a mid-turn tool list rebuild after MCP enable/disable operations.

Use Case

Constellation — a Copilot CLI extension that manages MCP server profiles for token optimization (saves 16K-33K tokens/turn by only loading needed MCPs). Everything works except tools require a wasted turn after each load.

Related: Feature request also filed on github/copilot-cli.

Environment

  • Copilot CLI v1.0.56-1
  • @github/copilot-sdk/extension via joinSession()
  • OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions