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)}`); } } );

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