Trading MCP Server
# Trading-MCP-Server
An intelligent trading assistant that integrates with the Claude AI MCP (Model Context Protocol) platform. This tool fetches live stock prices using Yahoo Finance and enables seamless command-based interaction with the market via Claude's agent interface.
## ๐ Features
- ๐ Fetches real-time (or near real-time) stock prices using Yahoo Finance
- ๐ค Connects to Claude MCP as a server with custom trading commands
- ๐ Built using Python with support for virtual environments and `uv` for dependency management
- โ๏ธ Supports modular expansion to include trading signals, historical analysis, and more
## ๐ง Architecture
- **Claude AI MCP Integration**: Uses `mcp[cli]` to expose a server interface to Claude.
- **Yahoo Finance API**: For retrieving stock data (via `yfinance`).
- **Virtual Environment**: Managed using `uv` for fast and deterministic builds.
## ๐ฆ Setup
```bash
# Install uv if not already installed
brew install uv
# Navigate to the project directory
cd MCPtrading
# Install dependencies
uv pip install -r requirements.txt
# (Optional) Add packages
uv add yfinance
```
## ๐โโ๏ธ Running the Server
Make sure to use the correct Python environment:
```bash
uv run --python .venv/bin/python --with "mcp[cli]" mcp run trader_tools.py
```
Or update your Claude config:
```json
{
"mcpServers": {
"Trading": {
"command": "/Users/yourname/.local/bin/uv",
"args": [
"run",
"--python",
"/full/path/to/.venv/bin/python",
"--with",
"mcp[cli]",
"mcp",
"run",
"trader_tools.py"
]
}
}
}
```
๐งช Example Usage
Ask Claude:
"What's the latest price of AAPL?"
Claude will call the MCP server and respond with the current stock price.
TDQS
Scored across 8 tools
Most tools have distinct purposes, but there is some overlap between 'pnl', 'realized_gains', and 'unrealized_gains' that could cause confusion. 'pnl' combines both realized and unrealized gains, while the other two provide separate calculations, which might lead an agent to misselect when seeking specific details.
The naming is mixed with snake_case used throughout, but the verb patterns vary: some are nouns (e.g., 'portfolio', 'pnl'), some are verbs (e.g., 'simulate_sell', 'validate_trades'), and some are descriptive phrases (e.g., 'trade_history', 'unrealized_gains'). This inconsistency reduces predictability, though it remains readable.
With 8 tools, the count is well-scoped for a trading server, covering key operations like price fetching, portfolio management, gain calculations, and trade validation. Each tool serves a clear purpose without being overwhelming or insufficient for the domain.
The tool set covers core trading functions such as price lookup, portfolio tracking, and gain analysis, but lacks tools for executing trades or managing orders, which are typical in trading systems. This minor gap might require agents to work around, but the existing tools support essential workflows.