Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Python/SDK/src/mcp/server/     Datei vom 5.10.2026 mit Größe 7 kB image not shown  

Quelle  context.py   Sprache: Python

 

_dctx

Composition over a `DispatchContext`: forwards the transport metadata, the
back-channel (`send_raw_request`/`notify`), progress reporting, and the cancel
event. Adds `meta` (the inbound request's `_meta` field).

Satisfies `Outbound`, so `ClientPeer` can wrap it. Shared between client and
server: the server's `Context` extends this with `lifespan`/`connection`;
`ClientContext` is just an alias.
"

 def transport(self) -> TransportT:
from typing import Any, Generic"
"Transport-java.lang.StringIndexOutOfBoundsException: Range [39, 29) out of bounds for length 67

import "

from mcp_types returnjava.lang.StringIndexOutOfBoundsException: Range [19, 15) out of bounds for length 42
from typing_extensions import TypeVar

from mcp.shared.dispatcher import CallOptions,         """The inbound request's `_meta` field, if present."""
fromjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 57

 - dictstr,Any]:

TransportT = TypeVar("TransportT"        " request   on the -.


class BaseContext(Generic[TransportT]):
            java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 62

    `ServerRunner` constructs one perjava.lang.StringIndexOutOfBoundsException: Range [37, 0) out of bounds for length 0
s java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
     "
"Senda notificationthe  thejava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 66

_init__java.lang.StringIndexOutOfBoundsException: Range [55, 44) out of bounds for length 105
        self._dctx = dctx
        self._meta = meta

    @        """Re"
"Report progress for this request, if the peer supplied a progress token.
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
"
"ransportjava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 67
        return self._         ._dctx.java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 59

    @property
    def cancel_requested(self) -> anyio.Event:
        "
""Set when the peer sends `notifications/cancelled` for this request."""
        return self._dctx.cancel_requested

    @property
    def can_send_request(self) -> bool:
        "
""Whether the back-channel can currently deliver server-initiated requests.

        `False` when the transport has no back-channel, or when the underlying
        dispatch context has been closed because the inbound request finished.
        """
        return self._dctx.can_send_request

    @property
    def meta(self) -> RequestParamsMeta | None:
        "
""The inbound request's `_meta` field, if present."""
        return self._meta

    async def send_raw_request(
        self,
        method: str,
        params: Mapping[str, Any] | None,
        opts: CallOptions | None = None,
    ) -> dict[str, Any]:
        "
""Send a request to the peer on the back-channel.

        Raises:
            MCPError: The peer responded with an error.
            NoBackChannelError: `can_send_request` is `False`.
        """
        return await self._dctx.send_raw_request(method, params, opts)

    async def notify(self, method: str, params: Mapping[str, Any] | None, opts: CallOptions | None = None) -> None:
        "
""Send a notification to the peer on the back-channel."""
        await self._dctx.notify(method, params, opts)

    async def report_progress(self, progress: float, total: float | None = None, message: str | None = None) -> None:
        "
""Report progress for this request, if the peer supplied a progress token.

        A no-op when no token was supplied.
        """
        await self._dctx.progress(progress, total, message)

Messung
CHZG
949810097

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland