Skip to main content
Glama

threads_search_posts

Search public Threads posts by keyword or topic tag. Filter results by media type, author username, and date range. Paginate to access more results.

Instructions

Search for public Threads posts by keyword or topic tag. Results can be filtered by media type and author.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesSearch keyword or query
search_typeNoSearch by keyword or topic tag (default: keyword)
media_typeNoFilter results by media type
author_usernameNoFilter results by author username
sinceNoStart date (Unix timestamp)
untilNoEnd date (Unix timestamp)
limitNoNumber of results
afterNoPagination cursor

Implementation Reference

  • Handler function for the threads_search_posts tool. It calls the Meta Graph API endpoint `/{threadsUserId}/threads_search` with query parameters (q, search_type, media_type, author_username, since, until, limit, after) and returns JSON results.
    // ─── threads_search_posts ────────────────────────────────────
    server.tool(
      "threads_search_posts",
      "Search for public Threads posts by keyword or topic tag. Results can be filtered by media type and author.",
      {
        q: z.string().describe("Search keyword or query"),
        search_type: z.enum(["keyword", "tag"]).optional().describe("Search by keyword or topic tag (default: keyword)"),
        media_type: z.enum(["TEXT", "IMAGE", "VIDEO", "CAROUSEL"]).optional().describe("Filter results by media type"),
        author_username: z.string().optional().describe("Filter results by author username"),
        since: z.string().optional().describe("Start date (Unix timestamp)"),
        until: z.string().optional().describe("End date (Unix timestamp)"),
        limit: z.number().optional().describe("Number of results"),
        after: z.string().optional().describe("Pagination cursor"),
      },
      async ({ q, search_type, media_type, author_username, since, until, limit, after }) => {
        try {
          const params: Record<string, unknown> = {
            q,
            fields: "id,text,username,permalink,timestamp,media_type,media_url,topic_tag",
          };
          if (search_type) params.search_type = search_type;
          if (media_type) params.media_type = media_type;
          if (author_username) params.author_username = author_username;
          if (since) params.since = since;
          if (until) params.until = until;
          if (limit) params.limit = limit;
          if (after) params.after = after;
          const { data, rateLimit } = await client.threads("GET", `/${client.threadsUserId}/threads_search`, params);
          return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text", text: `Search posts failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );
  • Zod schema defining the input parameters for threads_search_posts. Requires 'q' (keyword/query), with optional: search_type, media_type, author_username, since, until, limit, after.
    {
      q: z.string().describe("Search keyword or query"),
      search_type: z.enum(["keyword", "tag"]).optional().describe("Search by keyword or topic tag (default: keyword)"),
      media_type: z.enum(["TEXT", "IMAGE", "VIDEO", "CAROUSEL"]).optional().describe("Filter results by media type"),
      author_username: z.string().optional().describe("Filter results by author username"),
      since: z.string().optional().describe("Start date (Unix timestamp)"),
      until: z.string().optional().describe("End date (Unix timestamp)"),
      limit: z.number().optional().describe("Number of results"),
      after: z.string().optional().describe("Pagination cursor"),
    },
  • src/index.ts:50-88 (registration)
    Registration of the threads_search_posts tool via registerThreadsMediaTools in the main server entry point.
    registerThreadsMediaTools(server, client);
    registerThreadsReplyTools(server, client);
    registerThreadsProfileTools(server, client);
    registerThreadsInsightTools(server, client);
    
    // Register resources
    registerInstagramResources(server, client);
    registerThreadsResources(server, client);
    
    // Register prompts
    registerPrompts(server);
    
    async function main() {
      const transport = new StdioServerTransport();
      await server.connect(transport);
    }
    
    main().catch((err) => {
      console.error("Fatal error:", err);
      process.exit(1);
    });
    
    // ── Smithery Sandbox ──
    
    export function createSandboxServer() {
      const sandbox = new McpServer({
        name: "meta-mcp",
        version: "2.0.0",
      });
    
      const mockConfig: MetaConfig = {
        appId: "",
        appSecret: "",
        instagramAccessToken: "",
        instagramUserId: "",
        threadsAccessToken: "",
        threadsUserId: "",
      };
      const mockClient = new MetaClient(mockConfig);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses 'public' posts but omits behavioral traits like rate limits, authentication requirements, pagination behavior, or error handling. With no annotations, the description should provide more than a minimal overview.

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?

Two sentences with no wasted words. Front-loaded with the primary action and scope.

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?

Despite moderate complexity (8 parameters, no output schema), the description omits key filters (date range, pagination) and provides no information about return values or result format. Incomplete for effective tool usage.

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 coverage is 100%, so baseline is 3. The description adds minimal meaning by restating parameters (keyword/tag, filters) already described in the schema. Does not significantly enhance understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches for public Threads posts by keyword or topic tag, and mentions filtering by media type and author. It distinguishes from siblings by being the only search-focused Threads tool, though it doesn't explicitly contrast with similar tools on other platforms.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool vs alternatives like threads_get_posts or ig_search_hashtag. The description implies usage for searching public posts but lacks explicit context or exclusions.

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

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