PolyMarket MCP Server
PolyMarket MCP Server
An MCP server implementation for interacting with the PolyMarket API. This server provides tools for fetching prediction market data, including market information, prices, and historical data.
Features
- Get detailed information about specific prediction markets
- List available prediction markets with filtering options
- Get current prices and trading information
- Fetch historical price and volume data
- Proper error handling and rate limit management
- Clean data formatting for easy consumption
Installation
- Clone the repository:
- Create a virtual environment and install dependencies:
- Set up your environment variables:
Create a
.env
file in the root directory with your PolyMarket API key:
Usage
The server provides the following tools:
get-market-info
Get detailed information about a specific prediction market:
list-markets
List prediction markets with optional filters:
get-market-prices
Get current prices and trading information for a market:
get-market-history
Get historical price and volume data for a market:
Running the Server
The server can be run directly using Python:
Or through the MCP client:
Response Formats
All responses are formatted as clear text with relevant information. Here's an example of a market info response:
Error Handling
The server includes comprehensive error handling for various scenarios:
- Invalid API keys
- Rate limiting
- Network connectivity issues
- Invalid market IDs
- Malformed requests
- API timeout conditions
Each error is returned with a clear explanation of what went wrong and, where applicable, suggestions for resolution.
Development
For local development:
- Fork the repository
- Create a new branch for your feature
- Install development dependencies:
- Make your changes
- Submit a pull request
License
MIT License. See LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Acknowledgments
- Built using the MCP (Machine Conversation Protocol) framework
- Inspired by the Alpha Vantage MCP server architecture
Enables interaction with the PolyMarket API to fetch prediction market data such as market information, prices, and historical data, with robust error handling and rate limit management.