first vommit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import asyncio
|
||||
from mcp import ClientSession, StreamableHTTPTransport
|
||||
|
||||
|
||||
class MCPClient:
|
||||
|
||||
def __init__(self, url: str):
|
||||
|
||||
self.url = url
|
||||
|
||||
async def _call(self, tool, args):
|
||||
|
||||
transport = StreamableHTTPTransport(self.url)
|
||||
|
||||
async with ClientSession(transport) as session:
|
||||
|
||||
await session.initialize()
|
||||
|
||||
result = await session.call_tool(tool, args)
|
||||
|
||||
return result
|
||||
|
||||
def call_tool(self, tool, args):
|
||||
|
||||
return asyncio.run(self._call(tool, args))
|
||||
Reference in New Issue
Block a user