MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / for_loop

Method for_loop

src/mcp/server/connection.py:184–202  ·  view source on GitHub ↗

A connection for the handshake-driven loop path. Not born-ready: `initialized` is set later by the kernel when `notifications/initialized` arrives. `protocol_version` is seeded from the transport hint (or `LATEST_HANDSHAKE_VERSION`) so it's never `None`; the handshak

(
        cls,
        outbound: Outbound,
        *,
        session_id: str | None = None,
        protocol_version_hint: str | None = None,
    )

Source from the content-addressed store, hash-verified

182
183 @classmethod
184 def for_loop(
185 cls,
186 outbound: Outbound,
187 *,
188 session_id: str | None = None,
189 protocol_version_hint: str | None = None,
190 ) -> Connection:
191 """A connection for the handshake-driven loop path.
192
193 Not born-ready: `initialized` is set later by the kernel when
194 `notifications/initialized` arrives. `protocol_version` is seeded from
195 the transport hint (or `LATEST_HANDSHAKE_VERSION`) so it's never `None`;
196 the handshake overwrites it once negotiated.
197 """
198 return cls(
199 outbound,
200 protocol_version=protocol_version_hint if protocol_version_hint is not None else LATEST_HANDSHAKE_VERSION,
201 session_id=session_id,
202 )
203
204 @property
205 def has_standalone_channel(self) -> bool:

Calls

no outgoing calls