get-user-casts
Retrieve casts from a specific Farcaster user by providing their FID, with options to limit the number of results returned.
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 async handler function that implements the core logic of the 'get-user-casts' tool: fetches casts for a given FID from the Hubble API, formats them using formatCasts helper, and returns formatted text response or error.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)Zod schema defining input parameters for the 'get-user-casts' tool: 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 with MCP server using server.tool(name, description, inputSchema, handler).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 }; } } );