Skip to main content
Glama
brianellin

Bluesky MCP Server

by brianellin

get-timeline-posts

Retrieve your Bluesky home timeline, displaying posts from followed accounts in reverse chronological order. Specify the number of posts or hours to fetch for customizable results.

Instructions

Fetch your home timeline from Bluesky, which includes posts from all of the people you follow in reverse chronological order

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesNumber of posts to fetch or hours to look back
typeYesWhether count represents number of posts or hours to look back

Implementation Reference

  • The handler function for 'get-timeline-posts' tool. Fetches home timeline posts via agent.getTimeline with pagination, supports fetching by post count or hours back, filters accordingly, preprocesses posts using preprocessPosts, adds summary with formatSummaryText, and returns formatted text response.
    async ({ count, type }) => {
      try {
        if (!agent) {
          return mcpErrorResponse("Not connected to Bluesky. Check your environment variables.");
        }
    
        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 agent.getTimeline({ 
            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 (finalPosts.length === 0) {
          return mcpSuccessResponse("Your timeline is empty.");
        }
        
        // Format the posts
        const timelineData = preprocessPosts(finalPosts);
    
        const summaryText = formatSummaryText(finalPosts.length, "timeline");
        
        return mcpSuccessResponse(`${summaryText}\n\n${timelineData}`);
        
      } catch (error) {
        return mcpErrorResponse(`Error fetching timeline: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema using Zod for the tool parameters: count (number between 1-500), type (enum: 'posts' or 'hours').
    {
      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")
    },
  • src/index.ts:113-210 (registration)
    Registration of the 'get-timeline-posts' tool on the MCP server, including name, description, input schema, and handler function.
    server.tool(
      "get-timeline-posts",
      "Fetch your home timeline from Bluesky, which includes posts from all of the people you follow in reverse chronological order",
      {
        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 ({ count, type }) => {
        try {
          if (!agent) {
            return mcpErrorResponse("Not connected to Bluesky. Check your environment variables.");
          }
    
          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 agent.getTimeline({ 
              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 (finalPosts.length === 0) {
            return mcpSuccessResponse("Your timeline is empty.");
          }
          
          // Format the posts
          const timelineData = preprocessPosts(finalPosts);
    
          const summaryText = formatSummaryText(finalPosts.length, "timeline");
          
          return mcpSuccessResponse(`${summaryText}\n\n${timelineData}`);
          
        } catch (error) {
          return mcpErrorResponse(`Error fetching timeline: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4/5.0
Behavior3/5

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

With no annotations provided, the description carries the burden of behavioral disclosure. 'Fetch' implies a read-only operation, and 'reverse chronological order' explains the ordering behavior. However, it does not mention authentication requirements, pagination, rate limits, or the exact response structure, leaving gaps for an agent assessing side effects and usage constraints.

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, well-structured sentence that is immediately informative. It avoids fluff and provides the essential information (resource and content) in a clear, front-loaded manner.

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

Completeness4/5

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

Given the tool's simplicity and complete schema coverage, the description is nearly sufficient. It explains what the timeline contains and the ordering. However, because there is no output schema, a brief note about the return format (e.g., a list of post objects) would make it fully complete for an 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%, so the input schema already thoroughly explains both parameters ('count' as number of posts or hours, and 'type' as posts/hours). The description adds no additional parameter semantics, which is acceptable because the schema handles the heavy lifting.

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 'Fetch' and clearly identifies the resource as 'your home timeline from Bluesky'. It further distinguishes this from sibling tools by explaining it contains posts from followed people in reverse chronological order, which separates it from get-user-posts, get-feed-posts, and get-list-posts.

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

Usage Guidelines4/5

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

The description provides clear context about what the tool does (home timeline of followed users), making it easy to infer when to use it. However, it does not explicitly state when not to use it or mention alternatives, but the context is strong enough to guide selection among similar timeline-related tools.

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