Typed server-to-client request methods over a wrapped `Outbound`. Use this when you have a bare dispatcher (or any `Outbound`) and want the typed methods (`sample`, `elicit_form`, `elicit_url`, `list_roots`, `ping`) without writing your own host class.
| 63 | |
| 64 | |
| 65 | class ClientPeer: |
| 66 | """Typed server-to-client request methods over a wrapped `Outbound`. |
| 67 | |
| 68 | Use this when you have a bare dispatcher (or any `Outbound`) and want the |
| 69 | typed methods (`sample`, `elicit_form`, `elicit_url`, `list_roots`, |
| 70 | `ping`) without writing your own host class. |
| 71 | """ |
| 72 | |
| 73 | def __init__(self, outbound: Outbound) -> None: |
| 74 | self._outbound = outbound |
| 75 | |
| 76 | async def send_raw_request( |
| 77 | self, |
| 78 | method: str, |
| 79 | params: Mapping[str, Any] | None, |
| 80 | opts: CallOptions | None = None, |
| 81 | ) -> dict[str, Any]: |
| 82 | return await self._outbound.send_raw_request(method, params, opts) |
| 83 | |
| 84 | async def notify(self, method: str, params: Mapping[str, Any] | None, opts: CallOptions | None = None) -> None: |
| 85 | await self._outbound.notify(method, params, opts) |
| 86 | |
| 87 | @overload |
| 88 | @deprecated("The sampling capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning) |
| 89 | async def sample( |
| 90 | self, |
| 91 | messages: list[SamplingMessage], |
| 92 | *, |
| 93 | max_tokens: int, |
| 94 | system_prompt: str | None = None, |
| 95 | include_context: IncludeContext | None = None, |
| 96 | temperature: float | None = None, |
| 97 | stop_sequences: list[str] | None = None, |
| 98 | metadata: dict[str, Any] | None = None, |
| 99 | model_preferences: ModelPreferences | None = None, |
| 100 | tools: None = None, |
| 101 | tool_choice: ToolChoice | None = None, |
| 102 | meta: Meta | None = None, |
| 103 | opts: CallOptions | None = None, |
| 104 | ) -> CreateMessageResult: ... |
| 105 | @overload |
| 106 | @deprecated("The sampling capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning) |
| 107 | async def sample( |
| 108 | self, |
| 109 | messages: list[SamplingMessage], |
| 110 | *, |
| 111 | max_tokens: int, |
| 112 | system_prompt: str | None = None, |
| 113 | include_context: IncludeContext | None = None, |
| 114 | temperature: float | None = None, |
| 115 | stop_sequences: list[str] | None = None, |
| 116 | metadata: dict[str, Any] | None = None, |
| 117 | model_preferences: ModelPreferences | None = None, |
| 118 | tools: list[Tool], |
| 119 | tool_choice: ToolChoice | None = None, |
| 120 | meta: Meta | None = None, |
| 121 | opts: CallOptions | None = None, |
| 122 | ) -> CreateMessageResultWithTools: ... |
no outgoing calls