MCP tools
Connect an AI client to the product’s typed tools for markets, indicators, plans, alerts, and watchlists. Start with a local, read-only tool call.
Before you connect
Section titled “Before you connect”Use a local product checkout and Rust toolchain. For tools that call application services, start the host development stack or the complete Docker app.
The tool catalog is the contract:
backend/crates/mcp/src/tool_catalog.rs.
Use the client’s tools/list result for current parameter schemas rather than
guessing tool names or borrowing a different MCP server’s API.
Connect over stdio
Section titled “Connect over stdio”Build from the product repository root:
cd backendcargo build --locked --bin open-trading-mcpAdd a server entry to your client’s MCP configuration. Replace the absolute
checkout path below with your actual path; on Windows the executable ends in
.exe.
{ "mcpServers": { "open-trading-mcp": { "command": "/absolute/path/to/open-trading/backend/target/debug/open-trading-mcp", "env": { "OT_RUST_URL": "http://localhost:2000", "OT_NEST_URL": "http://localhost:3000" } } }}The client launches the binary and communicates over stdin/stdout. There is no HTTP URL in this mode. Restart or reload the MCP server in the client after changing its configuration or rebuilding the binary.
Connect over HTTP
Section titled “Connect over HTTP”For a host development stack, run from the product repository root:
make run-mcp-httpConnect an MCP client or Inspector with Streamable HTTP at
http://localhost:8181. The complete Docker app already exposes its HTTP MCP
listener at http://127.0.0.1:8181 by default; do not start a second listener on
the same port.
For the hosted MCP Inspector workflow, the
server needs MCP_CORS_ENABLED=true. Enable it only for the intended client
workflow. CORS is not access control, and the server should remain private.
An HTTP client must initialize, send notifications/initialized, and retain
the MCP session/connection for subsequent requests. Separate curl invocations
can report “Session not found”; use a real MCP client rather than treating this
transport like a stateless JSON API.
Make the first call
Section titled “Make the first call”In your connected client’s tool browser, select list_exchanges with no
parameters. Its tools/call parameters are:
{ "name": "list_exchanges", "arguments": {}}This is the parameters object inside an initialized MCP client’s request, not a standalone HTTP body. The tool returns MCP text content containing a JSON list of supported exchange IDs and labels. Use those IDs for subsequent market tools; do not invent them.
This call reads the shared exchange catalog and does not require an AI key or live market response. It verifies the client/tool connection, not every backend.
Service requirements
Section titled “Service requirements”| Tools | Requirement or behavior |
|---|---|
list_exchanges |
Shared supported-exchange catalog |
market_ohlc, indicator_bundle, performance_bundle |
Market data access; indicator calculations use the shared Rust implementation |
feed_snapshot, market_orderbook |
Running Rust API and available live feed/subscription; may return null without one |
compute_plan_levels |
Market data plus a fixed-percentage levels helper; not the AI generate-plan action |
generate_trading_plan |
Rust API and configured LLM providers; returns analysis, plan and chat without Nest persistence |
list_llm_providers, list_llm_models, list_ollama_models |
Rust API; model availability also depends on the chosen provider/service |
recognize_pattern |
Rust vision path and screenshot input; provider configuration may be required |
alerts_*, watchlists_* |
NestJS and its session-scoped data |
compute_plan_levels requires context_summary as a string: use "" when
there is no context, not null. Use generate_trading_plan when you want the
AI workflow corresponding to the application’s plan action. Neither tool
automatically saves a plan through NestJS.
Sessions and data
Section titled “Sessions and data”MCP creates its own anonymous Nest session through /api/session/ensure by
default. The browser and MCP client can therefore see different alert and
watchlist stores even when connected to the same services.
To deliberately share the browser’s session, set OT_NEST_SESSION in the MCP
process environment to its ot_session cookie or bare JWT. Do not copy that
credential into a public example, issue, screenshot, or repository.
| Variable | Default |
|---|---|
OT_RUST_URL |
http://localhost:2000 |
OT_NEST_URL |
http://localhost:3000 |
OT_NEST_SESSION |
Unset; MCP obtains its own session |
Extend a tool
Section titled “Extend a tool”- Implement the typed parameters and operation in
src/tools/. - Update
src/tool_catalog.rsand the exact#[tool]handler insrc/handler.rs. - Keep
run_tooldispatch andschema_for_toolinsrc/in_process.rsaligned. - Use the existing
NestClientorRustApiClientfor those service calls. - Run the relevant checks, rebuild the binary, and reload the client’s server.
With a configured hybrid stack and market connectivity, run from the product root:
make lintbash make/mcp/smoke-product-mcp.shThe smoke script builds the binary, checks catalog consistency, and exercises
selected domains against live services. Expect OK: product MCP smoke passed.
It is not a complete end-to-end test of every tool or AI provider.
Source: the MCP development guide. For connection failures, see Troubleshooting.