search_markets
Search for prediction markets using customizable filters like status (open, closed, resolved) and sorting options (newest, score, liquidity). Retrieve relevant market data with a specified limit for efficient browsing.
Instructions
Search for prediction markets with optional filters
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | ||
| limit | No | Max number of results (1-100) | |
| sort | No | ||
| term | No | Search query |
Input Schema (JSON Schema)
{
"properties": {
"filter": {
"enum": [
"all",
"open",
"closed",
"resolved"
],
"type": "string"
},
"limit": {
"description": "Max number of results (1-100)",
"type": "number"
},
"sort": {
"enum": [
"newest",
"score",
"liquidity"
],
"type": "string"
},
"term": {
"description": "Search query",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:529-558 (handler)Handler for the search_markets tool: parses input parameters using SearchMarketsSchema, constructs query parameters for the Manifold Markets API search endpoint, fetches the results, and returns them as a formatted JSON string.case 'search_markets': { const params = SearchMarketsSchema.parse(args); const searchParams = new URLSearchParams(); if (params.term) searchParams.set('term', params.term); if (params.limit) searchParams.set('limit', params.limit.toString()); if (params.filter) searchParams.set('filter', params.filter); if (params.sort) searchParams.set('sort', params.sort); const response = await fetch( `${API_BASE}/v0/search-markets?${searchParams}`, { headers: { Accept: 'application/json' } } ); if (!response.ok) { throw new McpError( ErrorCode.InternalError, `Manifold API error: ${response.statusText}` ); } const markets = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(markets, null, 2), }, ], }; }
- src/index.ts:51-56 (schema)Zod schema defining the input parameters for the search_markets tool: optional term for search query, limit (1-100), filter by status, and sort options.const SearchMarketsSchema = z.object({ term: z.string().optional(), limit: z.number().min(1).max(100).optional(), filter: z.enum(['all', 'open', 'closed', 'resolved']).optional(), sort: z.enum(['newest', 'score', 'liquidity']).optional(), });
- src/index.ts:214-226 (registration)Registration of the search_markets tool in the list of available tools, including name, description, and JSON schema for inputs.{ name: 'search_markets', description: 'Search for prediction markets with optional filters', inputSchema: { type: 'object', properties: { term: { type: 'string', description: 'Search query' }, limit: { type: 'number', description: 'Max number of results (1-100)' }, filter: { type: 'string', enum: ['all', 'open', 'closed', 'resolved'] }, sort: { type: 'string', enum: ['newest', 'score', 'liquidity'] }, }, }, },