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)}`);
        }
      }
    );
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 describes what data is fetched but doesn't mention authentication requirements, rate limits, pagination behavior, error conditions, or what the response format looks like. For a data-fetching tool with zero annotation coverage, this leaves significant behavioral gaps.

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 front-loads the core purpose. Every word earns its place by specifying the action, resource, and key behavioral characteristics (reverse chronological order, from followed users). No wasted words or redundant information.

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 data retrieval tool with no annotations and no output schema, the description is insufficiently complete. It doesn't describe the response format, authentication requirements, error handling, or rate limiting. While it clearly states what data is fetched, it leaves too many operational questions unanswered for an AI agent to use it effectively.

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 schema already fully documents both parameters. The description doesn't add any parameter-specific information beyond what's in the schema. The baseline score of 3 is appropriate when the schema does all the parameter documentation work.

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 specific action ('fetch'), resource ('home timeline from Bluesky'), and scope ('posts from all of the people you follow in reverse chronological order'). It distinguishes from siblings like get-user-posts (specific user) or get-feed-posts (curated feeds) by specifying the home timeline context.

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 for when to use this tool ('fetch your home timeline'), but doesn't explicitly state when not to use it or name alternatives. It implies usage for getting posts from followed users, but lacks explicit exclusions like 'use get-user-posts for specific user timelines'.

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