get_recent_activity
Retrieve a unified feed of recent on-chain activity including trades, splits, merges, and redemptions across all markets with market names.
Instructions
Get a unified feed of all recent on-chain activity: trades, splits, merges, and redemptions across both market types with market names.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| first | No |
Implementation Reference
- mcp-server/src/index.ts:837-895 (handler)The implementation of the 'get_recent_activity' tool handler, which queries recent trades, splits, merges, and redemptions across both market types and processes them into a unified events list.
async ({ first }) => { try { const activityQuery = `{ trades(first: ${first}, orderBy: timestamp, orderDirection: desc) { id market { id } type maker taker amountUSD price timestamp txHash } splits(first: ${first}, orderBy: timestamp, orderDirection: desc) { id stakeholder { id } conditionId amountUSD timestamp txHash } merges(first: ${first}, orderBy: timestamp, orderDirection: desc) { id stakeholder { id } conditionId amountUSD timestamp txHash } redemptions(first: ${first}, orderBy: timestamp, orderDirection: desc) { id redeemer { id } conditionId payoutUSD timestamp txHash } }`; const { simple, negrisk } = await queryBoth(activityQuery, activityQuery); const events: any[] = []; for (const src of [simple, negrisk]) { for (const t of src.trades || []) { events.push({ type: "TRADE", subType: t.type, conditionId: t.market?.id, user: t.maker, counterparty: t.taker, amountUSD: t.amountUSD, price: t.price, timestamp: t.timestamp, txHash: t.txHash, }); } for (const s of src.splits || []) { events.push({ type: "SPLIT", conditionId: s.conditionId, user: s.stakeholder?.id, amountUSD: s.amountUSD, timestamp: s.timestamp, txHash: s.txHash }); } for (const m of src.merges || []) { events.push({ type: "MERGE", conditionId: m.conditionId, user: m.stakeholder?.id, amountUSD: m.amountUSD, timestamp: m.timestamp, txHash: m.txHash }); } for (const r of src.redemptions || []) { events.push({ type: "REDEMPTION", conditionId: r.conditionId, user: r.redeemer?.id, amountUSD: r.payoutUSD, timestamp: r.timestamp, txHash: r.txHash }); } } events.sort((a, b) => Number(b.timestamp) - Number(a.timestamp)); const top = events.slice(0, first); const cids = [...new Set(top.map((e) => e.conditionId).filter(Boolean))]; const names = new Map<string, string>(); await Promise.all(cids.map(async (id) => names.set(id, await hydrateName(id)))); const enriched = top.map((e) => ({ ...e, marketName: names.get(e.conditionId) || e.conditionId, })); return textResult({ count: enriched.length, activity: enriched }); } catch (e) { return errorResult(e); - mcp-server/src/index.ts:828-836 (registration)The registration of the 'get_recent_activity' tool in the MCP server, including its description and input schema.
server.registerTool( "get_recent_activity", { description: "Get a unified feed of all recent on-chain activity: trades, splits, merges, and redemptions across both market types with market names.", inputSchema: { first: z.number().default(30), }, },