from upsonic import Agent, Task
from upsonic.tools.mcp import MultiMCPHandler
# Create multi-handler with specific prefixes for each server
multi_handler = MultiMCPHandler(
commands=[
"uvx mcp-server-sqlite --db-path /tmp/users.db",
"uvx mcp-server-sqlite --db-path /tmp/orders.db",
],
tool_name_prefixes=["users_db", "orders_db"], # Must match number of servers
timeout_seconds=60
)
# Create agent
agent = Agent(
name="Multi-DB Agent",
role="Multi-database operations specialist",
goal="Work with multiple databases using prefixed tools"
)
# Create task with clear tool prefixes
task = Task(
description="""
IMPORTANT: You have access to TWO separate databases with prefixed tools.
- Users database: Use tools prefixed with 'users_db_' (e.g., users_db_create_table, users_db_read_query)
- Orders database: Use tools prefixed with 'orders_db_' (e.g., orders_db_create_table, orders_db_read_query)
Step 1: Using users_db tools, create a 'users' table with id, name, and email columns.
Insert 3 sample users.
Step 2: Using orders_db tools, create an 'orders' table with id, user_id, and product columns.
Insert 4 sample orders.
Step 3: Query both databases to show all records.
""",
tools=[multi_handler]
)
result = agent.do(task)
print(result)