Skip to content

Commit 989e0e2

Browse files
committed
refactor: simplify StdioServerTransport by removing unused interfaces and properties
1 parent 4d0ac58 commit 989e0e2

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

src/Transports/StdioServerTransport.php

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66

77
use Evenement\EventEmitter;
88
use PhpMcp\Schema\JsonRpc\Parser;
9-
use Mcp\Server\Contracts\LoggerAwareInterface;
10-
use Mcp\Server\Contracts\LoopAwareInterface;
119
use Mcp\Server\Contracts\ServerTransportInterface;
1210
use Mcp\Server\Exception\TransportException;
1311
use PhpMcp\Schema\JsonRpc\Error;
1412
use PhpMcp\Schema\JsonRpc\Message;
1513
use Psr\Log\LoggerInterface;
1614
use Psr\Log\NullLogger;
17-
use React\ChildProcess\Process;
18-
use React\EventLoop\Loop;
1915
use React\EventLoop\LoopInterface;
2016
use React\Promise\Deferred;
2117
use React\Promise\PromiseInterface;
@@ -30,16 +26,10 @@
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

Comments
 (0)