Provides tools for interacting with Opinion.trade prediction markets on BNB Chain, including market data access, order placement, position management, and trading operations with EIP712 signing support
Opinion.trade MCP Server
Model Context Protocol (MCP) server for Opinion.trade - a decentralized prediction markets platform on BNB Chain.
Features
Dual-Mode Operation
Read-Only Mode: Market data access with API key only
Trading Mode: Full trading capabilities with private key for EIP712 signing
Available Tools (13 Total)
Public API Tools (6 - API key only)
get_markets- List prediction markets with filteringget_market_details- Get detailed market informationget_token_price- Current token/outcome pricesget_orderbook- Order book depth (bids/asks)get_price_history- Historical OHLCV datasearch_markets- Search markets by keyword
Trading Tools (7 - Requires private key)
place_order- Place limit/market orders with EIP712 signingcancel_order- Cancel specific ordercancel_all_orders- Cancel all open ordersget_open_orders- List user's open ordersget_positions- Get positions with P&Lget_trade_history- Executed trades historyget_balances- Account balances (available + locked)
Installation
Prerequisites
Python 3.10 or higher
Opinion.trade API key (Get one here)
Install from source
Configuration
1. Create .env file
2. Configure environment variables
Minimum configuration (read-only mode):
Full configuration (trading mode):
3. Configure Claude Code
Add to your Claude Code MCP settings:
Or use the installed command:
Usage Examples
Read-Only Mode (Market Data)
Trading Mode (Requires Private Key)
Security Best Practices
API Keys
Never commit your
.envfile to version controlStore API keys securely using environment variables
Rotate API keys periodically
Private Keys
NEVER share your private key
NEVER commit private keys to version control
Use hardware wallets for production trading
Consider using a dedicated trading wallet with limited funds
The private key is used for EIP712 signing (not transmitted to API)
Environment
Use
.envfiles for local developmentUse secure secret management for production
Verify you're on the correct network (mainnet vs testnet)
Architecture
Dual-Mode Design
The server automatically detects trading mode based on private key presence:
Components
PublicClient: Handles market data via REST API (httpx)
TradingClient: Wraps
opinion_clob_sdkfor trading with EIP712 signingOpinionConfig: Environment-based configuration with validation
Pydantic Models: Type-safe request validation
MCP Server: Tool registration and routing with error handling
API Response Format
Opinion.trade API responses follow this structure:
code: 0 for success, non-zero for errorsmsg: Human-readable messageresult: Contains eitherdata(single object) orlist(array)
Error Handling
The server provides detailed error messages:
Common error codes:
VALIDATION_ERROR: Invalid input parametersAPI_ERROR: Opinion.trade API errorTRADING_DISABLED: Trading tools called without private keyINTERNAL_ERROR: Unexpected server error
Development
Running Tests
Code Formatting
Troubleshooting
"API key is required" error
Ensure
OPINION_API_KEYis set in.envVerify
.envfile is in the project root directoryCheck that
python-dotenvis installed
"Trading tools not available" error
Set
OPINION_PRIVATE_KEYin.envto enable trading modeEnsure private key starts with
0xVerify private key corresponds to a funded BNB Chain wallet
"opinion-clob-sdk not found" error
Install the SDK:
pip install opinion-clob-sdk>=0.4.1Verify it's listed in your
requirements.txtorpyproject.toml
Network errors
Check your internet connection
Verify API host is reachable:
https://proxy.opinion.trade:8443Check if Opinion.trade API is operational
Resources
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Disclaimer
This is an unofficial MCP server for Opinion.trade. Use at your own risk. Always verify transactions before signing. The authors are not responsible for any losses incurred through the use of this software.
Version: 0.1.0 Status: Beta Chain: BNB Chain (Chain ID: 56)