feat: add ClientRequestContext type alias for client-side handlers (#1989)
This commit is contained in:
parent
74f41ff1ae
commit
4fc49c62bd
2 changed files with 55 additions and 37 deletions
20
src/mcp/shared/_context.py
Normal file
20
src/mcp/shared/_context.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
"""Request context for MCP handlers."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Generic
|
||||
|
||||
from typing_extensions import TypeVar
|
||||
|
||||
from mcp.shared.session import BaseSession
|
||||
from mcp.types import RequestId, RequestParamsMeta
|
||||
|
||||
SessionT = TypeVar("SessionT", bound=BaseSession[Any, Any, Any, Any, Any])
|
||||
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class RequestContext(Generic[SessionT]):
|
||||
"""Common context for handling incoming requests."""
|
||||
|
||||
request_id: RequestId
|
||||
meta: RequestParamsMeta | None
|
||||
session: SessionT
|
||||
|
|
@ -5,7 +5,7 @@ from typing import Generic
|
|||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from mcp.shared.context import RequestContext, SessionT
|
||||
from mcp.shared._context import RequestContext, SessionT
|
||||
from mcp.types import ProgressToken
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue