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

Open
#1,496 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript

Research direction

Start with the base-class implementation and comment at rpc.ts:9235, then trace session.rpc.tools.initializeAndValidate for sessions created through joinSession(). Reproduce the MCP enable flow, wait for mcp_server_status_changed, and verify that the active tool list is rebuilt during the same turn rather than only after tools_changed_notice.

Written by the indexing model from the issue text.

Description

enhancement

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
Dominant language
Java
Stars
10.5k
Forks
1.5k
Avg merge
1d 12h
Merged PRs (30d)
133

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/copilot-sdk

All issues in github/copilot-sdk

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.