get_conditions
Retrieve prepared on-chain market conditions and filter by resolution status to identify resolved or unresolved markets.
Instructions
Get conditions (markets that have been prepared on-chain) with resolution status. Useful for finding resolved/unresolved markets.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resolved | No | Filter by resolution status | |
| first | No |
Implementation Reference
- mcp-server/src/index.ts:999-1039 (handler)The handler function for the 'get_conditions' tool, which queries a subgraph for conditions and hydrates their names.
async ({ resolved, first }) => { try { const resolvedFilter = resolved !== undefined ? `resolved: ${resolved}` : ""; const condQuery = `{ conditions( first: ${first} orderBy: createdAt orderDirection: desc ${resolvedFilter ? `where: { ${resolvedFilter} }` : ""} ) { id oracle questionId outcomeSlotCount resolved payoutNumerators createdAt resolvedAt } }`; const { simple, negrisk } = await queryBoth(condQuery, condQuery); // Deduplicate by id (same CTF contract, same conditions in both) const seen = new Set<string>(); const conditions: any[] = []; for (const c of [...(simple.conditions || []), ...(negrisk.conditions || [])]) { if (!seen.has(c.id)) { seen.add(c.id); conditions.push(c); } } conditions.sort((a, b) => Number(b.createdAt) - Number(a.createdAt)); const top = conditions.slice(0, first); // Hydrate names const names = new Map<string, string>(); await Promise.all(top.map(async (c: any) => names.set(c.id, await hydrateName(c.id)))); const enriched = top.map((c: any) => ({ ...c, title: names.get(c.id) })); return textResult({ count: enriched.length, conditions: enriched }); } catch (e) { return errorResult(e); } } ); - mcp-server/src/index.ts:989-998 (registration)Tool registration for 'get_conditions' in the MCP server.
server.registerTool( "get_conditions", { description: "Get conditions (markets that have been prepared on-chain) with resolution status. Useful for finding resolved/unresolved markets.", inputSchema: { resolved: z.boolean().optional().describe("Filter by resolution status"), first: z.number().default(20), }, },