How a client reaches its server (Effect's McpClient.Transport):
stdio and http build one, and TransportService(protocol, request, notify, is_callable) makes one of three functions (a test
double, say).
Attributes#
| Attribute | Type | Description |
|---|---|---|
protocol | ClientProtocol = protocol | The protocol adapter of the version the client speaks. |
Functions#
__init__#
__init__(protocol, request, notify, is_callable) -> None| Parameter | Type | Description |
|---|---|---|
protocol | ClientProtocol | |
request | Callable[[JsonObject, Tool | None], Effect[JsonObject, McpClientError]] | |
notify | Callable[[JsonObject], Effect[None, McpClientError]] | |
is_callable | Callable[[Tool], bool] |
def __init__(
self,
protocol: ClientProtocol,
request: Callable[[JsonObject, Tool | None], Effect[JsonObject, McpClientError]],
notify: Callable[[JsonObject], Effect[None, McpClientError]],
is_callable: Callable[[Tool], bool],
) -> None:
self.protocol = protocol
self._request = request
self._notify = notify
self._is_callable = is_callablerequest#
request(message, tool) -> Effect[JsonObject, McpClientError]Send the JSON-RPC request message and wait for its response
(a JSON-RPC error response included); tool supplies a tool
call's routing headers. Fails with an McpClientError when the
message cannot be sent or read, a message exceeds the size limit,
the server answers an HTTP error status or no or a mismatched
response, or the transport has closed. Interrupting it
tells the server the request was cancelled (except initialize,
and on 2026-07-28 HTTP).
| Parameter | Type | Description |
|---|---|---|
message | JsonObject | |
tool | Tool | None |
Returns Effect[JsonObject, McpClientError]
def request(self, message: JsonObject, tool: Tool | None) -> Effect[JsonObject, McpClientError]:
"""Send the JSON-RPC request ``message`` and wait for its response
(a JSON-RPC error response included); ``tool`` supplies a tool
call's routing headers. Fails with an ``McpClientError`` when the
message cannot be sent or read, a message exceeds the size limit,
the server answers an HTTP error status or no or a mismatched
response, or the transport has closed. Interrupting it
tells the server the request was cancelled (except ``initialize``,
and on 2026-07-28 HTTP)."""
return self._request(message, tool)notify#
notify(message) -> Effect[None, McpClientError]Send the JSON-RPC notification message without waiting for a
reply. Fails with an McpClientError when it cannot be sent, the
server answers an HTTP error status, or the transport has closed.
| Parameter | Type | Description |
|---|---|---|
message | JsonObject |
Returns Effect[None, McpClientError]
def notify(self, message: JsonObject) -> Effect[None, McpClientError]:
"""Send the JSON-RPC notification ``message`` without waiting for a
reply. Fails with an ``McpClientError`` when it cannot be sent, the
server answers an HTTP error status, or the transport has closed."""
return self._notify(message)is_callable#
is_callable(tool) -> boolWhether this transport can route a call to tool: always on
stdio; on 2026-07-28 HTTP only when its header parameters are
valid.
| Parameter | Type | Description |
|---|---|---|
tool | Tool |
Returns bool
def is_callable(self, tool: Tool) -> bool:
"""Whether this transport can route a call to ``tool``: always on
stdio; on 2026-07-28 HTTP only when its header parameters are
valid."""
return self._is_callable(tool)