LlamaIndex
A LlamaIndex agent connected to the local MCP server gets 13 tools for running simulated markets and scoring trading strategies against them. The server places no orders.
Install
pip install llama-index-tools-mcp
The example starts the server in its own environment through uvx, which needs uv.
Connect
BasicMCPClient starts the server as a subprocess and talks to it over stdio, and McpToolSpec turns each MCP tool into a LlamaIndex tool.
import asyncio
import json
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec
async def main():
client = BasicMCPClient(
"uvx", args=["--with", "tradefloor[mcp]", "tradefloor", "mcp"]
)
tools = await McpToolSpec(client=client).to_tool_list_async()
by_name = {tool.metadata.name: tool for tool in tools}
print(len(by_name), "tools:", ", ".join(sorted(by_name)[:4]), "...")
output = await by_name["list_scenarios"].acall()
data = json.loads(output.raw_output.content[0].text)
print("scenarios:", ", ".join(s["name"] for s in data["shipped"]))
asyncio.run(main())13 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
A tool's raw_output is the MCP CallToolResult, and tradefloor puts its JSON in the first text block. To let a model pick the calls, pass the list to FunctionAgent(tools=tools, llm=...) from llama_index.core.agent.workflow. That step needs an LLM and its API key, and this page doesn't test it.
Tested with
Python 3.12, llama-index-tools-mcp 0.6.0, llama-index-core 0.14.25, mcp 2.3.0 and tradefloor 0.9.1.