search_markets
Find prediction markets on Manifold Markets using search terms, filters by status, and sorting options to locate specific trading opportunities.
Instructions
Search for prediction markets with optional filters
Input Schema
TableJSON 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:529-558 (handler)The main handler function for the 'search_markets' tool. It validates input parameters using SearchMarketsSchema, constructs a URLSearchParams query string, fetches market data from the Manifold Markets API endpoint '/v0/search-markets', handles errors, and returns the JSON-stringified results as text content.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 search term, limit (1-100), filter (all/open/closed/resolved), and sort (newest/score/liquidity). Used for validation in the handler.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)Tool registration entry in the listTools response. Defines the tool name, description, and JSON Schema for inputs, making it discoverable by MCP clients.{ 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'] }, }, }, },