Skip to main content
Glama
berlinbra

PolyMarket MCP Server

get-market-info

Retrieve detailed data on a specific prediction market using a market ID or slug. This tool integrates with the PolyMarket API to provide accurate market insights, including pricing and historical trends.

Instructions

Get detailed information about a specific prediction market

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
market_idYesMarket ID or slug

Implementation Reference

  • Handler implementation for the 'get-market-info' tool. Extracts the market_id argument, fetches market data using the ClobClient, formats it using format_market_info helper, and returns the result as text content.
    if name == "get-market-info":
        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_info = format_market_info(market_data)
        return [types.TextContent(type="text", text=formatted_info)]
  • JSON Schema defining the input for the 'get-market-info' tool, requiring a 'market_id' string parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "market_id": {
                "type": "string",
                "description": "Market ID or slug",
            },
        },
        "required": ["market_id"],
    },
  • Registration of the 'get-market-info' tool within the @server.list_tools() handler, specifying name, description, and input schema.
    types.Tool(
        name="get-market-info",
        description="Get detailed information about a specific prediction market",
        inputSchema={
            "type": "object",
            "properties": {
                "market_id": {
                    "type": "string",
                    "description": "Market ID or slug",
                },
            },
            "required": ["market_id"],
        },
    ),
  • Helper function that formats the raw market data dictionary into a human-readable string summary, extracting key fields like condition_id, title, status, and resolution_date.
    def format_market_info(market_data: dict) -> str:
        """Format market information into a concise string."""
        try:
            if not market_data or not isinstance(market_data, dict):
                return "No market information available"
                
            condition_id = market_data.get('condition_id', 'N/A')
            title = market_data.get('title', 'N/A')
            status = market_data.get('status', 'N/A')
            resolution_date = market_data.get('resolution_date', 'N/A')
                
            return (
                f"Condition ID: {condition_id}\n"
                f"Title: {title}\n"
                f"Status: {status}\n"
                f"Resolution Date: {resolution_date}\n"
                "---"
            )
        except Exception as e:
            return f"Error formatting market data: {str(e)}"
Install Server

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