-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp_server_demo.py
More file actions
35 lines (29 loc) · 927 Bytes
/
mcp_server_demo.py
File metadata and controls
35 lines (29 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from dotenv import load_dotenv
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
load_dotenv()
async def main():
client = MultiServerMCPClient(
{
"mcp-server-chart": {
"command": "npx",
"args": ["-y", "@antv/mcp-server-chart"],
"transport": "stdio",
},
}
)
tools = await client.get_tools()
agent = create_react_agent("deepseek:deepseek-chat", tools)
chart_response = await agent.ainvoke(
{
"messages": [
{"role": "user", "content": "Please generate a simple bar chart."
"There are 3 categories: A, B, and C."
"The values are 10, 20, and 30 respectively."}
]
}
)
print(chart_response)
if __name__ == "__main__":
import asyncio
asyncio.run(main())