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

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it fetches liked posts for the authenticated user, implying read-only behavior and authentication needs, but doesn't specify pagination, rate limits, error conditions, or what the return format looks like (e.g., list structure, fields included).

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 appropriately sized for a simple retrieval tool and front-loads the core functionality.

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?

For a tool with no annotations and no output schema, the description is incomplete. It doesn't explain what data is returned (e.g., post content, timestamps, like counts), how results are ordered, or whether authentication is required beyond mentioning 'authenticated user'. Given the lack of structured fields, more behavioral context is needed.

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 the single parameter 'limit' fully documented in the schema (range 1-100, default 50). The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3.

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 'list of posts that the authenticated user has liked', making the purpose unambiguous. It distinguishes from siblings like 'get-user-posts' (posts by a user) and 'get-post-likes' (users who liked a post), though it doesn't explicitly name these alternatives.

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. It doesn't mention when this tool is appropriate compared to 'get-user-posts' (for posts authored by the user) or 'get-feed-posts' (for feed content), nor does it specify prerequisites like authentication requirements.

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

Related 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/brianellin/bsky-mcp-server'

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