get_posts
Retrieve posts from your Instagram account or Facebook page to manage content and analyze engagement.
Instructions
Get posts from your Instagram account or Facebook page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| platform | Yes | Platform to get posts from | |
| limit | No | Number of posts to retrieve (default: 25) |
Implementation Reference
- src/index.ts:40-43 (schema)Zod schema for validating input parameters of the get_posts tool: platform (instagram or facebook) and optional limit.const GetPostsSchema = z.object({ platform: z.enum(['instagram', 'facebook']), limit: z.number().optional() });
- src/index.ts:203-214 (registration)Tool registration in the list of available tools returned by ListToolsRequestHandler, including name, description, and input schema.{ name: 'get_posts', description: 'Get posts from your Instagram account or Facebook page', inputSchema: { type: 'object', properties: { platform: { type: 'string', enum: ['instagram', 'facebook'], description: 'Platform to get posts from' }, limit: { type: 'number', description: 'Number of posts to retrieve (default: 25)' } }, required: ['platform'] } },
- src/index.ts:463-471 (handler)Handler logic in the CallToolRequestHandler switch statement: parses input with schema, then calls platform-specific API functions getInstagramPosts or getFacebookPosts.case 'get_posts': { const params = GetPostsSchema.parse(args); if (params.platform === 'instagram') { result = await api.getInstagramPosts(params.limit); } else { result = await api.getFacebookPosts(params.limit); } break; }
- src/facebook-api.ts:341-351 (helper)Core implementation for fetching Instagram posts using Graph API /media endpoint.export async function getInstagramPosts(limit: number = 25): Promise<{ data: Post[] }> { const igAccountId = config.igAccountId || (await getMyInstagramProfile()).id; return makeApiCall({ endpoint: `/${igAccountId}/media`, params: { fields: 'id,caption,media_type,media_url,thumbnail_url,permalink,timestamp,like_count,comments_count', limit } }); }
- src/facebook-api.ts:353-361 (helper)Core implementation for fetching Facebook page posts using Graph API /feed endpoint.export async function getFacebookPosts(limit: number = 25): Promise<{ data: Post[] }> { return makeApiCall({ endpoint: `/${config.fbPageId}/feed`, params: { fields: 'id,message,story,created_time,permalink_url,full_picture,attachments{media_type,url,title,description}', limit } }); }