refactor: split RequestContext between server and client (#1987)
This commit is contained in:
parent
050aeb6456
commit
b1f7eec3cd
2 changed files with 210 additions and 212 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Any, cast
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
import anyio
|
||||
|
|
@ -14,7 +14,7 @@ from mcp.server.session import ServerSession
|
|||
from mcp.shared.context import RequestContext
|
||||
from mcp.shared.message import SessionMessage
|
||||
from mcp.shared.progress import progress
|
||||
from mcp.shared.session import BaseSession, RequestResponder
|
||||
from mcp.shared.session import RequestResponder
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
|
@ -279,14 +279,10 @@ async def test_progress_context_manager():
|
|||
request_id="test-request",
|
||||
session=client_session,
|
||||
meta={"progress_token": progress_token},
|
||||
lifespan_context=None,
|
||||
)
|
||||
|
||||
# cast for type checker
|
||||
typed_context = cast(RequestContext[BaseSession[Any, Any, Any, Any, Any], Any], request_context)
|
||||
|
||||
# Utilize progress context manager
|
||||
with progress(typed_context, total=100) as p:
|
||||
with progress(request_context, total=100) as p:
|
||||
await p.progress(10, message="Loading configuration...")
|
||||
await p.progress(30, message="Connecting to database...")
|
||||
await p.progress(40, message="Fetching data...")
|
||||
|
|
|
|||
|
|
@ -1344,7 +1344,7 @@ async def test_streamablehttp_server_sampling(basic_server: None, basic_server_u
|
|||
|
||||
# Define sampling callback that returns a mock response
|
||||
async def sampling_callback(
|
||||
context: RequestContext[ClientSession, Any],
|
||||
context: RequestContext[ClientSession],
|
||||
params: types.CreateMessageRequestParams,
|
||||
) -> types.CreateMessageResult:
|
||||
nonlocal sampling_callback_invoked, captured_message_params
|
||||
|
|
|
|||
Loading…
Reference in a new issue