<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Olumide Omotoso</title>
    <description>The latest articles on DEV Community by Olumide Omotoso (@oluomotoso).</description>
    <link>https://dev.to/oluomotoso</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4252735%2F732f8f83-5f74-4eb3-b722-56121da31969.png</url>
      <title>DEV Community: Olumide Omotoso</title>
      <link>https://dev.to/oluomotoso</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oluomotoso"/>
    <language>en</language>
    <item>
      <title>I gave Claude a trading desk: building an MCP server that backtests and runs crypto bots</title>
      <dc:creator>Olumide Omotoso</dc:creator>
      <pubDate>Thu, 19 Nov 2026 00:52:01 +0000</pubDate>
      <link>https://dev.to/oluomotoso/i-gave-claude-a-trading-desk-building-an-mcp-server-that-backtests-and-runs-crypto-bots-2geb</link>
      <guid>https://dev.to/oluomotoso/i-gave-claude-a-trading-desk-building-an-mcp-server-that-backtests-and-runs-crypto-bots-2geb</guid>
      <description>&lt;p&gt;Most "AI trading" demos stop at a chatbot that tells you what it thinks Bitcoin will do. I wanted something more useful: an assistant that can take an idea, test it against real market history, and, only when I say so, run it as a bot on my own exchange account.&lt;/p&gt;

&lt;p&gt;So we built an MCP server for &lt;a href="https://www.tradestaq.com" rel="noopener noreferrer"&gt;TradeStaq&lt;/a&gt;, our algo trading platform. It's open source (MIT), on npm as &lt;code&gt;@the-staq/tradestaq-mcp&lt;/code&gt;, and it gives any MCP client 46 tools for strategies, backtests, bots, positions and copy trading.&lt;/p&gt;

&lt;p&gt;This post covers what it does, how to set it up in two minutes, and the design decisions that mattered most when an AI agent can touch real money.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like
&lt;/h2&gt;

&lt;p&gt;You talk to your assistant normally. The server maps the request to a tool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Show me my portfolio"                          → get_portfolio
"Generate a momentum strategy for ETH"          → generate_strategy
"Backtest it on BTC/USDT for the last 3 months" → what_if_backtest
"Explain the risk in plain English"             → explain_strategy
"Deploy it on paper first"                      → deploy_bot
"Why didn't my bot trade last night?"           → get_bot_logs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last one turned out to be one of the most used. &lt;code&gt;get_bot_logs&lt;/code&gt; returns a run-by-run history of why a bot did or did not trade: the signal it saw, the filter that blocked it, or the error it hit. Asking "why" in plain English beats scrolling through logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Remote (no install), for clients that support HTTP transport:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"tradestaq"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://mcp.tradestaq.com/mcp"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Local with npx (Claude Desktop, Cursor and others):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"tradestaq"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"@the-staq/tradestaq-mcp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Claude Code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add tradestaq -- npx -y @the-staq/tradestaq-mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then ask the assistant to "Authenticate with TradeStaq". It opens a browser window for an OAuth (PKCE) login, so your password never goes through the chat. The token is stored locally with 0600 permissions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tools, grouped
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Market data:&lt;/strong&gt; &lt;code&gt;get_price&lt;/code&gt;, &lt;code&gt;get_candles&lt;/code&gt;, &lt;code&gt;search_markets&lt;/code&gt;, &lt;code&gt;list_exchanges&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strategies:&lt;/strong&gt; &lt;code&gt;list_strategies&lt;/code&gt;, &lt;code&gt;get_strategy&lt;/code&gt;, &lt;code&gt;explain_strategy&lt;/code&gt;, &lt;code&gt;compare_strategies&lt;/code&gt;, &lt;code&gt;create_strategy&lt;/code&gt;, &lt;code&gt;generate_strategy&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backtesting:&lt;/strong&gt; &lt;code&gt;what_if_backtest&lt;/code&gt;, &lt;code&gt;get_backtest_results&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bots:&lt;/strong&gt; &lt;code&gt;deploy_bot&lt;/code&gt;, &lt;code&gt;update_bot&lt;/code&gt;, &lt;code&gt;start_bot&lt;/code&gt;, &lt;code&gt;stop_bot&lt;/code&gt;, &lt;code&gt;delete_bot&lt;/code&gt;, &lt;code&gt;get_bot_status&lt;/code&gt;, &lt;code&gt;get_bot_logs&lt;/code&gt;, &lt;code&gt;close_position&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Results:&lt;/strong&gt; &lt;code&gt;get_trade_history&lt;/code&gt;, &lt;code&gt;get_performance_metrics&lt;/code&gt;, plus public chart links for any bot (&lt;code&gt;create_bot_share_link&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Copy trading and advice:&lt;/strong&gt; &lt;code&gt;list_top_traders&lt;/code&gt;, &lt;code&gt;follow_trader&lt;/code&gt;, &lt;code&gt;suggest_strategies&lt;/code&gt;, &lt;code&gt;get_market_context&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also ships three prompt templates (Trading Assistant, Strategy Builder, Portfolio Reviewer) and three browsable resources (&lt;code&gt;tradestaq://portfolio&lt;/code&gt;, &lt;code&gt;tradestaq://bots&lt;/code&gt;, &lt;code&gt;tradestaq://strategies&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Exchanges include Binance, Bybit, OKX, Bitget, Hyperliquid and dYdX. Your exchange keys stay connected to your own account; TradeStaq never holds your funds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design decisions that mattered
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Paper by default, live on purpose
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;deploy_bot&lt;/code&gt; creates a paper bot unless you pass &lt;code&gt;live: true&lt;/code&gt;. An assistant that misreads "deploy it" should cost you nothing. Going live is an explicit choice, and changing a live bot needs a separate permission scope (&lt;code&gt;mcp:live&lt;/code&gt;) from changing a paper one (&lt;code&gt;mcp:paper&lt;/code&gt;). A token that can only manage paper bots can't touch real money, whatever the model decides to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Settings go in the same call that creates the bot
&lt;/h3&gt;

&lt;p&gt;Early on, an agent would deploy a bot and then call &lt;code&gt;update_bot&lt;/code&gt; to set its preset or parameters. The problem: a bot starts trading as soon as it exists, so for a few seconds it ran with default settings. Now &lt;code&gt;deploy_bot&lt;/code&gt; takes &lt;code&gt;presetId&lt;/code&gt;, &lt;code&gt;parameterOverrides&lt;/code&gt; and &lt;code&gt;executionMode&lt;/code&gt; in the create call itself, and the server applies them before the first trade. If you want to set things up in steps, &lt;code&gt;start: false&lt;/code&gt; creates the bot paused.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Partial updates never wipe settings
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;update_bot&lt;/code&gt; merges what you pass onto the bot's current config. Position size and leverage change only when you send them. Models are bad at round-tripping a full config object, so the API shouldn't punish them for sending just the field they mean to change.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Some changes need the bot to be flat
&lt;/h3&gt;

&lt;p&gt;Switching a bot's strategy or timeframe while it holds a position is a good way to orphan that position. The server refuses the switch while the bot is in a trade. The safe sequence is: pause with &lt;code&gt;stopAfterClose: true&lt;/code&gt;, wait until &lt;code&gt;get_bot_status&lt;/code&gt; shows no open position, switch, then &lt;code&gt;start_bot&lt;/code&gt;. Spelling that out in the tool description means the model follows it without being told.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Long jobs are async
&lt;/h3&gt;

&lt;p&gt;A backtest over months of candles takes 30 to 120 seconds. &lt;code&gt;what_if_backtest&lt;/code&gt; returns a job, and &lt;code&gt;get_backtest_results&lt;/code&gt; polls it. That keeps every tool call short, which matters for clients with tight timeouts.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Errors the model can act on
&lt;/h3&gt;

&lt;p&gt;Every error comes back in the same shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"RATE_LIMITED"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Human-readable description"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"retryable"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"retryAfterMs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;retryable&lt;/code&gt; and &lt;code&gt;retryAfterMs&lt;/code&gt; let the assistant decide whether to wait and retry or tell you something is wrong, instead of guessing from an error string.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. One sign-in, many processes
&lt;/h3&gt;

&lt;p&gt;We run the server interactively and from headless &lt;code&gt;claude -p&lt;/code&gt; jobs at the same time, all sharing one config file. Each copy used to cache the token and refresh it on its own, so one copy rotating the token would sign the others out. Now a refresh runs under a lockfile next to the config and re-reads the file inside it: if another copy already rotated the pair, this one just uses the new tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Claude Desktop / Cursor / CLI  ──stdio──►  tradestaq-mcp  ──HTTPS + JWT──►  TradeStaq API
Any web MCP client ──HTTP+SSE──►  (46 tools, 3 prompts, 3 resources)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two transports: stdio for local use (the default) and HTTP+SSE for remote clients, hosted at &lt;code&gt;mcp.tradestaq.com&lt;/code&gt;. It's TypeScript, tested with Vitest, and published to npm through trusted publishing with provenance, so there's no npm token in CI. Each release also updates the listing on the official MCP Registry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;npm: &lt;a href="https://www.npmjs.com/package/@the-staq/tradestaq-mcp" rel="noopener noreferrer"&gt;@the-staq/tradestaq-mcp&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/the-staq/tradestaq-mcp" rel="noopener noreferrer"&gt;the-staq/tradestaq-mcp&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Docs and setup: &lt;a href="https://www.tradestaq.com/mcp" rel="noopener noreferrer"&gt;tradestaq.com/mcp&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's a free plan, and every strategy can be backtested and paper traded before any real money is involved. If you build something on top of it, or find a tool description that confuses your model, open an issue. I'd like to hear about it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Trading involves risk. Backtests show how a strategy behaved on past data; they don't promise future results.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
