Skip to main content
Glama

PolyMarket MCP Server

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

NameRequiredDescriptionDefault
market_idYesMarket ID or slug

Input Schema (JSON Schema)

{ "properties": { "market_id": { "description": "Market ID or slug", "type": "string" } }, "required": [ "market_id" ], "type": "object" }

Implementation Reference

  • 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)]
  • 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"], }, ),
  • 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"], },
  • 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)}"

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/berlinbra/polymarket-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server