Skip to the page
INTEGRATIONS/AUTOGEN

AutoGen

An AutoGen agent can use tradefloor's local MCP server to build simulated markets, run stress scenarios and evaluate strategies. The server has 13 tools and places no orders. AutoGen talks to it over stdio through autogen_ext.tools.mcp.

Install

pip install autogen-agentchat "autogen-ext[mcp]" "mcp<2"

Keep the mcp<2 pin. autogen-ext 0.7.5 fails to import with mcp 2.x (ImportError: cannot import name 'RequestContext'). The server runs in its own environment through uvx, which needs uv, so it still gets the mcp 2.x it requires.

Connect

mcp_server_tools starts the server, reads its tool list and returns one AutoGen tool per MCP tool.

import asyncio
import json

from autogen_core import CancellationToken
from autogen_ext.tools.mcp import StdioServerParams, mcp_server_tools

server = StdioServerParams(
    command="uvx",
    args=["--with", "tradefloor[mcp]", "tradefloor", "mcp"],
    read_timeout_seconds=120,
)


async def main() -> None:
    tools = await mcp_server_tools(server)
    print(len(tools), "tools:", ", ".join(t.name for t in tools[:4]), "...")

    list_scenarios = next(t for t in tools if t.name == "list_scenarios")
    result = await list_scenarios.run_json({}, CancellationToken())
    scenarios = json.loads(result[0].text)["shipped"]
    print("scenarios:", ", ".join(s["name"] for s in scenarios))


asyncio.run(main())
13 tools: describe_simulator, check_envelope, validate_strategy, evaluate_strategies ...
scenarios: curve_shock, geopolitical_conflict, liquidity_crisis, oil_price_spike, policy_regime_shift, rate_shock, recession

Pass the same list to an agent with AssistantAgent(name, model_client=..., tools=tools), and the agent runs a tool when the model asks for one. Without a session, each tool call starts a new server process. To keep one process open, create a session with create_mcp_server_session(server) and pass it as mcp_server_tools(server, session=session).

Tested with

autogen-agentchat 0.7.5, autogen-ext 0.7.5, autogen-core 0.7.5 and mcp 1.30.0 on Python 3.12.14, with uv 0.12.14, and tradefloor 0.9.1.