Skip to main content
Glama
brianellin

Bluesky MCP Server

by brianellin

get-liked-posts

Retrieve a list of posts liked by the authenticated user, with a customizable limit of 1 to 100 posts, using the Bluesky MCP Server's API.

Instructions

Get a list of posts that the authenticated user has liked

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of liked posts to fetch (1-100)

Implementation Reference

  • src/index.ts:502-582 (registration)
    Registers the 'get-liked-posts' MCP tool with schema and inline handler function that fetches user's liked posts via Bluesky API.
    server.tool(
      "get-liked-posts",
      "Get a list of posts that the authenticated user has liked",
      {
        limit: z.number().min(1).max(100).default(50).describe("Maximum number of liked posts to fetch (1-100)"),
      },
      async ({ limit }) => {
        if (!agent) {
          return mcpErrorResponse("Not logged in. Please check your environment variables.");
        }
    
        const currentAgent = agent; // Assign to non-null variable to satisfy TypeScript
        
        try {
          // We can only get likes for the authenticated user
          if (!currentAgent.session?.handle) {
            return mcpErrorResponse("Not properly authenticated. Please check your credentials.");
          }
          
          const authenticatedUser = currentAgent.session.handle;
          
          // Now fetch the authenticated user's likes with pagination
          const MAX_BATCH_SIZE = 100; // Maximum number of likes per API call
          const MAX_BATCHES = 5;      // Maximum number of API calls to make (100 x 5 = 500)
          let allLikes: any[] = [];
          let nextCursor: string | undefined = undefined;
          let batchCount = 0;
          
          // Loop to fetch likes with pagination
          while (batchCount < MAX_BATCHES && allLikes.length < limit) {
            // Calculate how many likes to fetch in this batch
            const batchLimit = Math.min(MAX_BATCH_SIZE, limit - allLikes.length);
            
            // Make the API call with cursor if we have one
            const response = await currentAgent.app.bsky.feed.getActorLikes({
              actor: authenticatedUser,
              limit: batchLimit,
              cursor: nextCursor || undefined
            });
            
            if (!response.success) {
              // If we've already fetched some likes, return those
              if (allLikes.length > 0) {
                break;
              }
              return mcpErrorResponse(`Failed to fetch your likes.`);
            }
            
            const { feed, cursor } = response.data;
            
            // Add the fetched likes to our collection
            allLikes = allLikes.concat(feed);
            
            // Update cursor for the next batch
            nextCursor = cursor;
            batchCount++;
            
            // If no cursor returned or we've reached our limit, stop paginating
            if (!cursor || allLikes.length >= limit) {
              break;
            }
          }
          
          if (allLikes.length === 0) {
            return mcpSuccessResponse(`You haven't liked any posts.`);
          }
          
          // Format the likes list using preprocessPosts
          const formattedLikes = preprocessPosts(allLikes);
          
          // Create a summary
          const summaryText = formatSummaryText(allLikes.length, "liked posts");
          
          return mcpSuccessResponse(`${summaryText}\n\n${formattedLikes}`);
          
        } catch (error) {
          return mcpErrorResponse(`Error fetching likes: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );
  • Handler function implements the core logic: authenticates, paginates getActorLikes API calls for the user's likes, preprocesses posts for display, and returns formatted summary.
      async ({ limit }) => {
        if (!agent) {
          return mcpErrorResponse("Not logged in. Please check your environment variables.");
        }
    
        const currentAgent = agent; // Assign to non-null variable to satisfy TypeScript
        
        try {
          // We can only get likes for the authenticated user
          if (!currentAgent.session?.handle) {
            return mcpErrorResponse("Not properly authenticated. Please check your credentials.");
          }
          
          const authenticatedUser = currentAgent.session.handle;
          
          // Now fetch the authenticated user's likes with pagination
          const MAX_BATCH_SIZE = 100; // Maximum number of likes per API call
          const MAX_BATCHES = 5;      // Maximum number of API calls to make (100 x 5 = 500)
          let allLikes: any[] = [];
          let nextCursor: string | undefined = undefined;
          let batchCount = 0;
          
          // Loop to fetch likes with pagination
          while (batchCount < MAX_BATCHES && allLikes.length < limit) {
            // Calculate how many likes to fetch in this batch
            const batchLimit = Math.min(MAX_BATCH_SIZE, limit - allLikes.length);
            
            // Make the API call with cursor if we have one
            const response = await currentAgent.app.bsky.feed.getActorLikes({
              actor: authenticatedUser,
              limit: batchLimit,
              cursor: nextCursor || undefined
            });
            
            if (!response.success) {
              // If we've already fetched some likes, return those
              if (allLikes.length > 0) {
                break;
              }
              return mcpErrorResponse(`Failed to fetch your likes.`);
            }
            
            const { feed, cursor } = response.data;
            
            // Add the fetched likes to our collection
            allLikes = allLikes.concat(feed);
            
            // Update cursor for the next batch
            nextCursor = cursor;
            batchCount++;
            
            // If no cursor returned or we've reached our limit, stop paginating
            if (!cursor || allLikes.length >= limit) {
              break;
            }
          }
          
          if (allLikes.length === 0) {
            return mcpSuccessResponse(`You haven't liked any posts.`);
          }
          
          // Format the likes list using preprocessPosts
          const formattedLikes = preprocessPosts(allLikes);
          
          // Create a summary
          const summaryText = formatSummaryText(allLikes.length, "liked posts");
          
          return mcpSuccessResponse(`${summaryText}\n\n${formattedLikes}`);
          
        } catch (error) {
          return mcpErrorResponse(`Error fetching likes: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );
  • Zod schema for tool input parameters defining the 'limit' for number of liked posts.
    {
      limit: z.number().min(1).max(100).default(50).describe("Maximum number of liked posts to fetch (1-100)"),
    },
  • Uses preprocessPosts helper from llm-preprocessor.ts to format the fetched liked posts for output.
    const formattedLikes = preprocessPosts(allLikes);

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It only states that it gets liked posts but does not mention authentication requirements, ordering, pagination behavior beyond the limit parameter, error handling, or the response structure. This is minimal disclosure for a tool with no annotation support.

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, concise sentence that is front-loaded with the key verb and resource. It contains no unnecessary words or repetition and is easy to parse quickly.

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

Completeness3/5

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

Given the tool's simplicity (one parameter, no output schema), the description is adequate but minimal. It lacks any mention of response format, empty-list behavior, or authentication side effects, which would be useful for agents to fully understand the tool's output and potential failure modes.

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?

The input schema fully describes the single 'limit' parameter (type, default, minimum, maximum). The description adds no extra meaning to this parameter, so the baseline of 3 applies given 100% schema coverage.

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

Purpose5/5

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

The description uses a specific verb ('Get') and clearly identifies the resource ('list of posts that the authenticated user has liked'), distinguishing it from sibling tools like get-post-likes (which lists users who liked a post) and get-user-posts (which lists posts created by a user).

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

Usage Guidelines3/5

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

The description clearly states the tool's purpose, implying it should be used when the authenticated user's liked posts are needed. However, it does not explicitly mention when not to use it or reference any alternative tools, though none of the siblings directly duplicate this functionality.

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