from upsonic import Task, Agent
from upsonic.tools.mcp import MCPHandler
# MCP server with authentication
auth_handler = MCPHandler(
command="npx -y @company/private-mcp-server",
env={
"API_KEY": "your_api_key_here",
"API_SECRET": "your_api_secret_here",
"AUTH_TOKEN": "bearer_token_here"
},
timeout_seconds=60
)
# Multiple servers with different auth
github_handler = MCPHandler(
command="npx -y @modelcontextprotocol/server-github",
env={
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxx"
},
timeout_seconds=60
)
slack_handler = MCPHandler(
command="uvx mcp-server-slack",
env={
"SLACK_BOT_TOKEN": "xoxb-xxxxx",
"SLACK_TEAM_ID": "T1234567"
},
timeout_seconds=60
)
# Create task with authenticated tools
task = Task(
description="Fetch the latest open issues from the repository 'my-project/repo' using the GitHub tool, then send a summary of these issues to the '#dev-team' channel on Slack.",
tools=[github_handler, slack_handler]
)
# Create agent
agent = Agent(
name="Integration Agent",
model="anthropic/claude-sonnet-4-5"
)
# Execute
result = agent.print_do(task)
print("Result:", result)