""" Source :https://github.com/modelcontextprotocol/python-sdk/blob/6353dd192c41b891ef3bf1dfc093db46f6e2175a/README.md?plain=1#L779 Author: Alex Punnen Status: Demo """ from mcp.client.streamable_http import streamablehttp_client from mcp import ClientSession async def main(): # Connect to a streamable HTTP server async with streamablehttp_client("http://127.0.0.0:4200/mcp") as ( read_stream, write_stream, _, ): # Create a session using the client streams async with ClientSession(read_stream, write_stream) as session: # Initialize the connection await session.initialize() # Call a tool tools = await session.list_tools() print("Available tools:", tools) tool_result = await session.call_tool("add", {"a": 1, "b": 2}) print("Tool result:", tool_result) if __name__ == "__main__": import asyncio asyncio.run(main())