Skip to main content
Glama
StockTraders-AI

stocktraders-mcp

Official

stocktraders-mcp

In parallel, completely independent from the old chatbotgpt/chatbotgpt — no shared code, no shared DB, no touching the running system.

Installation

python -m venv .venv
.venv\Scripts\activate        # Windows
pip install -r requirements.txt
copy .env.example .env        # rồi điền BYOK_ENCRYPTION_KEY

Related MCP server: Rozkoduj MCP

Run regression tests (mandatory before changing anything in core/)

python tests/regression_cases.py

Run MCP server (for Claude Desktop / ChatGPT / Cursor to connect)

# stdio (Claude Desktop, MCP inspector)
python -m mcp_server.server

# HTTP (client từ xa)
python -m mcp_server.server --http --port 8100

Run BYOK web app

uvicorn webapp.main:app --port 8000

Flow:

  1. POST /auth/key {"user_id": "...", "openai_api_key": "sk-..."} — users store their own key.

  2. POST /chat {"user_id": "...", "message": "..."} — uses the key just saved, doesn't touch the company key.

  3. No key → 400, no silent fallback to a shared key.

Architecture

See details in the core/*.py docstring at the top of each file — each file states exactly which component of the old system it replaces and why.

  • core/ — tool registry + executor (1:1 port from the old code) + formatters (accurate numbers) + knowledge (guide embedded in tool description) + context_state (multi-turn carry-forward of date/ticker, generalized).

  • mcp_server/ — real MCP server, exposing core/ to external AI clients.

  • webapp/ — BYOK web chat, sharing core/ with the MCP server (ensuring no divergence).

Verified

  • tests/regression_cases.py: 24/24 pass — tool registry has all 29 tools, embedded guide is correct, context carry-forward is correct (the bug case fixed today in the old system), number formatter is accurate.

  • MCP server: real round-trip over the MCP protocol (in-memory client/server) — lists 30 tools (29 + searchCaseIdeas), getAnalyzeWave carries the correct guide "big wave or pullback wave".

  • Webapp: real uvicorn run, tested /health, /auth/key, /auth/key/status, /chat (correctly rejects when no key).

Not done yet (needs a real OpenAI key + real time to verify)

  • Test real conversations via Claude Desktop/MCP inspector against the 11 cases from the original rule doc.

  • Test real conversations via the webapp with a real OpenAI key, comparing each sentence against the old version.

  • Deploy to a VPS (current production is chatbotgpt/chatbotgpt; this project has not been deployed anywhere yet).

  • Migrate old case_ideas (intentionally not automatic — see plan).

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables natural language trading operations for stocks, options, crypto, and portfolio management via Alpaca's Trading API through AI assistants.
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Provides AI assistants with market screening, analysis, and scoring across stocks, crypto, and forex, enabling natural language queries for trading insights.
    4
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Connects a brokerage account to AI assistants, enabling portfolio queries, order management, and market data access through natural language.
    MIT