Skip to main content
Glama
manimohans

Farcaster MCP Server

by manimohans

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
NameRequiredDescriptionDefault
fidYesFarcaster user ID (FID)
limitNoMaximum number of casts to return (default: 10)

Implementation Reference

  • 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 }; } }
  • 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 }; } } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/manimohans/farcaster-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server