Fix code formatting with ruff

This commit is contained in:
Bilgin Ibryam 2025-05-20 16:55:20 +01:00
parent 94bf5d2a38
commit 83fc449e39
5 changed files with 16 additions and 8 deletions

View File

@ -5,6 +5,7 @@ from dotenv import load_dotenv
from dapr_agents import AssistantAgent from dapr_agents import AssistantAgent
from dapr_agents.tool.mcp import MCPClient from dapr_agents.tool.mcp import MCPClient
async def main(): async def main():
try: try:
# Load MCP tools from server (stdio or sse) # Load MCP tools from server (stdio or sse)
@ -38,6 +39,7 @@ async def main():
except Exception as e: except Exception as e:
logging.exception("Error starting weather agent service", exc_info=e) logging.exception("Error starting weather agent service", exc_info=e)
if __name__ == "__main__": if __name__ == "__main__":
load_dotenv() load_dotenv()
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)

View File

@ -3,12 +3,14 @@ import random
mcp = FastMCP("TestServer") mcp = FastMCP("TestServer")
@mcp.tool() @mcp.tool()
async def get_weather(location: str) -> str: async def get_weather(location: str) -> str:
"""Get weather information for a specific location.""" """Get weather information for a specific location."""
temperature = random.randint(60, 80) temperature = random.randint(60, 80)
return f"{location}: {temperature}F." return f"{location}: {temperature}F."
@mcp.tool() @mcp.tool()
async def jump(distance: str) -> str: async def jump(distance: str) -> str:
"""Simulate a jump of a given distance.""" """Simulate a jump of a given distance."""

View File

@ -8,8 +8,8 @@ from dapr_agents.tool.mcp import MCPClient
load_dotenv() load_dotenv()
async def main():
async def main():
# Create the MCP client # Create the MCP client
client = MCPClient() client = MCPClient()
@ -17,7 +17,7 @@ async def main():
await client.connect_stdio( await client.connect_stdio(
server_name="local", server_name="local",
command=sys.executable, # Use the current Python interpreter 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 # Get available tools from the MCP instance
@ -44,5 +44,6 @@ async def main():
# Clean up resources # Clean up resources
await client.close() await client.close()
if __name__ == "__main__": if __name__ == "__main__":
asyncio.run(main()) asyncio.run(main())

View File

@ -3,17 +3,20 @@ import random
mcp = FastMCP("TestServer") mcp = FastMCP("TestServer")
@mcp.tool() @mcp.tool()
async def get_weather(location: str) -> str: async def get_weather(location: str) -> str:
"""Get weather information for a specific location.""" """Get weather information for a specific location."""
temperature = random.randint(60, 80) temperature = random.randint(60, 80)
return f"{location}: {temperature}F." return f"{location}: {temperature}F."
@mcp.tool() @mcp.tool()
async def jump(distance: str) -> str: async def jump(distance: str) -> str:
"""Simulate a jump of a given distance.""" """Simulate a jump of a given distance."""
return f"I jumped the following distance: {distance}" return f"I jumped the following distance: {distance}"
# When run directly, serve tools over STDIO # When run directly, serve tools over STDIO
if __name__ == "__main__": if __name__ == "__main__":
mcp.run("stdio") mcp.run("stdio")