@@ -768,9 +768,8 @@ def test_mcp_tools(client):
768768 )
769769 ],},
770770 )
771- response = chat .send_message ('What is the weather in Boston?' );
772- response = chat .send_message ('What is the weather in San Francisco?' );
773-
771+ response = chat .send_message ('What is the weather in Boston?' )
772+ response = chat .send_message ('What is the weather in San Francisco?' )
774773
775774
776775def test_mcp_tools_stream (client ):
@@ -842,3 +841,101 @@ async def test_async_mcp_tools_stream(client):
842841 'What is the weather in San Francisco?'
843842 ):
844843 pass
844+
845+
846+ def test_server_side_mcp_tools (client ):
847+ with pytest_helper .exception_if_vertex (client , ValueError ):
848+ chat = client .chats .create (
849+ model = 'gemini-2.5-flash' ,
850+ config = {
851+ 'tools' : [
852+ {
853+ 'mcp_servers' : [
854+ {
855+ 'name' : 'weather_server' ,
856+ 'streamable_http_transport' : {
857+ 'url' : (
858+ 'https://gemini-api-demos.uc.r.appspot.com/mcp'
859+ ),
860+ 'headers' : {
861+ 'AUTHORIZATION' : 'Bearer github_pat_XXXX' ,
862+ },
863+ 'timeout' : '10s' ,
864+ },
865+ },
866+ ],
867+ },
868+ ],
869+ },
870+ )
871+ response = chat .send_message ('What is the weather in Boston on 02/02/2026?' )
872+ response = chat .send_message (
873+ 'What is the weather in San Francisco on 02/02/2026?'
874+ )
875+
876+
877+ def test_server_side_mcp_tools_stream (client ):
878+ with pytest_helper .exception_if_vertex (client , ValueError ):
879+ chat = client .chats .create (
880+ model = 'gemini-2.5-flash' ,
881+ config = {
882+ 'tools' : [
883+ {
884+ 'mcp_servers' : [
885+ {
886+ 'name' : 'weather_server' ,
887+ 'streamable_http_transport' : {
888+ 'url' : (
889+ 'https://gemini-api-demos.uc.r.appspot.com/mcp'
890+ ),
891+ 'headers' : {
892+ 'AUTHORIZATION' : 'Bearer github_pat_XXXX' ,
893+ },
894+ 'timeout' : '10s' ,
895+ },
896+ },
897+ ],
898+ },
899+ ],
900+ },
901+ )
902+ for chunk in chat .send_message_stream (
903+ 'What is the weather in Boston on 02/02/2026?'
904+ ):
905+ pass
906+ for chunk in chat .send_message_stream (
907+ 'What is the weather in San Francisco on 02/02/2026?'
908+ ):
909+ pass
910+
911+
912+ @pytest .mark .asyncio
913+ async def test_async_server_side_mcp_tools (client ):
914+ with pytest_helper .exception_if_vertex (client , ValueError ):
915+ chat = client .aio .chats .create (
916+ model = 'gemini-2.5-flash' ,
917+ config = {
918+ 'tools' : [
919+ {
920+ 'mcp_servers' : [
921+ {
922+ 'name' : 'weather_server' ,
923+ 'streamable_http_transport' : {
924+ 'url' : (
925+ 'https://gemini-api-demos.uc.r.appspot.com/mcp'
926+ ),
927+ 'headers' : {
928+ 'AUTHORIZATION' : 'Bearer github_pat_XXXX' ,
929+ },
930+ 'timeout' : '10s' ,
931+ },
932+ },
933+ ],
934+ },
935+ ],
936+ },
937+ )
938+ await chat .send_message ('What is the weather in Boston on 02/02/2026?' )
939+ await chat .send_message (
940+ 'What is the weather in San Francisco on 02/02/2026?'
941+ )
0 commit comments