1- """`Connection` — per-client connection state and the standalone outbound channel.
1+ """`Connection` - per-client connection state and the standalone outbound channel.
22
3- Always present on `Context` (never `` None` `), even in stateless deployments.
4- Holds peer info populated at `` initialize` ` time, per-connection scratch
5- `` state`` and an `` exit_stack` ` for teardown, and an `Outbound` for the
3+ Always present on `Context` (never `None`), even in stateless deployments.
4+ Holds peer info populated at `initialize` time, per-connection scratch
5+ `state` and an `exit_stack` for teardown, and an `Outbound` for the
66standalone stream (the SSE GET stream in streamable HTTP, or the single duplex
77stream in stdio).
88
99`notify` is best-effort: it never raises. If there's no standalone channel
1010(stateless HTTP) or the stream has been dropped, the notification is
11- debug-logged and silently discarded — server-initiated notifications are
11+ debug-logged and silently discarded - server-initiated notifications are
1212inherently advisory. `send_raw_request` *does* raise `NoBackChannelError` when
1313there's no channel; `ping` is the only spec-sanctioned standalone request.
1414"""
@@ -43,7 +43,7 @@ class Connection(TypedServerRequestMixin):
4343 """Per-client connection state and standalone-stream `Outbound`.
4444
4545 Constructed by `ServerRunner` once per connection. The peer-info fields are
46- `` None`` until `` initialize`` completes; `` initialized` ` is set then.
46+ `None` until `initialize` completes; `initialized` is set then.
4747 """
4848
4949 def __init__ (self , outbound : Outbound , * , has_standalone_channel : bool , session_id : str | None = None ) -> None :
@@ -63,8 +63,8 @@ def __init__(self, outbound: Outbound, *, has_standalone_channel: bool, session_
6363 self .exit_stack : AsyncExitStack = AsyncExitStack ()
6464 """Cleanup stack unwound by `ServerRunner` when the connection closes.
6565
66- Push context managers (`` await exit_stack.enter_async_context(...)` `)
67- or callbacks (`` exit_stack.push_async_callback(...)` `) from handlers or
66+ Push context managers (`await exit_stack.enter_async_context(...)`)
67+ or callbacks (`exit_stack.push_async_callback(...)`) from handlers or
6868 middleware to register per-connection teardown. Unwound LIFO after
6969 `dispatcher.run()` returns, shielded from cancellation."""
7070
@@ -76,13 +76,13 @@ async def send_raw_request(
7676 ) -> dict [str , Any ]:
7777 """Send a raw request on the standalone stream.
7878
79- Low-level `Outbound` channel. Prefer the typed `` send_request` ` (from
79+ Low-level `Outbound` channel. Prefer the typed `send_request` (from
8080 `TypedServerRequestMixin`) or the convenience methods below; use this
8181 directly only for off-spec messages.
8282
8383 Raises:
8484 MCPError: The peer responded with an error.
85- NoBackChannelError: `` has_standalone_channel`` is `` False` `.
85+ NoBackChannelError: `has_standalone_channel` is `False`.
8686 """
8787 if not self .has_standalone_channel :
8888 raise NoBackChannelError (method )
@@ -103,16 +103,16 @@ async def notify(self, method: str, params: Mapping[str, Any] | None) -> None:
103103 logger .debug ("dropped %s: standalone stream closed" , method )
104104
105105 async def ping (self , * , meta : Meta | None = None , opts : CallOptions | None = None ) -> None :
106- """Send a `` ping` ` request on the standalone stream.
106+ """Send a `ping` request on the standalone stream.
107107
108108 Raises:
109109 MCPError: The peer responded with an error.
110- NoBackChannelError: `` has_standalone_channel`` is `` False` `.
110+ NoBackChannelError: `has_standalone_channel` is `False`.
111111 """
112112 await self .send_raw_request ("ping" , dump_params (None , meta ), opts )
113113
114114 async def log (self , level : LoggingLevel , data : Any , logger : str | None = None , * , meta : Meta | None = None ) -> None :
115- """Send a `` notifications/message` ` log entry on the standalone stream. Best-effort."""
115+ """Send a `notifications/message` log entry on the standalone stream. Best-effort."""
116116 params : dict [str , Any ] = {"level" : level , "data" : data }
117117 if logger is not None :
118118 params ["logger" ] = logger
@@ -133,9 +133,9 @@ async def send_resource_updated(self, uri: str, *, meta: Meta | None = None) ->
133133 def check_capability (self , capability : ClientCapabilities ) -> bool :
134134 """Return whether the connected client declared the given capability.
135135
136- Returns `` False`` if `` initialize` ` hasn't completed yet.
136+ Returns `False` if `initialize` hasn't completed yet.
137137 """
138- # TODO: redesign — mirrors v1 ServerSession.check_client_capability
138+ # TODO: redesign - mirrors v1 ServerSession.check_client_capability
139139 # verbatim for parity.
140140 if self .client_capabilities is None :
141141 return False
0 commit comments