Skip to main content
Glama

threads_get_posts

Retrieve published Threads posts with options to filter by date, limit results, and paginate through content.

Instructions

Get a list of published Threads posts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of results (default 25)
sinceNoStart date (ISO 8601 or Unix timestamp)
untilNoEnd date (ISO 8601 or Unix timestamp)
afterNoPagination cursor
beforeNoPagination cursor

Implementation Reference

  • The handler for threads_get_posts, which fetches published Threads posts using the MetaClient.
    async ({ limit, since, until, after, before }) => {
      try {
        const params: Record<string, unknown> = {
          fields: "id,media_product_type,media_type,media_url,permalink,text,timestamp,shortcode,is_quote_post,has_replies,reply_audience,topic_tag,link_attachment_url,poll_attachment,gif_attachment,alt_text",
        };
        if (limit) params.limit = limit;
        if (since) params.since = since;
        if (until) params.until = until;
        if (after) params.after = after;
        if (before) params.before = before;
        const { data, rateLimit } = await client.threads("GET", `/${client.threadsUserId}/threads`, params);
        return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
      } catch (error) {
        return { content: [{ type: "text", text: `Get posts failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
      }
    }
  • The input schema for threads_get_posts using Zod.
    {
      limit: z.number().optional().describe("Number of results (default 25)"),
      since: z.string().optional().describe("Start date (ISO 8601 or Unix timestamp)"),
      until: z.string().optional().describe("End date (ISO 8601 or Unix timestamp)"),
      after: z.string().optional().describe("Pagination cursor"),
      before: z.string().optional().describe("Pagination cursor"),
    },
  • Registration of the threads_get_posts tool within the McpServer.
    server.tool(
      "threads_get_posts",
      "Get a list of published Threads posts.",
      {
        limit: z.number().optional().describe("Number of results (default 25)"),
        since: z.string().optional().describe("Start date (ISO 8601 or Unix timestamp)"),
        until: z.string().optional().describe("End date (ISO 8601 or Unix timestamp)"),
        after: z.string().optional().describe("Pagination cursor"),
        before: z.string().optional().describe("Pagination cursor"),
      },
      async ({ limit, since, until, after, before }) => {
        try {
          const params: Record<string, unknown> = {
            fields: "id,media_product_type,media_type,media_url,permalink,text,timestamp,shortcode,is_quote_post,has_replies,reply_audience,topic_tag,link_attachment_url,poll_attachment,gif_attachment,alt_text",
          };
          if (limit) params.limit = limit;
          if (since) params.since = since;
          if (until) params.until = until;
          if (after) params.after = after;
          if (before) params.before = before;
          const { data, rateLimit } = await client.threads("GET", `/${client.threadsUserId}/threads`, params);
          return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text", text: `Get posts failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );

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/mikusnuz/meta-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server