Skip to main content
Glama

search_prediction_markets

Search Polymarket prediction markets by keyword to retrieve detailed market data, including titles, trading volumes, and outcome probabilities in JSON format.

Instructions

Search prediction markets by any term.

Parameters

search_term : str Identifier such as "argentina".

Returns

str JSON array of objects with the schema: [ { "title": "Trump to win 2024?", "volume": 123456.78, "outcomes": [ {"option": "Yes", "probability": 0.42}, {"option": "No", "probability": 0.58} ] }, … ] Parse with json.loads.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_termYes

Implementation Reference

  • main.py:62-91 (handler)
    Handler function for the 'search_prediction_markets' tool, decorated with @mcp.tool for registration. Calls the helper in polymarket.py and returns JSON serialized markets.
    @mcp.tool
    async def search_prediction_markets(search_term: str) -> str:
        """
        Search prediction markets by any term.
    
        Parameters
        ----------
        search_term : str
            Identifier such as "argentina".
    
        Returns
        -------
        str
            JSON array of objects with the schema:
            [
              {
                "title": "Trump to win 2024?",
                "volume": 123456.78,
                "outcomes": [
                  {"option": "Yes", "probability": 0.42},
                  {"option": "No",  "probability": 0.58}
                ]
              },
              …
            ]
            Parse with `json.loads`.
        """
    
        markets = await poly.search_markets(search_term)
        return json.dumps([m.model_dump() for m in markets])
  • Pydantic models defining the output schema for markets and outcomes used by the tool.
    class MarketOutcome(BaseModel):
        option: str
        probability: float
    
    
    class Markets(BaseModel):
        title: str
        volume: float
        outcomes: list[MarketOutcome]
  • Core helper function that performs the API search on Polymarket, parses events into Markets models, and returns the list of active markets.
    async def search_markets(search_term: str) -> list[Markets]:
        url = f"https://polymarket.com/api/events/search?_c=all&_q={search_term}&_p=1&active=true&archived=false&closed=false"
        events = requests.get(url, timeout=15).json()["events"]
        markets: list[Markets] = []
        for event in events:
            if event.get("archived", True) or event.get("closed", True):
                continue
            if not event.get("active", False):
                continue
    
            if len(event["markets"]) == 1:
                outcomes = [
                    MarketOutcome(
                        option=outcome,
                        probability=float(price),
                    )
                    for outcome, price in zip(
                        event["markets"][0]["outcomes"],
                        event["markets"][0]["outcomePrices"],
                    )
                ]
            else:
                outcomes: list[MarketOutcome] = []
                for market in event["markets"]:
                    outcomes.append(
                        MarketOutcome(
                            option=market["groupItemTitle"],
                            probability=float(market["outcomePrices"][0]),
                        )
                    )
    
            markets.append(
                Markets(
                    title=event["title"],
                    volume=float(event["volume"]),
                    outcomes=outcomes,
                )
            )
        return markets
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly describes the search functionality and output format, including the JSON structure and parsing instruction. However, it lacks details on rate limits, authentication needs, error handling, or whether this is a read-only operation (implied by 'Search' but not explicit). The description adds useful context but misses some behavioral traits.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, parameters, returns) and front-loaded key information. Every sentence adds value, such as the parsing instruction. It's appropriately sized for a single-parameter tool, though the returns section is detailed, which is necessary given the lack of output schema.

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

Completeness4/5

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

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is fairly complete. It covers the purpose, parameter semantics, and output format in detail, which is crucial since there's no output schema. However, it lacks sibling differentiation and some behavioral context, which slightly reduces completeness for an agent's decision-making.

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

Parameters4/5

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

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'search_term' is an 'Identifier such as "argentina"', providing a concrete example and clarifying it's a string for searching. This compensates well for the schema's lack of documentation, though it could elaborate on format constraints or examples.

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 with a specific verb ('Search') and resource ('prediction markets'), and specifies the search scope ('by any term'). However, it doesn't explicitly differentiate from sibling tools like 'prediction_markets_markets_by_topic' or 'prediction_markets_trending_topics', which likely have different search approaches or criteria.

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 its siblings. It mentions searching 'by any term' but doesn't clarify if this is for general keyword searches, while siblings might filter by topic or trending status. There are no explicit when-to-use or when-not-to-use instructions, leaving the agent to infer usage from tool names alone.

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/fernandezpablo85/polymarket-mcp'

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