Skip to main content
Glama
anaisbetts

stonex-mcp

by anaisbetts

stonex-mcp

Typed TypeScript client for the StoneX Client (torchapi) REST API, plus an MCP server that exposes those endpoints as tools.

Auth is not automated (no Okta/MFA in this project). You log into StoneX Client in a browser, export a cookies.txt file, and pass the path to that file on the CLI.

Requirements

  • Bun 1.1+ (for local development / prepare build)

  • Node.js 18+ (to run the published bin bundle)

Related MCP server: claude-tws-connect

Install

bun install

Auth: cookies.txt

  1. Install a browser extension that exports Netscape cookies.txt (e.g. Get cookies.txt LOCALLY).

  2. Log into https://client.stonex.com/client/.

  3. Export cookies for client.stonex.com to a file (e.g. client.stonex.com_cookies.txt).

  4. Pass that path to the server:

stonex-mcp --cookies /path/to/client.stonex.com_cookies.txt

The server reads session cookies from that file and calls GET https://client.stonex.com/client/token only when it needs a Bearer JWT.

Token cache

Derived access tokens are cached on disk so repeated MCP tool calls do not mint a new token every time:

OS

Path

Windows

%LOCALAPPDATA%\stonex-mcp\access-token.json

macOS

~/Library/Caches/stonex-mcp/access-token.json

Linux

${XDG_CACHE_HOME:-~/.cache}/stonex-mcp/access-token.json

When the cached JWT is missing or near expiry, a new token is requested using the cookies file and written back to the cache. If refresh starts failing with 401, re-export cookies after logging into StoneX Client again.

Treat the cookies file and cached token like passwords. Do not commit them.

Run the MCP server

bun start -- --cookies /path/to/client.stonex.com_cookies.txt
# or after build:
node dist/stonex-mcp.js --cookies /path/to/client.stonex.com_cookies.txt

Cursor / Claude Desktop config

{
  "mcpServers": {
    "stonex": {
      "command": "npx",
      "args": [
        "-y",
        "stonex-mcp",
        "--cookies",
        "C:/Users/YOU/Downloads/client.stonex.com_cookies.txt"
      ]
    }
  }
}

npx runs the built Node bundle (dist/stonex-mcp.js, produced by bun run build / prepare). Local equivalent: "command": "bun", "args": ["run", "/path/to/stonex-mcp/src/cli.ts", "--cookies", "/path/to/cookies.txt"].

Typed client

import { StoneXClient } from "./src/client/index.ts";
import { sessionCookieFromCookiesTxtFile } from "./src/auth/cookiesTxt.ts";
import { resolveAuth } from "./src/auth/resolveAuth.ts";
import { writeTokenCache } from "./src/auth/tokenCache.ts";

const { accessToken, sessionCookie } = await resolveAuth(
  "/path/to/client.stonex.com_cookies.txt",
);

const client = new StoneXClient({
  accessToken,
  sessionCookie,
  onAccessToken: (token) => writeTokenCache(token),
});

const accounts = await client.getAccounts();
const summary = await client.getAccountSummary({
  accountNumber: accounts[0]!.acctNo,
});

Or build a cookie header yourself with sessionCookieFromCookiesTxtFile(...).

Endpoints mirror the StoneX Client SPA (https://vulcan.stonex.com/torchapi): accounts, balances, summary, positions, activity, performance, projected income, documents, and related user/account metadata.

Related MCP Connectors

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

  • MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents

  • Your agent needs markets — prices and fundamentals for listed companies, the filings behind them, crypto, and what the prediction markets put the odds at. **What you can ask for** • "Pull this company's income statement, cash flow and balance sheet for the last 8 quarters." • "What did insiders buy or sell, and when?" • "Snapshot prices for these 50 tickers, then the OHLC history for the three that moved." • "What are the current odds on this event across Kalshi and Polymarket?" • "Screen for companies matching these financial criteria." **How to use it** Point any MCP client at https://mcp.aisa.one/finance/mcp and sign in with OAuth — there is no key to create or paste. 49 tools: prices and snapshots, income statements, balance sheets and cash flows, metrics and ratios, earnings and analyst estimates, filings and line-item search, insider trades, macro interest rates, news, a screener; CoinGecko spot prices, market tables, OHLC, per-venue tickers and trending; Kalshi and Polymarket markets and trades; plus EDINET filings for Japan. **Why this rather than the source** Equities, crypto and event markets behind one account, so a cross-asset question is one conversation. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Read the number here, then ask the same agent what X is saying about the ticker today — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/marketpulse/mcp · /crypto-market-data/mcp · /prediction-market-data/mcp · /stock-pulse/mcp for one slice each.

  • Real SEC, 13F, insider, congress & macro data your AI agent can cite. Hosted MCP, 24 tools.

Related MCP Servers

  • A
    license
    D
    quality
    D
    maintenance
    MCP server that exposes Alpaca Market Data & Broker API as tools, enabling access to financial data like stock bars, assets, market days, and news through the Message Control Protocol.
    4
    22 npm
    2
    ISC
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that enables interaction with Interactive Brokers TWS/Gateway via natural language for portfolio management and market data retrieval. It provides tools for account summaries, historical data, and a secure two-step confirmation process for placing and canceling orders.
    6
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    MCP server exposing Tradier brokerage tools to Claude, enabling account balance checks, position management, order operations, and market data queries.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that exposes personal financial data — transaction ledger, portfolio holdings, live/historical market prices, and quantitative risk metrics — as standardized tools, resources, and prompts, enabling natural language reasoning over real computed numbers.
    -