File size: 627 Bytes
9677fde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""LangChain / LangGraph: bind the Space's tools to any chat model."""
import asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient

SPACE = "https://YOUR-SPACE.hf.space"

async def main():
    client = MultiServerMCPClient({
        "swmm": {"url": f"{SPACE}/mcp", "transport": "streamable_http"},
    })
    tools = await client.get_tools()
    print([t.name for t in tools])
    # from langgraph.prebuilt import create_react_agent
    # agent = create_react_agent("anthropic:claude-sonnet-4-5", tools)
    # result = await agent.ainvoke({"messages": "Upload and analyse my model ..."})

asyncio.run(main())