Skip to content

Commit 2ada693

Browse files
committedJan 6, 2025·
Add file system tools to Aura
1 parent 8a739ec commit 2ada693

File tree

6 files changed

+211
-38
lines changed

6 files changed

+211
-38
lines changed
 

‎pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
88
"autogen-agentchat==0.4.0.dev13",
9+
"autogen-ext-mcp>=0.2.0",
910
"autogen-ext[langchain,openai,azure]==0.4.0.dev13",
1011
"langchain-google-community[gmail]>=2.0.3",
1112
"python-dateutil>=2.9.0.post0",

‎src/aura/agents/aura.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from autogen_agentchat.agents import AssistantAgent
44
from autogen_ext.models.openai import OpenAIChatCompletionClient
55
from tools.tool_factory import (
6+
get_file_system_tools,
67
get_gmail_tools,
78
get_google_calendar_tools,
89
get_utility_tools,
@@ -34,11 +35,12 @@ def _get_timezone() -> ZoneInfo:
3435
return ZoneInfo(str(get_localzone()))
3536

3637

37-
def aura() -> AssistantAgent:
38+
async def aura() -> AssistantAgent:
3839
tools = (
3940
get_gmail_tools(SCOPES)
4041
+ get_google_calendar_tools(SCOPES)
4142
+ get_utility_tools()
43+
+ await get_file_system_tools()
4244
)
4345

4446
assistant = AssistantAgent(

‎src/aura/main.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
from autogen_agentchat.messages import TextMessage
44
from autogen_core import CancellationToken
55
from dotenv import load_dotenv
6-
76
from agents.aura import aura
7+
88
from utils.console import RichConsole
99

10+
load_dotenv()
11+
1012

1113
async def main():
12-
agent = aura()
14+
agent = await aura()
1315

1416
while True:
1517
try:
@@ -31,5 +33,4 @@ async def main():
3133

3234

3335
if __name__ == "__main__":
34-
load_dotenv()
3536
asyncio.run(main())

‎src/aura/tools/tool_factory.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
from pathlib import Path
12
from autogen_ext.tools.langchain import LangChainToolAdapter
3+
from autogen_ext_mcp.tools import get_tools_from_mcp_server
24
from langchain_google_community import GmailToolkit
35
from langchain_google_community.gmail.utils import (
46
build_resource_service as build_gmail_resource_service,
57
)
8+
from mcp import StdioServerParameters
69

710
from .gmail.toolkit import GmailToolkitExt
811
from .google_calendar.tookit import GoogleCalendarToolkit
@@ -12,6 +15,20 @@
1215
from .utilities.get_current_time import GetCurrentTime
1316

1417

18+
file_system_server = StdioServerParameters(
19+
command="npx.cmd",
20+
args=[
21+
"-y",
22+
"@modelcontextprotocol/server-filesystem",
23+
str(Path.home() / "Desktop" / "aura"),
24+
],
25+
)
26+
27+
28+
async def get_file_system_tools():
29+
return await get_tools_from_mcp_server(file_system_server)
30+
31+
1532
def get_gmail_tools(scopes: list[str]):
1633
api_resource = build_gmail_resource_service(scopes=scopes)
1734

‎src/aura/utils/mcp.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from typing import List
2+
from autogen_ext_mcp.tools import MCPToolAdapter
3+
from rich.console import Console
4+
5+
6+
def print_tools(tools: List[MCPToolAdapter]) -> None:
7+
console = Console()
8+
console.print("\n[bold blue]📦 Loaded MCP Tools:[/bold blue]")
9+
10+
for tool in tools:
11+
console.print(f"\n[bold green]🔧 {tool.schema['name']}[/bold green]")
12+
if "description" in tool.schema:
13+
console.print(f"[italic]{tool.schema['description']}[/italic]")
14+
15+
if "parameters" in tool.schema:
16+
console.print("\n[yellow]Parameters:[/yellow]")
17+
params = tool.schema["parameters"]
18+
if "properties" in params:
19+
for prop_name, prop_details in params["properties"].items():
20+
required = prop_name in params.get("required", [])
21+
required_mark = "[red]*[/red]" if required else ""
22+
console.print(
23+
f" • [cyan]{prop_name}{required_mark}[/cyan]: {prop_details.get('type', 'any')}"
24+
)
25+
if "description" in prop_details:
26+
console.print(f" [dim]{prop_details['description']}[/dim]")
27+
28+
console.print("─" * 50)

‎uv.lock

+158-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.