Skip to content

Commit 6f2c1a1

Browse files
committed
fix: use streamable_http_client instead of deprecated streamablehttp_client
- Update import in mcp_proxy_for_aws/client.py to use streamable_http_client - Update fastmcp dependency from (>=2.13.1,<2.14.1) to (>=2.14.1,<3.0.0) - Adapt to new API where httpx client is created and passed instead of factory - Update test mocks to reflect the new API structure - Resolves deprecation warning introduced in fastmcp 2.14.1+ Fixes #128
1 parent 9c1ab1f commit 6f2c1a1

File tree

4 files changed

+255
-47
lines changed

4 files changed

+255
-47
lines changed

mcp_proxy_for_aws/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from botocore.credentials import Credentials
1919
from contextlib import _AsyncGeneratorContextManager
2020
from datetime import timedelta
21-
from mcp.client.streamable_http import GetSessionIdCallback, streamablehttp_client
21+
from mcp.client.streamable_http import GetSessionIdCallback, streamable_http_client
2222
from mcp.shared._httpx_utils import McpHttpClientFactory, create_mcp_http_client
2323
from mcp.shared.message import SessionMessage
2424
from mcp_proxy_for_aws.sigv4_helper import SigV4HTTPXAuth
@@ -114,7 +114,7 @@ def aws_iam_streamablehttp_client(
114114
auth = SigV4HTTPXAuth(creds, aws_service, region)
115115

116116
# Return the streamable HTTP client context manager with AWS IAM authentication
117-
return streamablehttp_client(
117+
return streamable_http_client(
118118
url=endpoint,
119119
headers=headers,
120120
timeout=timeout,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description = "MCP Proxy for AWS"
1616
readme = "README.md"
1717
requires-python = ">=3.10,<3.15"
1818
dependencies = [
19-
"fastmcp (>=2.13.1,<2.14.1)",
19+
"fastmcp>=2.14.1,<3.0.0",
2020
"boto3>=1.41.0",
2121
"botocore[crt]>=1.41.0",
2222
]

tests/unit/test_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def test_boto3_session_parameters(
6060
mock_read, mock_write, mock_get_session = mock_streams
6161

6262
with patch('boto3.Session', return_value=mock_session) as mock_boto:
63-
with patch('mcp_proxy_for_aws.client.streamablehttp_client') as mock_stream_client:
63+
with patch('mcp_proxy_for_aws.client.streamable_http_client') as mock_stream_client:
6464
mock_stream_client.return_value.__aenter__ = AsyncMock(
6565
return_value=(mock_read, mock_write, mock_get_session)
6666
)
@@ -94,7 +94,7 @@ async def test_sigv4_auth_is_created_and_used(mock_session, mock_streams, servic
9494

9595
with patch('boto3.Session', return_value=mock_session):
9696
with patch('mcp_proxy_for_aws.client.SigV4HTTPXAuth') as mock_auth_cls:
97-
with patch('mcp_proxy_for_aws.client.streamablehttp_client') as mock_stream_client:
97+
with patch('mcp_proxy_for_aws.client.streamable_http_client') as mock_stream_client:
9898
mock_auth = Mock()
9999
mock_auth_cls.return_value = mock_auth
100100
mock_stream_client.return_value.__aenter__ = AsyncMock(
@@ -137,7 +137,7 @@ async def test_streamable_client_parameters(
137137
mock_read, mock_write, mock_get_session = mock_streams
138138

139139
with patch('boto3.Session', return_value=mock_session):
140-
with patch('mcp_proxy_for_aws.client.streamablehttp_client') as mock_stream_client:
140+
with patch('mcp_proxy_for_aws.client.streamable_http_client') as mock_stream_client:
141141
mock_stream_client.return_value.__aenter__ = AsyncMock(
142142
return_value=(mock_read, mock_write, mock_get_session)
143143
)
@@ -170,7 +170,7 @@ async def test_custom_httpx_client_factory_is_passed(mock_session, mock_streams)
170170
custom_factory = Mock()
171171

172172
with patch('boto3.Session', return_value=mock_session):
173-
with patch('mcp_proxy_for_aws.client.streamablehttp_client') as mock_stream_client:
173+
with patch('mcp_proxy_for_aws.client.streamable_http_client') as mock_stream_client:
174174
mock_stream_client.return_value.__aenter__ = AsyncMock(
175175
return_value=(mock_read, mock_write, mock_get_session)
176176
)
@@ -198,7 +198,7 @@ async def mock_aexit(*_):
198198
cleanup_called = True
199199

200200
with patch('boto3.Session', return_value=mock_session):
201-
with patch('mcp_proxy_for_aws.client.streamablehttp_client') as mock_stream_client:
201+
with patch('mcp_proxy_for_aws.client.streamable_http_client') as mock_stream_client:
202202
mock_stream_client.return_value.__aenter__ = AsyncMock(
203203
return_value=(mock_read, mock_write, mock_get_session)
204204
)
@@ -220,7 +220,7 @@ async def test_credentials_parameter_with_region(mock_streams):
220220
creds = Credentials('test_key', 'test_secret', 'test_token')
221221

222222
with patch('mcp_proxy_for_aws.client.SigV4HTTPXAuth') as mock_auth_cls:
223-
with patch('mcp_proxy_for_aws.client.streamablehttp_client') as mock_stream_client:
223+
with patch('mcp_proxy_for_aws.client.streamable_http_client') as mock_stream_client:
224224
mock_auth = Mock()
225225
mock_auth_cls.return_value = mock_auth
226226
mock_stream_client.return_value.__aenter__ = AsyncMock(
@@ -264,7 +264,7 @@ async def test_credentials_parameter_bypasses_boto3_session(mock_streams):
264264

265265
with patch('boto3.Session') as mock_boto:
266266
with patch('mcp_proxy_for_aws.client.SigV4HTTPXAuth'):
267-
with patch('mcp_proxy_for_aws.client.streamablehttp_client') as mock_stream_client:
267+
with patch('mcp_proxy_for_aws.client.streamable_http_client') as mock_stream_client:
268268
mock_stream_client.return_value.__aenter__ = AsyncMock(
269269
return_value=(mock_read, mock_write, mock_get_session)
270270
)

0 commit comments

Comments
 (0)