File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ await ctx.Server.SampleAsync([
145145 . WithLogging ( b => b . SetResourceBuilder ( resource ) )
146146 . UseOtlpExporter ( ) ;
147147
148- builder . Services . AddSingleton ( subscriptions ) ;
148+ builder . Services . AddSingleton < IDictionary < string , List < IMcpServer > > > ( subscriptions ) ;
149149builder . Services . AddHostedService < SubscriptionMessageSender > ( ) ;
150150builder . Services . AddHostedService < LoggingUpdateMessageSender > ( ) ;
151151
Original file line number Diff line number Diff line change 11using ModelContextProtocol ;
22using ModelContextProtocol . Server ;
33
4- internal class SubscriptionMessageSender ( IServiceProvider serviceProvider , HashSet < string > subscriptions ) : BackgroundService
4+ internal class SubscriptionMessageSender ( IDictionary < string , List < IMcpServer > > subscriptions ) : BackgroundService
55{
66 protected override async Task ExecuteAsync ( CancellationToken stoppingToken )
77 {
@@ -12,11 +12,9 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
1212 {
1313 try
1414 {
15- // Try to get the server from the service provider
16- var server = serviceProvider . GetService < IMcpServer > ( ) ;
17- if ( server != null )
15+ foreach ( var ( uri , servers ) in subscriptions )
1816 {
19- foreach ( var uri in subscriptions )
17+ foreach ( var server in servers )
2018 {
2119 await server . SendNotificationAsync ( "notifications/resource/updated" ,
2220 new
You can’t perform that action at this time.
0 commit comments