Skip to main content
Glama
berlinbra

PolyMarket MCP Server

get-market-history

Retrieve historical price and volume data for a specified market using a Market ID or slug. Choose timeframes like 1d, 7d, 30d, or all to analyze market trends and performance over time.

Instructions

Get historical price and volume data for a market

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
market_idYesMarket ID or slug
timeframeNoTime period for historical data7d

Implementation Reference

  • The core handler logic for the 'get-market-history' tool within the @server.call_tool() function. It extracts market_id and timeframe from arguments, fetches market data using ClobClient.get_market(), formats it using format_market_history, and returns the result as text content.
    elif name == "get-market-history":
        market_id = arguments.get("market_id")
        timeframe = arguments.get("timeframe", "7d")
        
        if not market_id:
            return [types.TextContent(type="text", text="Missing market_id parameter")]
        
        # Note: Adjust this based on actual CLOB client capabilities
        market_data = client.get_market(market_id)
        formatted_history = format_market_history(market_data)
        return [types.TextContent(type="text", text=formatted_history)]
  • JSON Schema defining the input parameters for the 'get-market-history' tool: market_id (required string) and timeframe (optional enum with default '7d').
    inputSchema={
        "type": "object",
        "properties": {
            "market_id": {
                "type": "string",
                "description": "Market ID or slug",
            },
            "timeframe": {
                "type": "string",
                "description": "Time period for historical data",
                "enum": ["1d", "7d", "30d", "all"],
                "default": "7d"
            }
        },
        "required": ["market_id"],
    },
  • Registration of the 'get-market-history' tool in the @server.list_tools() function, including name, description, and input schema.
    types.Tool(
        name="get-market-history",
        description="Get historical price and volume data for a market",
        inputSchema={
            "type": "object",
            "properties": {
                "market_id": {
                    "type": "string",
                    "description": "Market ID or slug",
                },
                "timeframe": {
                    "type": "string",
                    "description": "Time period for historical data",
                    "enum": ["1d", "7d", "30d", "all"],
                    "default": "7d"
                }
            },
            "required": ["market_id"],
        },
    )
  • Helper function to format the raw market history data into a readable string, extracting recent history points and handling errors.
    def format_market_history(history_data: dict) -> str:
        """Format market history data into a concise string."""
        try:
            if not history_data or not isinstance(history_data, dict):
                return "No historical data available"
                
            formatted_history = [
                f"Historical Data for {history_data.get('title', 'Unknown Market')}\n"
            ]
            
            # Format historical data points
            # Note: Adjust this based on actual CLOB client response structure
            for point in history_data.get('history', [])[-5:]:
                formatted_history.append(
                    f"Time: {point.get('timestamp', 'N/A')}\n"
                    f"Price: {point.get('price', 'N/A')}\n"
                    "---\n"
                )
            
            return "\n".join(formatted_history)
        except Exception as e:
            return f"Error formatting historical data: {str(e)}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it indicates this is a read operation ('Get'), it lacks details on permissions, rate limits, data freshness, or error handling. For a tool fetching historical market data, this omission is significant, as users need to understand constraints like data availability or API limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Get historical price and volume data for a market'. It's front-loaded with the core purpose, has zero waste, and is appropriately sized for a simple tool. Every word earns its place without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (historical data retrieval with parameters) and lack of annotations and output schema, the description is incomplete. It doesn't explain what the return values look like (e.g., data format, fields), potential limitations (e.g., max timeframe), or how it differs from siblings. For a tool without structured output documentation, this leaves gaps in usability.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents both parameters ('market_id' and 'timeframe') with descriptions and an enum for 'timeframe'. The description adds no additional parameter semantics beyond implying historical data retrieval, which is already covered by the tool's purpose. Baseline 3 is appropriate as the schema handles most documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get historical price and volume data for a market'. It specifies the verb ('Get'), resource ('historical price and volume data'), and target ('for a market'). However, it doesn't explicitly distinguish this tool from sibling tools like 'get-market-prices' or 'get-market-info', which might also retrieve market data but with different scopes or timeframes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get-market-prices' or 'get-market-info', nor does it specify scenarios where this tool is preferred (e.g., for historical analysis vs. current data). Without such context, users might struggle to choose between similar tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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