list_posts
Filter by platform, status, and date to retrieve social media posts. Access all post states including drafts, scheduled, published, and failed.
Instructions
List social media posts with optional filters for platform, status, and date range
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number (0-based) | |
| limit | No | Posts per page (max 50) | |
| platforms | No | Filter by platforms | |
| statuses | No | Filter by post statuses | |
| from | No | Start date filter (ISO 8601, e.g. 2025-01-01T00:00:00.000Z) | |
| to | No | End date filter (ISO 8601, e.g. 2025-01-31T23:59:59.999Z) |
Implementation Reference
- src/tools/posts.ts:37-80 (registration)Registers the 'list_posts' tool using server.tool() with the name 'list_posts', description, Zod schema for input params (page, limit, platforms, statuses, from, to), and handler function.
server.tool( 'list_posts', 'List social media posts with optional filters for platform, status, and date range', { page: z.number().int().min(0).default(0).describe('Page number (0-based)'), limit: z .number() .int() .min(1) .max(50) .default(20) .describe('Posts per page (max 50)'), platforms: z .array(z.enum(PLATFORMS)) .optional() .describe('Filter by platforms'), statuses: z .array(z.enum(STATUSES)) .optional() .describe('Filter by post statuses'), from: z .string() .optional() .describe('Start date filter (ISO 8601, e.g. 2025-01-01T00:00:00.000Z)'), to: z .string() .optional() .describe('End date filter (ISO 8601, e.g. 2025-01-31T23:59:59.999Z)'), }, async (input) => { const data = await client.get<PaginatedPosts>('/social-posts', { page: String(input.page), limit: String(input.limit), platforms: input.platforms?.join(','), statuses: input.statuses?.join(','), from: input.from, to: input.to, }); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - src/tools/posts.ts:66-79 (handler)Handler function for list_posts: makes an HTTP GET request to '/social-posts' via the PostFastClient, passing query parameters (page, limit, platforms, statuses, from, to), and returns the paginated posts as JSON string content.
async (input) => { const data = await client.get<PaginatedPosts>('/social-posts', { page: String(input.page), limit: String(input.limit), platforms: input.platforms?.join(','), statuses: input.statuses?.join(','), from: input.from, to: input.to, }); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, - src/tools/posts.ts:40-65 (schema)Zod input schema for list_posts defining page (int, min 0, default 0), limit (int, 1-50, default 20), platforms (optional array of enum PLATFORMS), statuses (optional array of enum STATUSES), from (optional ISO 8601 date string), to (optional ISO 8601 date string).
{ page: z.number().int().min(0).default(0).describe('Page number (0-based)'), limit: z .number() .int() .min(1) .max(50) .default(20) .describe('Posts per page (max 50)'), platforms: z .array(z.enum(PLATFORMS)) .optional() .describe('Filter by platforms'), statuses: z .array(z.enum(STATUSES)) .optional() .describe('Filter by post statuses'), from: z .string() .optional() .describe('Start date filter (ISO 8601, e.g. 2025-01-01T00:00:00.000Z)'), to: z .string() .optional() .describe('End date filter (ISO 8601, e.g. 2025-01-31T23:59:59.999Z)'), }, - src/index.ts:6-6 (registration)Import of registerPostTools from the posts module where list_posts is registered.
import { registerPostTools } from './tools/posts.js'; - src/types.ts:49-53 (helper)PaginatedPosts type used as the return type for the list_posts handler's API response.
export interface PaginatedPosts { data: SocialPost[]; totalCount: number; pageInfo: { page: number; hasNextPage: boolean; perPage: number }; }