11using ConformanceServer . Prompts ;
22using ConformanceServer . Resources ;
33using ConformanceServer . Tools ;
4- using Microsoft . Extensions . AI ;
54using ModelContextProtocol . Protocol ;
65using System . Collections . Concurrent ;
76using System . Text . Json ;
8- using System . Text . Json . Nodes ;
9- using System . Text . Json . Serialization ;
107
118namespace ModelContextProtocol . ConformanceServer ;
129
@@ -41,18 +38,8 @@ public static async Task MainAsync(string[] args, ILoggerProvider? loggerProvide
4138 }
4239 if ( ctx . Params ? . Uri is { } uri )
4340 {
44- subscriptions [ ctx . Server . SessionId ] . TryAdd ( uri , 0 ) ;
45-
46- await ctx . Server . SampleAsync ( [
47- new ChatMessage ( ChatRole . System , "You are a helpful test server" ) ,
48- new ChatMessage ( ChatRole . User , $ "Resource { uri } , context: A new subscription was started") ,
49- ] ,
50- chatOptions : new ChatOptions
51- {
52- MaxOutputTokens = 100 ,
53- Temperature = 0.7f ,
54- } ,
55- cancellationToken : ct ) ;
41+ var sessionSubscriptions = subscriptions . GetOrAdd ( ctx . Server . SessionId , _ => new ( ) ) ;
42+ sessionSubscriptions . TryAdd ( uri , 0 ) ;
5643 }
5744
5845 return new EmptyResult ( ) ;
@@ -67,6 +54,7 @@ await ctx.Server.SampleAsync([
6754 {
6855 subscriptions [ ctx . Server . SessionId ] . TryRemove ( uri , out _ ) ;
6956 }
57+
7058 return new EmptyResult ( ) ;
7159 } )
7260 . WithCompleteHandler ( async ( ctx , ct ) =>
0 commit comments