Skip to the page
INTEGRATIONS/LLAMAINDEX

LlamaIndex

A LlamaIndex agent connected to tradefloor's local MCP server gets 22 tools for running simulated markets and scoring trading strategies on them. 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 llama-index-tools-mcp

The example runs the server in a separate environment through uvx, which needs uv.

Connect

BasicMCPClient starts the server as a subprocess and talks to it over stdio. 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())
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

A tool's raw_output is the MCP CallToolResult, with tradefloor's 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.11.0.