smolagents
A smolagents agent can use tradefloor's local MCP server to run simulations and evaluate trading strategies. smolagents loads the server's 22 tools as ordinary smolagents tools. 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 "smolagents[mcp]" "mcp<2"
The mcp<2 pin is for your agent's environment only. smolagents[mcp] 1.26.0 installs mcpadapt 0.1.20, and that fails to import under mcp 2.x with ImportError: cannot import name 'streamablehttp_client'. The server runs in a separate environment through uvx (which needs uv) and gets mcp 2.x there.
Connect
MCPClient starts the server as a subprocess, returns its tools as a list and closes the connection when the with block exits.
import json
from mcp import StdioServerParameters
from smolagents import MCPClient
server = StdioServerParameters(
command="uvx",
args=["--with", "tradefloor[mcp]", "tradefloor", "mcp"],
)
with MCPClient(server, structured_output=False) as tools:
names = sorted(tool.name for tool in tools)
print(len(names), "tools:", ", ".join(names[:4]), "...")
list_scenarios = next(tool for tool in tools if tool.name == "list_scenarios")
result = json.loads(list_scenarios())
print("scenarios:", ", ".join(s["name"] for s in result["shipped"]))22 tools: build_scenario, build_universe, check_envelope, check_job ... scenarios: curve_shock, geopolitical_conflict, liquidity_crisis, oil_price_spike, policy_regime_shift, rate_shock, recession, recession_2008
Setting structured_output explicitly silences a FutureWarning about its default changing. With False, each tool returns the server's JSON as a string.
To give the tools to an agent, pass the list inside the with block, for example CodeAgent(tools=tools, model=model) or ToolCallingAgent(tools=tools, model=model). Both agents also add a final_answer tool. ToolCollection.from_mcp(server, trust_remote_code=True) loads the 22 tools too. It raises a ValueError unless you pass trust_remote_code=True to confirm you trust a server that runs code on your machine.
Tested with
smolagents 1.26.0, mcpadapt 0.1.20, mcp 1.30.0, Python 3.12.14, uv 0.12.14 and tradefloor 0.11.0.