get-market-prices
Retrieve real-time prices and trading details for specific markets using market ID or slug. Integrates with the PolyMarket API to provide accurate prediction market data for analysis.
Instructions
Get current prices and trading information for a market
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| market_id | Yes | Market ID or slug |
Input Schema (JSON Schema)
{
"properties": {
"market_id": {
"description": "Market ID or slug",
"type": "string"
}
},
"required": [
"market_id"
],
"type": "object"
}
Implementation Reference
- src/polymarket_mcp/server.py:284-291 (handler)Handler for the get-market-prices tool: extracts market_id argument, fetches market data using ClobClient.get_market(), formats it with format_market_prices(), and returns as TextContent.elif name == "get-market-prices": market_id = arguments.get("market_id") if not market_id: return [types.TextContent(type="text", text="Missing market_id parameter")] market_data = client.get_market(market_id) formatted_prices = format_market_prices(market_data) return [types.TextContent(type="text", text=formatted_prices)]
- src/polymarket_mcp/server.py:85-98 (registration)Tool registration in list_tools(): defines name, description, and input schema requiring 'market_id'.types.Tool( name="get-market-prices", description="Get current prices and trading information for a market", inputSchema={ "type": "object", "properties": { "market_id": { "type": "string", "description": "Market ID or slug", }, }, "required": ["market_id"], }, ),
- src/polymarket_mcp/server.py:89-97 (schema)JSON schema for get-market-prices input: object with required 'market_id' string."type": "object", "properties": { "market_id": { "type": "string", "description": "Market ID or slug", }, }, "required": ["market_id"], },
- src/polymarket_mcp/server.py:181-201 (helper)Helper function to format market data into a readable string, extracting title and current_price.def format_market_prices(market_data: dict) -> str: """Format market prices into a concise string.""" try: if not market_data or not isinstance(market_data, dict): return market_data formatted_prices = [ f"Current Market Prices for {market_data.get('title', 'Unknown Market')}\n" ] # Extract price information from market data # Note: Adjust this based on actual CLOB client response structure current_price = market_data.get('current_price', 'N/A') formatted_prices.append( f"Current Price: {current_price}\n" "---\n" ) return "\n".join(formatted_prices) except Exception as e: return f"Error formatting price data: {str(e)}"