mirror of https://github.com/dapr/dapr-agents.git
Fix code formatting with ruff
This commit is contained in:
parent
94bf5d2a38
commit
83fc449e39
|
|
@ -5,6 +5,7 @@ from dotenv import load_dotenv
|
|||
from dapr_agents import AssistantAgent
|
||||
from dapr_agents.tool.mcp import MCPClient
|
||||
|
||||
|
||||
async def main():
|
||||
try:
|
||||
# Load MCP tools from server (stdio or sse)
|
||||
|
|
@ -38,7 +39,8 @@ async def main():
|
|||
except Exception as e:
|
||||
logging.exception("Error starting weather agent service", exc_info=e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_dotenv()
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
asyncio.run(main())
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -80,4 +80,4 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -3,13 +3,15 @@ import random
|
|||
|
||||
mcp = FastMCP("TestServer")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def get_weather(location: str) -> str:
|
||||
"""Get weather information for a specific location."""
|
||||
temperature = random.randint(60, 80)
|
||||
return f"{location}: {temperature}F."
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def jump(distance: str) -> str:
|
||||
"""Simulate a jump of a given distance."""
|
||||
return f"I jumped the following distance: {distance}"
|
||||
return f"I jumped the following distance: {distance}"
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ from dapr_agents.tool.mcp import MCPClient
|
|||
|
||||
load_dotenv()
|
||||
|
||||
async def main():
|
||||
|
||||
async def main():
|
||||
# Create the MCP client
|
||||
client = MCPClient()
|
||||
|
||||
|
|
@ -17,13 +17,13 @@ async def main():
|
|||
await client.connect_stdio(
|
||||
server_name="local",
|
||||
command=sys.executable, # Use the current Python interpreter
|
||||
args=["tools.py"] # Run tools.py directly
|
||||
args=["tools.py"], # Run tools.py directly
|
||||
)
|
||||
|
||||
|
||||
# Get available tools from the MCP instance
|
||||
tools = client.get_all_tools()
|
||||
print("🔧 Available tools:", [t.name for t in tools])
|
||||
|
||||
|
||||
# Create the Weather Agent using MCP tools
|
||||
weather_agent = Agent(
|
||||
name="Stevie",
|
||||
|
|
@ -44,5 +44,6 @@ async def main():
|
|||
# Clean up resources
|
||||
await client.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -3,17 +3,20 @@ import random
|
|||
|
||||
mcp = FastMCP("TestServer")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def get_weather(location: str) -> str:
|
||||
"""Get weather information for a specific location."""
|
||||
temperature = random.randint(60, 80)
|
||||
return f"{location}: {temperature}F."
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def jump(distance: str) -> str:
|
||||
"""Simulate a jump of a given distance."""
|
||||
return f"I jumped the following distance: {distance}"
|
||||
|
||||
|
||||
# When run directly, serve tools over STDIO
|
||||
if __name__ == "__main__":
|
||||
mcp.run("stdio")
|
||||
mcp.run("stdio")
|
||||
|
|
|
|||
Loading…
Reference in New Issue