search_markets
Search prediction markets by keyword, filter by open/closed/resolved status, and sort by newest, score, or liquidity.
Instructions
Search for prediction markets with optional filters
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "search_markets"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| term | No | Search query | |
| limit | No | Max number of results (1-100) | |
| filter | No | ||
| sort | No |
Implementation Reference
- src/index.ts:51-56 (schema)Zod schema for search_markets input validation, with optional fields: term, limit (1-100), filter (all/open/closed/resolved), sort (newest/score/liquidity).
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-225 (registration)Registration of the 'search_markets' tool in the ListToolsRequestSchema handler, defining its name, description, and input schema (term, limit, filter, sort).
{ 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'] }, }, }, - src/index.ts:529-558 (handler)Handler for the 'search_markets' tool call: parses params via Zod schema, constructs URL search params, fetches from Manifold API /v0/search-markets, and returns JSON results.
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), }, ], }; }