Building an MCP Agentic Stock Trading System - Part 1: The Architecture
I wanted to experiment with Model Context Protocol (MCP) and compare local LLMs against API-based ones. So I built a stock paper-trading system with three brains: a rules-based trader, Claude API, and a local Llama model in LM Studio. Same market data, different decision-making approaches.
This isn't about making money—it's about making comparisons. I structured the experiment with three parallel agents:
Rules-based trader: Traditional if/then logic (RSI, moving averages, volume)
Claude API trader: claude-3-haiku over the same data
Local LLM trader: openai/gpt-oss-20b running in LM Studio
All three get identical market data through MCP servers. They analyze the same stocks, make their own decisions, and I track what they recommend. The goal is to see how different intelligence types approach the same problem.
MCP is Anthropic's protocol for connecting AI systems to data sources and tools. Instead of hardcoding APIs into each agent, I built MCP servers that provide market data, historical prices, and trading actions. Any agent—local or API—can connect and use them.
┌─────────────────────────────────────────────────────┐
│ Trading Agents │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Rule-Based │ │ Claude │ │ Local LLM │ │
│ │ Agent │ │ Haiku │ │ (LM Studio) │ │
│ └──────┬──────┘ └───────┬─────┘ └──────┬──────┘ │
│ │ │ │ │
│ └─────────────────┴───────────────┘ │
│ │ │
└───────────────────────────┼─────────────────────────┘
│
┌────────┴────────┐
│ MCP Clients │
│ (Tool Wrapper) │
└────────┬────────┘
│
┌───────────────┴──────────────┐
│ │
┌───────▼──────┐ ┌───────▼──────┐
│ Market Data │ │ Analysis │
│ MCP Server │ │ MCP Server │
│ │ │ │
│ Tools: │ │ Tools: │
│ - get_price │ │ - calc_sma │
│ - get_hist │ │ - calc_rsi │
│ - search │ │ - calc_macd │
└──────────────┘ └──────────────┘
Three agents, one protocol: comparing decision-making approaches
This is a multi-day series of posts. This post, Part 1, is about setting up the architecture. Over the next few posts, I'll walk through implementing the MCP servers, connecting the agents, and comparing their decision patterns.
I'm not expecting the LLMs to beat traditional strategies. I'm curious what they learn, how they reason, and whether local models can keep up with API-based ones for structured tasks.
agentic-stock-trader - View on GitHub
This post is part of my daily AI journey blog at Mosaic Mesh AI. Building in public, learning in public, sharing the messy middle of AI development.
