trading simulator mcp
An MCP server that enables AI models like Claude to interact with the Trading Simulator API for checking balances, viewing prices, and executing trades with automatic chain detection.
An MCP server that enables AI models like Claude to interact with the Trading Simulator API for checking balances, viewing prices, and executing trades with automatic chain detection.
An MCP (Model Context Protocol) server for interacting with the Trading Simulator API. This server enables AI models like Claude to check balances, check prices, and execute trades via an MCP-compatible interface.
This MCP server provides access to Trading Simulator operations through structured tool calls:
View trade history
Price Operations
View price history
Trading Operations
Smart token detection that automatically handles chain parameters
Competition Operations
The Trading Simulator MCP includes an intelligent token detection system that simplifies trade execution:
Automatic Chain Detection: When executing trades with common tokens, the system automatically identifies the appropriate blockchain (EVM/SVM) and specific chain (ETH, BASE, etc.) parameters.
Same-Chain Optimization: When trading tokens on the same chain, parameters are automatically configured for same-chain transactions.
Cross-Chain Fallback: If a same-chain trade fails due to tokens being on different chains, the system falls back gracefully to explicit parameters or server-side detection.
Common Token Support: The system includes a growing list of common tokens with their addresses and chain information.
The Trading Simulator API uses Bearer token authentication, requiring a single API key passed in the Authorization
header as a Bearer token.
Example:
Authorization: Bearer your_api_key_here
Clone the repository
git clone https://github.com/yourusername/trading-simulator-mcp.git
cd trading-simulator-mcp
Install dependencies
npm install
Configure your API credentials (see Configuration section below)
Build the project
npm run build
Start the server
npm run start
You have two options for configuring the Trading Simulator MCP server:
The recommended approach is to provide environment variables directly in your Cursor or Claude Desktop configuration. This is more secure and eliminates the need for a .env file.
If you prefer to use a .env file, or are running the server directly from the command line:
Create a .env
file with your API credentials
cp .env.example .env
Edit the .env
file with your API key
TRADING_SIM_API_KEY=your_api_key_here
TRADING_SIM_API_URL=http://localhost:3000
DEBUG=false
Secure your .env file with restricted permissions
chmod 600 .env
The Trading Simulator MCP server uses the following order of precedence for environment variables:
To add this MCP server to Cursor:
npm run build
Trading Simulator MCP
(or any name you prefer)command
node
/path/to/trading-sim-mcp/dist/index.js
(use the full path)TRADING_SIM_API_KEY
: Your API keyTRADING_SIM_API_URL
: API server URL (optional)DEBUG
: true
(optional, for additional logging)For more security, you can configure Cursor via the .cursor/mcp.json
file in your home directory:
{
"mcpServers": {
"trading-simulator-mcp": {
"name": "Trading Simulator MCP",
"type": "command",
"command": "node",
"args": ["/path/to/trading-simulator-mcp/dist/index.js"],
"env": {
"TRADING_SIM_API_KEY": "your_api_key_here",
"TRADING_SIM_API_URL": "http://localhost:3000",
"DEBUG": "true"
}
}
}
}
This approach eliminates the need for a .env file.
To add this MCP server to Claude Desktop:
npm run build
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%Claudeclaude_desktop_config.json
On Linux: ~/.config/Claude/claude_desktop_config.json
Create or edit the claude_desktop_config.json
file with the following content:
{
"mcpServers": {
"trading-simulator-mcp": {
"name": "Trading Simulator MCP",
"type": "command",
"command": "node",
"args": [
"/path/to/trading-simulator-mcp/dist/index.js"
],
"env": {
"TRADING_SIM_API_KEY": "your_api_key_here",
"TRADING_SIM_API_URL": "http://localhost:3000",
"DEBUG": "true"
}
}
}
}
Replace /path/to/trading-simulator-mcp/dist/index.js
with the full path to your compiled server file
Example: /Users/username/trading-simulator-mcp/dist/index.js
Save the configuration file and restart Claude Desktop
If you encounter issues with Claude Desktop, check the logs at:
- On macOS: ~/Library/Logs/Claude/
- On Windows: %USERPROFILE%AppDataLocalClaudeLogs
- On Linux: ~/.local/share/Claude/logs/
When developing the MCP server, use console.error()
instead of console.log()
for all debugging and logging. The Claude Desktop app and Cursor communicate with the server via stdout, so any console.log()
statements will interfere with this communication and cause JSON parsing errors.
The server provides the following MCP tools:
get_balances
- Get token balances for your teamget_portfolio
- Get portfolio information for your teamget_trades
- Get trade history for your teamget_price
- Get the current price for a tokenget_token_info
- Get detailed information about a tokenget_price_history
- Get historical price data for a tokenexecute_trade
- Execute a trade between two tokensget_quote
- Get a quote for a potential tradeget_competition_status
- Get the status of the current competitionget_leaderboard
- Get the competition leaderboardThe system includes a COMMON_TOKENS
structure that maps token addresses to their respective chains. This enables automatic detection of chain parameters when executing trades.
Current common tokens include:
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
So11111111111111111111111111111111111111112
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
0x4200000000000000000000000000000000000006
To add more common tokens, you can extend the COMMON_TOKENS
object in the types.ts
file.