Skip to main content
Glama
PaulieB14

Limitless MCP

search_markets

Find markets by keyword or category with enriched on-chain data including volume and trade counts.

Instructions

Search markets by keyword or category. Returns market metadata enriched with on-chain volume and trade counts from subgraphs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoKeyword to search in title/description
categoriesNoFilter by categories (e.g. ['Crypto', 'Politics'])
firstNoNumber of results to return

Implementation Reference

  • The handler for the search_markets tool, which invokes the apiClient's searchMarkets function and then enriches the results with subgraph data.
    async ({ query, categories, first }) => {
      try {
        const apiResults = await searchMarkets(query, categories, first);
    
        // Enrich each result with on-chain stats from subgraphs
        const enriched = await Promise.all(
          apiResults.map(async (m) => {
            const mq = (entity: string) =>
              `{ ${entity}(id: "${m.conditionId}") { tradesCount volumeUSD feesUSD } }`;
            const [s, n] = await Promise.all([
              querySimple(mq("market")).catch(() => ({ market: null })),
              queryNegRisk(mq("negRiskMarket")).catch(() => ({ negRiskMarket: null })),
            ]);
            const onChain = s.market || n.negRiskMarket;
            return {
              title: m.title,
              conditionId: m.conditionId,
              categories: m.categories,
              currentPrices: m.prices,
              expirationDate: m.expirationDate,
              marketType: m.marketType,
              tradeType: m.tradeType,
              status: m.status,
              onChainVolume: onChain?.volumeUSD || "0",
              onChainTrades: onChain?.tradesCount || "0",
              onChainFees: onChain?.feesUSD || "0",
            };
          })
        );
    
        return textResult({ count: enriched.length, markets: enriched });
      } catch (e) {
        return errorResult(e);
      }
    }
  • The implementation of searchMarkets in apiClient.ts, which fetches from the API and filters cached markets.
    export async function searchMarkets(
      query?: string,
      categories?: string[],
      first = 20
    ): Promise<MarketMeta[]> {
      // If there's a query, also try the API search endpoint for broader results
      if (query) {
        const headers = getHeaders();
        try {
          const res = await fetch(
            `${LIMITLESS_API_BASE}/markets/search?query=${encodeURIComponent(query)}`,
            { headers }
          );
          if (res.ok) {
            const json = (await res.json()) as { markets: any[] };
            for (const m of json.markets || []) {
              const meta = toMarketMeta(m);
              if (meta) marketCache.set(meta.conditionId.toLowerCase(), meta);
            }
          }
        } catch {
          // Fall back to cache-only search
        }
      }
    
      await refreshMarketCache();
      let results = Array.from(marketCache.values());
    
      if (query) {
        const q = query.toLowerCase();
        results = results.filter(
          (m) =>
            m.title.toLowerCase().includes(q) ||
            m.description.toLowerCase().includes(q) ||
            m.slug.toLowerCase().includes(q)
        );
      }
    
      if (categories && categories.length > 0) {
        const cats = categories.map((c) => c.toLowerCase());
        results = results.filter((m) =>
          m.categories.some((c) => cats.includes(c.toLowerCase()))
        );
      }
    
      return results.slice(0, first);
    }
  • Registration of the search_markets tool in the MCP server.
    server.registerTool(
      "search_markets",
      {
        description:
          "Search markets by keyword or category. Returns market metadata enriched with on-chain volume and trade counts from subgraphs.",
        inputSchema: {
          query: z.string().optional().describe("Keyword to search in title/description"),
          categories: z
            .array(z.string())
            .optional()
            .describe("Filter by categories (e.g. ['Crypto', 'Politics'])"),
          first: z.number().default(20).describe("Number of results to return"),
        },
      },
Behavior3/5

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

No annotations provided, so description carries full burden. Adds valuable behavioral context by disclosing data source ('from subgraphs') and return composition ('metadata enriched with on-chain volume and trade counts'). However, lacks operational details like rate limits, pagination cursors, or caching behavior that would be necessary for complete transparency without annotation support.

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?

Two sentences with zero waste. First sentence front-loads the action and scope; second sentence clarifies return value. Every word earns its place.

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?

For a 3-parameter search tool with 100% schema coverage but no output schema, the description adequately compensates by describing return values ('market metadata enriched...'). Missing only pagination strategy details (cursor vs offset) which would be helpful given 'first' implies limit-based pagination.

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 schema fully documents all three parameters. Description mentions 'keyword or category' which maps to the parameter intent, but adds no syntax guidance, validation rules, or semantic relationships beyond what the schema properties already provide. Baseline 3 appropriate when schema does heavy lifting.

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?

Clear verb 'Search' and resource 'markets' with specific scope 'by keyword or category'. Distinguishes from siblings like get_market_analytics or get_market_trades by implying discovery/finding functionality rather than retrieval of specific known entities, though it doesn't explicitly contrast with them.

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

Usage Guidelines3/5

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

Implies usage through 'Search markets by keyword or category' but provides no explicit when-to-use guidance versus alternatives like query_subgraph (raw graph access) or get_market_analytics (specific market data). No mention of prerequisites or exclusions.

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

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/PaulieB14/limitless-subgraphs'

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