import { z } from "zod";
import { fetchComments } from "../services/gamma.js";
const schema = z.object({
limit: z.number().optional().default(20).describe("Number of comments to return (default: 20)"),
offset: z.number().optional().default(0).describe("Pagination offset (default: 0)"),
user: z.string().optional().describe("Filter by user address (0x...)"),
market: z.string().optional().describe("Filter by market slug or ID"),
order: z.string().optional().describe("Comma-separated list of fields to order by"),
ascending: z.boolean().optional().describe("Sort ascending"),
parent_entity_type: z
.enum(["Event", "Series", "market"])
.optional()
.describe("Filter by parent entity type"),
parent_entity_id: z.number().optional().describe("Filter by parent entity ID"),
get_positions: z.boolean().optional().describe("Include commenter's positions"),
holders_only: z.boolean().optional().describe("Only include comments from holders"),
});
export const listCommentsTool = {
name: "list_comments",
description:
"List comments from Gamma API /comments. Requires parent_entity_type and parent_entity_id in practice (use list_events/list_series/list_markets to get IDs); otherwise Gamma often returns 422. Example: parent_entity_type=Event, parent_entity_id=80505.",
parameters: schema,
execute: async (args: z.infer<typeof schema>) => {
try {
const data = await fetchComments(args);
return JSON.stringify(data, null, 2);
} catch (error) {
return JSON.stringify({ error: error instanceof Error ? error.message : String(error) });
}
},
};