-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmcp_client.py
More file actions
34 lines (28 loc) · 870 Bytes
/
mcp_client.py
File metadata and controls
34 lines (28 loc) · 870 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
import os
import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from mcp_use import MCPAgent, MCPClient
async def main():
load_dotenv()
config = {
"mcpServers": {
"gsuite": {
"command": "python",
"args": [f"{os.getenv("MCP_SERVER_ABS_PATH")}"],
}
}
}
client = MCPClient.from_dict(config)
llm = ChatOpenAI(model="gpt-4o")
# Create agent with the client
agent = MCPAgent(llm=llm, client=client, max_steps=30)
result = await agent.run(
"""
Create a Google Calendar Event based on the content of the last mail being sent to my inbox.
If you cannot create an event, create a sort of "reminder event" in order to remind me to check that email.
""",
)
print(f"\nResult: {result}")
if __name__ == "__main__":
asyncio.run(main())