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
          };
        }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does but lacks details on traits like whether it's read-only, requires authentication, has rate limits, returns paginated results, or handles errors. For a retrieval tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse. Every word earns its place, achieving optimal conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (data retrieval with parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'casts' entail (e.g., content, metadata), return format, error handling, or behavioral constraints. For a tool with these contextual gaps, the description should provide more completeness to aid the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters ('username' as Farcaster username and 'limit' with default). The description adds no additional parameter semantics beyond what the schema provides, such as format examples for usernames or constraints on limit values. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and resource 'casts from a specific Farcaster username', making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get-channel-casts' and 'get-user-casts', which likely retrieve casts by different criteria. The description is specific but lacks sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'get-channel-casts' and 'get-user-casts' available, there's no indication of when this username-based retrieval is preferred, such as for public profiles or specific user identification. No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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