Skip to content

Commit 5540d80

Browse files
committed
fix: address coverage gaps and stale RequestSender docstring
- tests: replace unreachable 'return {}' with 'raise NotImplementedError' (already in coverage exclude_also) and collapse send_request+return into one statement - dispatcher: RequestSender docstring no longer claims Dispatcher satisfies it (Dispatcher exposes call(), not send_request())
1 parent f332c59 commit 5540d80

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/mcp/shared/dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class CallOptions(TypedDict, total=False):
6666
class RequestSender(Protocol):
6767
"""Anything that can send a request and await its result.
6868
69-
Both `Dispatcher` (for top-level outbound calls) and `DispatchContext`
70-
(for server-to-client calls made *during* an inbound request) satisfy this.
69+
`DispatchContext` satisfies this; `PeerMixin` (and `Connection`/`Peer`) wrap
70+
a `RequestSender` to provide typed request methods.
7171
"""
7272

7373
async def send_request(

tests/shared/test_dispatcher.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async def on_call(
109109
ctx: DispatchContext[TransportContext], method: str, params: Mapping[str, Any] | None
110110
) -> dict[str, Any]:
111111
await anyio.sleep_forever()
112-
return {}
112+
raise NotImplementedError
113113

114114
async with running_pair(server_on_call=on_call) as (client, *_):
115115
with anyio.fail_after(5), pytest.raises(MCPError) as exc:
@@ -148,8 +148,7 @@ async def test_ctx_send_request_raises_nobackchannelerror_when_transport_disallo
148148
async def server_on_call(
149149
ctx: DispatchContext[TransportContext], method: str, params: Mapping[str, Any] | None
150150
) -> dict[str, Any]:
151-
await ctx.send_request("sampling/createMessage", None)
152-
return {}
151+
return await ctx.send_request("sampling/createMessage", None)
153152

154153
async with running_pair(server_on_call=server_on_call, can_send_request=False) as (client, *_):
155154
with anyio.fail_after(5), pytest.raises(NoBackChannelError) as exc:

0 commit comments

Comments
 (0)