@@ -18,6 +18,10 @@ internal class McpProxy
1818 private readonly ILogger < McpProxy > _logger ;
1919 private readonly DevServerMonitor _devServerMonitor ;
2020 private readonly McpClientProxy _mcpClientProxy ;
21+ private bool _waitForTools ;
22+
23+ // Clients that don't support the list_updated notification
24+ private static readonly string [ ] ClientsWithoutListUpdateSupport = [ "claude-code" , "codex" ] ;
2125
2226 public McpProxy ( ILogger < McpProxy > logger , DevServerMonitor mcpServerMonitor , McpClientProxy mcpClientProxy )
2327 {
@@ -26,8 +30,9 @@ public McpProxy(ILogger<McpProxy> logger, DevServerMonitor mcpServerMonitor, Mcp
2630 _mcpClientProxy = mcpClientProxy ;
2731 }
2832
29- public async Task < int > RunAsync ( string currentDirectory , int port , List < string > forwardedArgs , CancellationToken ct )
33+ public async Task < int > RunAsync ( string currentDirectory , int port , List < string > forwardedArgs , bool waitForTools , CancellationToken ct )
3034 {
35+ _waitForTools = waitForTools ;
3136 _devServerMonitor . StartMonitoring ( currentDirectory , port , forwardedArgs ) ;
3237
3338 try
@@ -44,6 +49,8 @@ public async Task<int> RunAsync(string currentDirectory, int port, List<string>
4449
4550 private async Task < int > StartMcpStdIoProxyAsync ( CancellationToken ct )
4651 {
52+ var tcs = new TaskCompletionSource ( ) ;
53+
4754 var builder = Host . CreateApplicationBuilder ( ) ;
4855 builder . Services
4956 . AddMcpServer ( )
@@ -73,6 +80,17 @@ private async Task<int> StartMcpStdIoProxyAsync(CancellationToken ct)
7380 } )
7481 . WithListToolsHandler ( async ( ctx , ct ) =>
7582 {
83+ // Claude Code and Codex do not support the list_updated notification.
84+ // To avoid tool invocation failures, we wait for the tools to be available
85+ // after the dev server has started.
86+ if ( _waitForTools
87+ || ClientsWithoutListUpdateSupport . Contains ( ctx . Server . ClientInfo ? . Name ) )
88+ {
89+ _logger . LogTrace ( "Client without list_updated support detected, waiting for upstream server to start" ) ;
90+
91+ await tcs . Task ;
92+ }
93+
7694 var upstreamClient = _mcpClientProxy . UpstreamClient ;
7795
7896 if ( upstreamClient is null )
@@ -103,6 +121,8 @@ private async Task<int> StartMcpStdIoProxyAsync(CancellationToken ct)
103121
104122 _mcpClientProxy . RegisterToolListChangedCallback ( async ( ) =>
105123 {
124+ tcs . TrySetResult ( ) ;
125+
106126 await host . Services . GetRequiredService < IMcpServer > ( ) . SendNotificationAsync (
107127 NotificationMethods . ToolListChangedNotification ,
108128 new ResourceUpdatedNotificationParams ( )
0 commit comments