2929use Mcp \Schema \ResourceTemplate ;
3030use Mcp \Schema \ServerCapabilities ;
3131use Mcp \Schema \Tool ;
32- use Psr \ EventDispatcher \ EventDispatcherInterface ;
32+ use Mcp \ Server \ NotificationPublisher ;
3333use Psr \Log \LoggerInterface ;
3434use Psr \Log \NullLogger ;
3535
@@ -61,8 +61,8 @@ class Registry
6161 private array $ resourceTemplates = [];
6262
6363 public function __construct (
64+ private readonly NotificationPublisher $ notificationPublisher ,
6465 private readonly ReferenceHandler $ referenceHandler = new ReferenceHandler (),
65- private readonly ?EventDispatcherInterface $ eventDispatcher = null ,
6666 private readonly LoggerInterface $ logger = new NullLogger (),
6767 ) {
6868 }
@@ -75,12 +75,12 @@ public function getCapabilities(): ServerCapabilities
7575
7676 return new ServerCapabilities (
7777 tools: true , // [] !== $this->tools,
78- toolsListChanged: $ this -> eventDispatcher instanceof EventDispatcherInterface ,
78+ toolsListChanged: true ,
7979 resources: [] !== $ this ->resources || [] !== $ this ->resourceTemplates ,
8080 resourcesSubscribe: false ,
81- resourcesListChanged: $ this -> eventDispatcher instanceof EventDispatcherInterface ,
81+ resourcesListChanged: true ,
8282 prompts: [] !== $ this ->prompts ,
83- promptsListChanged: $ this -> eventDispatcher instanceof EventDispatcherInterface ,
83+ promptsListChanged: true ,
8484 logging: false , // true,
8585 completions: true ,
8686 );
@@ -102,7 +102,7 @@ public function registerTool(Tool $tool, callable|array|string $handler, bool $i
102102
103103 $ this ->tools [$ toolName ] = new ToolReference ($ tool , $ handler , $ isManual );
104104
105- $ this ->eventDispatcher ?->dispatch (new ToolListChangedEvent ());
105+ $ this ->notificationPublisher -> enqueue (new ToolListChangedEvent ());
106106 }
107107
108108 /**
@@ -121,7 +121,7 @@ public function registerResource(Resource $resource, callable|array|string $hand
121121
122122 $ this ->resources [$ uri ] = new ResourceReference ($ resource , $ handler , $ isManual );
123123
124- $ this ->eventDispatcher ?->dispatch (new ResourceListChangedEvent ());
124+ $ this ->notificationPublisher -> enqueue (new ResourceListChangedEvent ());
125125 }
126126
127127 /**
@@ -145,7 +145,7 @@ public function registerResourceTemplate(
145145
146146 $ this ->resourceTemplates [$ uriTemplate ] = new ResourceTemplateReference ($ template , $ handler , $ isManual , $ completionProviders );
147147
148- $ this ->eventDispatcher ?->dispatch (new ResourceTemplateListChangedEvent ());
148+ $ this ->notificationPublisher -> enqueue (new ResourceTemplateListChangedEvent ());
149149 }
150150
151151 /**
@@ -169,7 +169,7 @@ public function registerPrompt(
169169
170170 $ this ->prompts [$ promptName ] = new PromptReference ($ prompt , $ handler , $ isManual , $ completionProviders );
171171
172- $ this ->eventDispatcher ?->dispatch (new PromptListChangedEvent ());
172+ $ this ->notificationPublisher -> enqueue (new PromptListChangedEvent ());
173173 }
174174
175175 /**
0 commit comments