Skip to main content
Glama
brianellin

Bluesky MCP Server

by brianellin

get-list-posts

Retrieve posts from a user list on Bluesky by specifying list URI, count, and time frame. Enables focused content curation and analysis.

Instructions

Fetch posts from users in a specified list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesNumber of posts to fetch or hours to look back
listYesThe URI of the list (e.g., at://did:plc:abcdef/app.bsky.graph.list/listname)
typeYesWhether count represents number of posts or hours to look back

Implementation Reference

  • Complete registration and implementation of the 'get-list-posts' tool. This includes the tool name, description, Zod input schema for list URI, count, and type parameters, and the full async handler function that validates the list URI, fetches posts via Bluesky's getListFeed API with pagination support, applies optional time-based filtering, limits results, preprocesses the posts using preprocessPosts, formats a summary, and returns a formatted response or error.
    server.tool(
      "get-list-posts",
      "Fetch posts from users in a specified list",
      {
        list: z.string().describe("The URI of the list (e.g., at://did:plc:abcdef/app.bsky.graph.list/listname)"),
        count: z.number().min(1).max(500).describe("Number of posts to fetch or hours to look back"),
        type: z.enum(["posts", "hours"]).describe("Whether count represents number of posts or hours to look back")
      },
      async ({ list, count, type }) => {
        if (!agent) {
          return mcpErrorResponse("Not connected to Bluesky. Check your environment variables.");
        }
    
        const currentAgent = agent; // Assign to non-null variable to satisfy TypeScript
        
        try {
          // Validate the list by getting its info
          const listInfo = await validateUri(currentAgent, list, 'list');
          if (!listInfo) {
            return mcpErrorResponse(`Invalid list URI or list not found: ${list}.`);
          }
    
          const MAX_TOTAL_POSTS = 500; // Safety limit to prevent excessive API calls
          
          let allPosts: any[] = [];
          let nextCursor: string | undefined = undefined;
          let shouldContinueFetching = true;
          
          // Set up time-based or count-based fetching
          const useHoursLimit = type === "hours";
          const targetHours = count;
          const targetDate = new Date(Date.now() - targetHours * 60 * 60 * 1000);
          
          while (shouldContinueFetching && allPosts.length < MAX_TOTAL_POSTS) {
            // Calculate how many posts to fetch in this batch
            const batchLimit = 100;
            
            const response = await currentAgent.app.bsky.feed.getListFeed({ 
              list,
              limit: batchLimit,
              cursor: nextCursor
            });
            
            if (!response.success) {
              break;
            }
            
            const { feed, cursor } = response.data;
            
            // Filter posts based on time window if using hours limit
            let filteredFeed = feed;
            if (useHoursLimit) {
              filteredFeed = feed.filter(post => {
                const createdAt = post?.post?.record?.createdAt;
                if (!createdAt || typeof createdAt !== 'string') return false;
                const postDate = new Date(createdAt);
                return postDate >= targetDate;
              });
            }
            
            // Add the filtered posts to our collection
            allPosts = allPosts.concat(filteredFeed);
            
            // Update cursor for the next batch
            nextCursor = cursor;
            
            // Check if we should continue fetching based on the mode
            if (useHoursLimit) {
              // Check if we've reached posts older than our target date
              const oldestPost = feed[feed.length - 1];
              if (oldestPost?.post?.record?.createdAt && typeof oldestPost.post.record.createdAt === 'string') {
                const postDate = new Date(oldestPost.post.record.createdAt);
                if (postDate < targetDate) {
                  shouldContinueFetching = false;
                }
              }
            } else {
              // If we're using count-based fetching, stop when we have enough posts
              shouldContinueFetching = allPosts.length < count;
            }
            
            // Stop if we don't have a cursor for the next page
            if (!cursor) {
              shouldContinueFetching = false;
            }
          }
          
          // If we're using count-based fetching, limit the posts to the requested count
          const finalPosts = !useHoursLimit
            ? allPosts.slice(0, count)
            : allPosts;
    
          // If no posts were found after filtering
          if (finalPosts.length === 0) {
            return mcpSuccessResponse(`No posts found from the list.`);
          }
    
          // Format the posts
          const formattedPosts = preprocessPosts(finalPosts);
    
          // Add summary information
          const summaryText = formatSummaryText(finalPosts.length, "list");
    
          return mcpSuccessResponse(`${summaryText}\n\n${formattedPosts}`);
        } catch (error) {
          return mcpErrorResponse(`Error fetching list posts: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );

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 carries the full burden. It only states 'Fetch posts' with no additional behavioral details such as authentication requirements, rate limits, sorting, or pagination. This is a minimal disclosure.

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, clear sentence with no wasted words. It is concise and front-loaded with the action and resource.

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?

The tool is relatively simple with no output schema, but the description could provide more context about the 'type' parameter (posts vs hours) or what constitutes a 'list'. As is, it is minimally complete but leaves some ambiguity about behavior and return value.

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?

All three parameters have schema descriptions (100% coverage), so the description does not need to explain them. The description itself adds no extra semantic value beyond what the schema already provides. Baseline score of 3 applies.

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 clearly states the action (fetch posts) and the specific resource (users in a specified list). This distinguishes it from sibling tools like get-user-posts or get-timeline-posts, which fetch from different sources.

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 implies that this tool is for fetching posts from a list of users, but it does not explicitly state when to use it over alternatives or any exclusions. The context is implied, not explicit.

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