Skip to main content

Overview

Python-based MCP servers using the uvx package runner.

Usage

from upsonic import Task, Agent

# UVX-based MCP server (Python-based, no installation needed)
class FetchMCP:
    command = "uvx"
    args = ["mcp-server-fetch"]

class FileSystemMCP:
    command = "uvx"
    args = ["mcp-server-filesystem"]

# Create task
task = Task(
    description="Fetch the documentation page from 'https://docs.python.org/3/' using FetchMCP, and then save the content to a local file named 'python_docs.html'.",
    tools=[FetchMCP, FileSystemMCP]
)

# Create agent
agent = Agent(
    name="Data Fetcher",
    model="openai/gpt-4o"
)

# Execute
result = agent.do(task)
print(result)

Parameters

  • command (str): The command to run (“uvx”)
  • args (List[str]): Arguments including package name
  • tool_name_prefix (str): Optional prefix to add to all tool names (prevents collisions)

Using Tool Name Prefix

When using multiple MCP servers with the same tools, add a tool_name_prefix to prevent collisions:
from upsonic import Task, Agent

# Two SQLite servers for different databases
class UsersDB:
    command = "uvx"
    args = ["mcp-server-sqlite", "--db-path", "/tmp/users.db"]
    tool_name_prefix = "users_db"  # Tools become: users_db_create_table, etc.

class OrdersDB:
    command = "uvx"
    args = ["mcp-server-sqlite", "--db-path", "/tmp/orders.db"]
    tool_name_prefix = "orders_db"  # Tools become: orders_db_create_table, etc.

task = Task(
    description="""
    Use 'users_db_*' tools to work with the users database.
    Use 'orders_db_*' tools to work with the orders database.
    Create tables in both and insert sample data.
    """,
    tools=[UsersDB, OrdersDB]
)

agent = Agent(name="Multi-DB Agent", model="openai/gpt-4o")
result = agent.do(task)

Characteristics

  • Python-based MCP servers
  • Automatic dependency management
  • No manual installation required
  • Isolated execution environment