forked from mcp-use/mcp-use
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp_everything.py
More file actions
39 lines (30 loc) · 1.05 KB
/
mcp_everything.py
File metadata and controls
39 lines (30 loc) · 1.05 KB
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
36
37
38
39
"""
This example shows how to test the different functionalities of MCPs using the MCP server from
anthropic.
"""
import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from mcp_use import MCPAgent, MCPClient
everything_server = {
"mcpServers": {"everything": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-everything"]}}
}
async def main():
"""Run the example using a configuration file."""
load_dotenv()
client = MCPClient(config=everything_server)
llm = ChatOpenAI(model="gpt-5", temperature=0)
agent = MCPAgent(llm=llm, client=client, max_steps=30, pretty_print=True)
result = await agent.run(
"""
Hello, you are a tester can you please answer the following questions:
- Which resources do you have access to?
- Which prompts do you have access to?
- Which tools do you have access to?
""",
max_steps=30,
)
print(f"\nResult: {result}")
if __name__ == "__main__":
# Run the appropriate example
asyncio.run(main())