get-user-casts
Retrieve Farcaster user casts by FID using this tool. Specify user ID and limit to fetch recent posts for analysis or interaction within the Farcaster network.
Instructions
Get casts from a specific Farcaster user by FID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fid | Yes | Farcaster user ID (FID) | |
| limit | No | Maximum number of casts to return (default: 10) |
Implementation Reference
- src/index.ts:421-465 (handler)The handler function for the 'get-user-casts' tool. It fetches casts from the Hubble API using the provided FID, limits the results, formats them using formatCasts helper, and returns a formatted text response or an error message.async ({ fid, limit = 10 }: { fid: number; limit?: number }) => { try { console.error(`Fetching casts for FID ${fid} with limit ${limit}`); const response = await fetchFromHubble(`/castsByFid`, { fid, pageSize: limit, reverse: 1 // Get newest first }) as FarcasterCastsResponse; console.error(`Got response with ${response.messages?.length || 0} messages`); if (!response.messages || response.messages.length === 0) { return { content: [ { type: "text", text: `No casts found for FID ${fid}` } ] }; } const castsText = await formatCasts(response.messages, limit); return { content: [ { type: "text", text: `# Casts from FID ${fid}\n\n${castsText}` } ] }; } catch (error) { console.error("Error in get-user-casts:", error); return { content: [ { type: "text", text: `Error fetching casts: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/index.ts:417-420 (schema)Input schema using Zod for validating the tool parameters: required 'fid' (number) and optional 'limit' (number).{ fid: z.number().describe("Farcaster user ID (FID)"), limit: z.number().optional().describe("Maximum number of casts to return (default: 10)") },
- src/index.ts:414-466 (registration)Registration of the 'get-user-casts' tool using server.tool(), specifying name, description, input schema, and handler function.server.tool( "get-user-casts", "Get casts from a specific Farcaster user by FID", { fid: z.number().describe("Farcaster user ID (FID)"), limit: z.number().optional().describe("Maximum number of casts to return (default: 10)") }, async ({ fid, limit = 10 }: { fid: number; limit?: number }) => { try { console.error(`Fetching casts for FID ${fid} with limit ${limit}`); const response = await fetchFromHubble(`/castsByFid`, { fid, pageSize: limit, reverse: 1 // Get newest first }) as FarcasterCastsResponse; console.error(`Got response with ${response.messages?.length || 0} messages`); if (!response.messages || response.messages.length === 0) { return { content: [ { type: "text", text: `No casts found for FID ${fid}` } ] }; } const castsText = await formatCasts(response.messages, limit); return { content: [ { type: "text", text: `# Casts from FID ${fid}\n\n${castsText}` } ] }; } catch (error) { console.error("Error in get-user-casts:", error); return { content: [ { type: "text", text: `Error fetching casts: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );