File tree Expand file tree Collapse file tree 3 files changed +100
-126
lines changed
examples/clients/simple-sampling-client
mcp_simple_sampling_client Expand file tree Collapse file tree 3 files changed +100
-126
lines changed Original file line number Diff line number Diff line change 55import json
66import typing
77
8+ import httpx
89import pydantic_settings
9- import requests
1010
1111import mcp
1212from mcp .client .streamable_http import streamablehttp_client
@@ -77,7 +77,7 @@ def get_llm_response(
7777
7878 extra_arguments = {} if tools is None else {"tool_choice" : "auto" , "tools" : tools }
7979
80- chat_completion = requests .post (
80+ chat_completion = httpx .post (
8181 self .api_url ,
8282 json = {
8383 "messages" : updated_chat_history ,
@@ -92,9 +92,10 @@ def get_llm_response(
9292 "Content-Type" : "application/json" ,
9393 },
9494 timeout = 300 ,
95- ).json ()
95+ )
96+ chat_completion .raise_for_status ()
9697
97- return chat_completion
98+ return chat_completion . json ()
9899
99100 async def fetch_mcp_tools (self : "SamplingClient" ) -> list [Tool ]:
100101 """List available tools."""
Original file line number Diff line number Diff line change @@ -37,10 +37,10 @@ classifiers = [
3737 " Typing :: Typed" ,
3838]
3939dependencies = [
40+ " httpx>=0.27.1" ,
4041 " mcp>=1.16.0,<2" ,
41- " pydantic>=2.11.10,<3" ,
42- " pydantic-settings>=2.11.0,<3" ,
43- " requests>=2.32.5,<3" ,
42+ " pydantic>=2.11.0,<3.0.0" ,
43+ " pydantic-settings>=2.5.2" ,
4444]
4545
4646[project .scripts ]
You can’t perform that action at this time.
0 commit comments