@@ -55,39 +55,3 @@ async def execute_mcp_tool_with_endpoint(
5555 except Exception :
5656 data = {"raw" : resp .text }
5757 return json .dumps (data , ensure_ascii = False )
58-
59-
60- # Synchronous helpers for use inside threads
61- def execute_mcp_tool_sync (name : str , params : Dict [str , Any ]) -> str :
62- ep = os .environ .get ("MCP_HTTP_ENDPOINT" )
63- if not ep :
64- raise RuntimeError ("MCP_HTTP_ENDPOINT not configured" )
65- url = f"{ _normalize_endpoint (ep )} /tools/execute"
66- payload = {"name" : name , "arguments" : params }
67- headers = {"Content-Type" : "application/json" }
68- timeout = float (os .environ .get ("MCP_HTTP_TIMEOUT" , "15" ))
69- with httpx .Client (timeout = timeout ) as client :
70- resp = client .post (url , json = payload , headers = headers )
71- resp .raise_for_status ()
72- try :
73- data = resp .json ()
74- except Exception :
75- data = {"raw" : resp .text }
76- return json .dumps (data , ensure_ascii = False )
77-
78-
79- def execute_mcp_tool_with_endpoint_sync (
80- endpoint : str , name : str , params : Dict [str , Any ]
81- ) -> str :
82- url = f"{ _normalize_endpoint (endpoint )} /tools/execute"
83- payload = {"name" : name , "arguments" : params }
84- headers = {"Content-Type" : "application/json" }
85- timeout = float (os .environ .get ("MCP_HTTP_TIMEOUT" , "15" ))
86- with httpx .Client (timeout = timeout ) as client :
87- resp = client .post (url , json = payload , headers = headers )
88- resp .raise_for_status ()
89- try :
90- data = resp .json ()
91- except Exception :
92- data = {"raw" : resp .text }
93- return json .dumps (data , ensure_ascii = False )
0 commit comments