Skip to main content
Glama
manimohans

Farcaster MCP Server

by manimohans

get-username-casts

Retrieve recent casts from a Farcaster user by specifying their username. Use this tool to fetch and analyze content posted by specific accounts on the Farcaster network.

Instructions

Get casts from a specific Farcaster username

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesFarcaster username
limitNoMaximum number of casts to return (default: 10)

Implementation Reference

  • The handler function that executes the get-username-casts tool. It resolves the Farcaster username to a FID, fetches user display name, retrieves recent casts using the Hubble API, formats them, and returns a formatted text response or error.
    async ({ username, limit = 10 }: { username: string; limit?: number }) => { try { console.error(`Looking up casts for username: ${username}`); // First, we need to get the FID for the username const fid = await getFidByUsername(username); if (!fid) { return { content: [ { type: "text", text: `User "${username}" not found.` } ], isError: true }; } console.error(`Found FID ${fid} for username ${username}, fetching user data`); // Get user data to ensure we have the display name const userData = await getUserData(fid); // Use the display name if available, otherwise use the FID const displayName = userData.displayName || `FID: ${fid}`; console.error(`User data: displayName=${displayName}`); // Now get the casts for this FID const response = await fetchFromHubble(`/castsByFid`, { fid, pageSize: limit, reverse: 1 // Get newest first }) as FarcasterCastsResponse; if (!response.messages || response.messages.length === 0) { return { content: [ { type: "text", text: `No casts found for ${displayName} (FID: ${fid})` } ] }; } const castsText = await formatCasts(response.messages, limit); return { content: [ { type: "text", text: `# Casts from ${displayName}\n\n${castsText}` } ] }; } catch (error) { console.error("Error in get-username-casts:", error); return { content: [ { type: "text", text: `Error fetching casts by username: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
  • Zod schema defining the input parameters: required 'username' string and optional 'limit' number.
    { username: z.string().describe("Farcaster username"), limit: z.number().optional().describe("Maximum number of casts to return (default: 10)") },
  • src/index.ts:595-672 (registration)
    Registration of the 'get-username-casts' tool on the MCP server using server.tool(), including description, schema, and inline handler function.
    server.tool( "get-username-casts", "Get casts from a specific Farcaster username", { username: z.string().describe("Farcaster username"), limit: z.number().optional().describe("Maximum number of casts to return (default: 10)") }, async ({ username, limit = 10 }: { username: string; limit?: number }) => { try { console.error(`Looking up casts for username: ${username}`); // First, we need to get the FID for the username const fid = await getFidByUsername(username); if (!fid) { return { content: [ { type: "text", text: `User "${username}" not found.` } ], isError: true }; } console.error(`Found FID ${fid} for username ${username}, fetching user data`); // Get user data to ensure we have the display name const userData = await getUserData(fid); // Use the display name if available, otherwise use the FID const displayName = userData.displayName || `FID: ${fid}`; console.error(`User data: displayName=${displayName}`); // Now get the casts for this FID const response = await fetchFromHubble(`/castsByFid`, { fid, pageSize: limit, reverse: 1 // Get newest first }) as FarcasterCastsResponse; if (!response.messages || response.messages.length === 0) { return { content: [ { type: "text", text: `No casts found for ${displayName} (FID: ${fid})` } ] }; } const castsText = await formatCasts(response.messages, limit); return { content: [ { type: "text", text: `# Casts from ${displayName}\n\n${castsText}` } ] }; } catch (error) { console.error("Error in get-username-casts:", error); return { content: [ { type: "text", text: `Error fetching casts by username: ${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