66
77use Evenement \EventEmitter ;
88use PhpMcp \Schema \JsonRpc \Parser ;
9- use Mcp \Server \Contracts \LoggerAwareInterface ;
10- use Mcp \Server \Contracts \LoopAwareInterface ;
119use Mcp \Server \Contracts \ServerTransportInterface ;
1210use Mcp \Server \Exception \TransportException ;
1311use PhpMcp \Schema \JsonRpc \Error ;
1412use PhpMcp \Schema \JsonRpc \Message ;
1513use Psr \Log \LoggerInterface ;
1614use Psr \Log \NullLogger ;
17- use React \ChildProcess \Process ;
18- use React \EventLoop \Loop ;
1915use React \EventLoop \LoopInterface ;
2016use React \Promise \Deferred ;
2117use React \Promise \PromiseInterface ;
3026 * Implementation of the STDIO server transport using ReactPHP Process and Streams.
3127 * Listens on STDIN, writes to STDOUT, and emits events for the Protocol.
3228 */
33- final class StdioServerTransport extends EventEmitter implements
34- ServerTransportInterface,
35- LoggerAwareInterface,
36- LoopAwareInterface
29+ final class StdioServerTransport extends EventEmitter implements ServerTransportInterface
3730{
3831 private const string CLIENT_ID = 'stdio ' ;
3932
40- protected LoggerInterface $ logger ;
41- protected LoopInterface $ loop ;
42- protected ?Process $ process = null ;
4333 protected ?ReadableStreamInterface $ stdin = null ;
4434 protected ?WritableStreamInterface $ stdout = null ;
4535 protected string $ buffer = '' ;
@@ -57,8 +47,10 @@ final class StdioServerTransport extends EventEmitter implements
5747 * @throws TransportException If provided resources are invalid.
5848 */
5949 public function __construct (
50+ protected readonly LoopInterface $ loop ,
6051 protected $ inputStreamResource = STDIN ,
6152 protected $ outputStreamResource = STDOUT ,
53+ protected readonly LoggerInterface $ logger = new NullLogger (),
6254 ) {
6355 if (
6456 \str_contains (PHP_OS , 'WIN ' )
@@ -81,19 +73,6 @@ public function __construct(
8173 ) {
8274 throw new TransportException ('Invalid output stream resource provided. ' );
8375 }
84-
85- $ this ->logger = new NullLogger ();
86- $ this ->loop = Loop::get ();
87- }
88-
89- public function setLogger (LoggerInterface $ logger ): void
90- {
91- $ this ->logger = $ logger ;
92- }
93-
94- public function setLoop (LoopInterface $ loop ): void
95- {
96- $ this ->loop = $ loop ;
9776 }
9877
9978 /**
0 commit comments