Skip to content

Commit 666237d

Browse files
google-labs-jules[bot]james2037
authored andcommitted
Refactor: Remove unused preferSseStream method from TransportInterface
The preferSseStream method was defined in TransportInterface and implemented as a no-op in HttpTransport, StdioTransport, and the MockTransport. Codebase analysis confirmed that this method was not called anywhere, nor was it part of the documented external API in README.md or examples. The HttpTransport currently does not support Server-Sent Events (SSE), and the MCP specification (2025-03-26) makes SSE an optional feature for servers. As the method provided no functionality towards current or planned SSE capabilities and was unused, it has been removed to simplify the interface and reduce potential confusion. This change involved: - Removing the method definition from TransportInterface. - Removing the implementations from HttpTransport, StdioTransport, and MockTransport. - Verifying that all tests and linters pass after the removal.
1 parent 87cc05c commit 666237d

File tree

4 files changed

+0
-43
lines changed

4 files changed

+0
-43
lines changed

src/Transport/HttpTransport.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,4 @@ public function getResponse(): ResponseInterface
266266
}
267267
return $this->response;
268268
}
269-
270-
/**
271-
* Indicates a preference for using Server-Sent Events (SSE) for streaming responses, if applicable.
272-
*
273-
* Transports that support SSE (like HttpTransport) can use this hint to switch
274-
* their response mode. Other transports can ignore this.
275-
*
276-
* @param bool $prefer True to prefer SSE, false otherwise.
277-
*/
278-
public function preferSseStream(bool $prefer = true): void
279-
{
280-
// Default implementation does nothing, to be overridden by transports that support SSE.
281-
// In a real HttpTransport that supports SSE, this method would set a flag
282-
// to change response content-type and formatting in the send() method.
283-
// For this simplified version, it remains a no-op.
284-
}
285269
}

src/Transport/StdioTransport.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,4 @@ public function isStreamOpen(): bool
203203
{
204204
return false;
205205
}
206-
207-
/**
208-
* Indicates a preference for using Server-Sent Events (SSE) for streaming responses, if applicable.
209-
* StdioTransport does not support SSE, so this is a no-op.
210-
*
211-
* @param bool $prefer True to prefer SSE, false otherwise.
212-
*/
213-
public function preferSseStream(bool $prefer = true): void
214-
{
215-
// StdioTransport does not support SSE.
216-
}
217206
}

src/Transport/TransportInterface.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,4 @@ public function isClosed(): bool;
6969
* @return bool True if a stream is actively open, false otherwise.
7070
*/
7171
public function isStreamOpen(): bool;
72-
73-
/**
74-
* Hints to the transport that Server-Sent Events (SSE) are preferred for the response stream, if applicable.
75-
*
76-
* Transports that support SSE (e.g., HttpTransport) can use this to modify
77-
* how they format and send responses. Transports that do not support SSE can ignore this hint.
78-
*
79-
* @param bool $prefer True to indicate a preference for SSE streaming, false otherwise.
80-
*/
81-
public function preferSseStream(bool $prefer = true): void;
8272
}

tests/Util/MockTransport.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ public function log(string $message): void
8080
// error_log("MockTransport Log: " . $message); // For debugging tests
8181
}
8282

83-
public function preferSseStream(bool $prefer = true): void
84-
{
85-
// No-op for this mock implementation.
86-
// Could store the preference if tests need to assert it was called.
87-
}
88-
8983
/**
9084
* Checks if the transport stream is currently open.
9185
* For this mock, defaults to false. Can be made configurable if needed.

0 commit comments

Comments
 (0)