File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ await ctx.Server.SampleAsync([
145
145
. WithLogging ( b => b . SetResourceBuilder ( resource ) )
146
146
. UseOtlpExporter ( ) ;
147
147
148
- builder . Services . AddSingleton ( subscriptions ) ;
148
+ builder . Services . AddSingleton < IDictionary < string , List < IMcpServer > > > ( subscriptions ) ;
149
149
builder . Services . AddHostedService < SubscriptionMessageSender > ( ) ;
150
150
builder . Services . AddHostedService < LoggingUpdateMessageSender > ( ) ;
151
151
Original file line number Diff line number Diff line change 1
1
using ModelContextProtocol ;
2
2
using ModelContextProtocol . Server ;
3
3
4
- internal class SubscriptionMessageSender ( IServiceProvider serviceProvider , HashSet < string > subscriptions ) : BackgroundService
4
+ internal class SubscriptionMessageSender ( IDictionary < string , List < IMcpServer > > subscriptions ) : BackgroundService
5
5
{
6
6
protected override async Task ExecuteAsync ( CancellationToken stoppingToken )
7
7
{
@@ -12,11 +12,9 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
12
12
{
13
13
try
14
14
{
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 )
18
16
{
19
- foreach ( var uri in subscriptions )
17
+ foreach ( var server in servers )
20
18
{
21
19
await server . SendNotificationAsync ( "notifications/resource/updated" ,
22
20
new
You can’t perform that action at this time.
0 commit comments