-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Bump mcp and other dependencies for Dependabot alerts
#4047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
7833b96
782a995
e8d0496
634d5eb
4e00834
99fa07d
94bc306
840099e
0194063
023a518
8922929
b53d48c
e706269
0885571
e832160
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,7 @@ async def sampling_callback( | |
| annotations=None, | ||
| meta=None, | ||
| ), | ||
| meta=None, | ||
| ) | ||
| ] | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ | |
| from mcp.client.session import ClientSession, ElicitationFnT, LoggingFnT | ||
| from mcp.client.sse import sse_client | ||
| from mcp.client.stdio import StdioServerParameters, stdio_client | ||
| from mcp.client.streamable_http import GetSessionIdCallback, streamablehttp_client | ||
| from mcp.client.streamable_http import GetSessionIdCallback, streamable_http_client | ||
| from mcp.shared import exceptions as mcp_exceptions | ||
| from mcp.shared.context import RequestContext | ||
| from mcp.shared.message import SessionMessage | ||
|
|
@@ -1134,8 +1134,10 @@ def _transport_client( | |
| ], | ||
| ]: ... | ||
|
|
||
| # Only used by MCPServerSSE which has a hang bug (https://github.com/modelcontextprotocol/python-sdk/issues/1811). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this just be on that subclass then? We may not need the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeahp I wanted to keep this lean but I made that change now |
||
| # Remove pragma once https://github.com/modelcontextprotocol/python-sdk/pull/1838 is released. | ||
| @asynccontextmanager | ||
| async def client_streams( | ||
| async def client_streams( # pragma: no cover | ||
| self, | ||
| ) -> AsyncIterator[ | ||
| tuple[ | ||
|
|
@@ -1144,7 +1146,7 @@ async def client_streams( | |
| ] | ||
| ]: | ||
| if self.http_client and self.headers: | ||
| raise ValueError('`http_client` is mutually exclusive with `headers`.') # pragma: no cover | ||
| raise ValueError('`http_client` is mutually exclusive with `headers`.') | ||
|
|
||
| transport_client_partial = functools.partial( | ||
| self._transport_client, | ||
|
|
@@ -1154,7 +1156,8 @@ async def client_streams( | |
| ) | ||
|
|
||
| if self.http_client is not None: | ||
| # TODO: Clean up once https://github.com/modelcontextprotocol/python-sdk/pull/1177 lands. | ||
| # sse_client still uses the old httpx_client_factory API (streamable_http_client uses http_client). | ||
| # This wrapper is needed until sse_client is updated to match streamable_http_client's API. | ||
| @asynccontextmanager | ||
| async def httpx_client_factory( | ||
| headers: dict[str, str] | None = None, | ||
|
|
@@ -1218,8 +1221,8 @@ def __get_pydantic_core_schema__(cls, _: Any, __: Any) -> CoreSchema: | |
| ) | ||
|
|
||
| @property | ||
| def _transport_client(self): | ||
| return sse_client # pragma: no cover | ||
| def _transport_client(self): # pragma: no cover | ||
| return sse_client | ||
|
|
||
| def __eq__(self, value: object, /) -> bool: | ||
| return super().__eq__(value) and isinstance(value, MCPServerSSE) and self.url == value.url | ||
|
|
@@ -1282,8 +1285,36 @@ def __get_pydantic_core_schema__(cls, _: Any, __: Any) -> CoreSchema: | |
| ) | ||
|
|
||
| @property | ||
| def _transport_client(self): | ||
| return streamablehttp_client | ||
| def _transport_client(self): # pragma: no cover | ||
| return streamable_http_client | ||
|
|
||
| @asynccontextmanager | ||
| async def client_streams( | ||
| self, | ||
| ) -> AsyncIterator[ | ||
| tuple[ | ||
| MemoryObjectReceiveStream[SessionMessage | Exception], | ||
| MemoryObjectSendStream[SessionMessage], | ||
| ] | ||
| ]: | ||
| # The new streamable_http_client API only accepts url and http_client. | ||
| # We need to create an httpx.AsyncClient with the desired timeout and headers. | ||
| if self.http_client is not None: | ||
| async with streamable_http_client(self.url, http_client=self.http_client) as ( | ||
| read_stream, | ||
| write_stream, | ||
| *_, | ||
| ): | ||
| yield read_stream, write_stream | ||
| else: | ||
| timeout = httpx.Timeout(self.timeout, read=self.read_timeout) | ||
| async with httpx.AsyncClient(timeout=timeout, headers=self.headers) as client: | ||
| async with streamable_http_client(self.url, http_client=client) as ( | ||
| read_stream, | ||
| write_stream, | ||
| *_, | ||
| ): | ||
| yield read_stream, write_stream | ||
|
dsfaccini marked this conversation as resolved.
Outdated
|
||
|
|
||
| def __eq__(self, value: object, /) -> bool: | ||
| return super().__eq__(value) and isinstance(value, MCPServerStreamableHTTP) and self.url == value.url | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the new types we could support here and below? Add a comment at lease please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the painful stuff is that
content: SamplingMessageContentBlock | list[SamplingMessageContentBlock]but I've moved the
NotImplementedErrorinto an explicit branch checking all rest-types and added anassert_neverat the endThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AudioContenteasily in theImageContentbranch above?map_from_sampling_content) but relatively easily could be, vs anything that is fundamentally unsupported. Just so people know what their options are when they hit this error (e.g. contribute a fix)