AutoGen
An AutoGen agent can use tradefloor's local MCP server over stdio through autogen_ext.tools.mcp. The agent can use the server's 22 tools to build simulated markets, run stress scenarios and evaluate strategies. With the session tools a model can trade step by step in a simulated market the server keeps open, and no order reaches a real broker.
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 a separate environment through uvx (which needs uv) and gets mcp 2.x there.
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())22 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, recession_2008
To give the tools to an agent, pass the list to AssistantAgent(name, model_client=..., tools=tools). 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.11.0.