1414use Mcp \Capability \Attribute \McpTool ;
1515use Mcp \Schema \Content \TextContent ;
1616use Mcp \Schema \Enum \LoggingLevel ;
17- use Mcp \Server \ClientAwareInterface ;
18- use Mcp \Server \ClientAwareTrait ;
17+ use Mcp \Server \RequestContext ;
1918use Psr \Log \LoggerInterface ;
2019
21- final class ClientAwareService implements ClientAwareInterface
20+ final class ClientAwareService
2221{
23- use ClientAwareTrait;
24-
2522 public function __construct (
2623 private readonly LoggerInterface $ logger ,
2724 ) {
@@ -32,9 +29,10 @@ public function __construct(
3229 * @return array{incident: string, recommended_actions: string, model: string}
3330 */
3431 #[McpTool('coordinate_incident_response ' , 'Coordinate an incident response with logging, progress, and sampling. ' )]
35- public function coordinateIncident (string $ incidentTitle ): array
32+ public function coordinateIncident (RequestContext $ context , string $ incidentTitle ): array
3633 {
37- $ this ->log (LoggingLevel::Warning, \sprintf ('Incident triage started: %s ' , $ incidentTitle ));
34+ $ clientGateway = $ context ->getClientGateway ();
35+ $ clientGateway ->log (LoggingLevel::Warning, \sprintf ('Incident triage started: %s ' , $ incidentTitle ));
3836
3937 $ steps = [
4038 'Collecting telemetry ' ,
@@ -45,7 +43,7 @@ public function coordinateIncident(string $incidentTitle): array
4543 foreach ($ steps as $ index => $ step ) {
4644 $ progress = ($ index + 1 ) / \count ($ steps );
4745
48- $ this ->progress ($ progress , 1 , $ step );
46+ $ clientGateway ->progress ($ progress , 1 , $ step );
4947
5048 usleep (180_000 ); // Simulate work being done
5149 }
@@ -56,11 +54,11 @@ public function coordinateIncident(string $incidentTitle): array
5654 implode (', ' , $ steps )
5755 );
5856
59- $ result = $ this ->sample ($ prompt , 350 , 90 , ['temperature ' => 0.5 ]);
57+ $ result = $ clientGateway ->sample ($ prompt , 350 , 90 , ['temperature ' => 0.5 ]);
6058
6159 $ recommendation = $ result ->content instanceof TextContent ? trim ((string ) $ result ->content ->text ) : '' ;
6260
63- $ this ->log (LoggingLevel::Info, \sprintf ('Incident triage completed for %s ' , $ incidentTitle ));
61+ $ clientGateway ->log (LoggingLevel::Info, \sprintf ('Incident triage completed for %s ' , $ incidentTitle ));
6462
6563 return [
6664 'incident ' => $ incidentTitle ,
0 commit comments