Skip to main content
Glama

keyword_search

Search for keywords or hashtags across multiple social media platforms including X, Reddit, YouTube, and LinkedIn. Retrieve posts within specified date ranges and quantity limits.

Instructions

Create a keyword/hashtag search across social media platforms (X, Reddit, Bluesky, YouTube, LinkedIn, Facebook, Instagram, Weibo). Polls until the search is complete and returns the full results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query (keyword or hashtag)
platformsNoPlatforms to search (default: twitter, reddit, bluesky, youtube)
start_dateNoStart date (YYYY-MM-DD)
end_dateNoEnd date (YYYY-MM-DD)
max_postNoMaximum number of posts to retrieve (default: 100)

Implementation Reference

  • Handler implementation for the "keyword_search" tool, which creates a keyword search and polls for its status until completion.
    server.tool(
      "keyword_search",
      "Create a keyword/hashtag search across social media platforms (X, Reddit, Bluesky, YouTube, LinkedIn, Facebook, Instagram, Weibo). Polls until the search is complete and returns the full results.",
      {
        query: z.string().min(1).max(500).describe("Search query (keyword or hashtag)"),
        platforms: z
          .array(z.enum(["twitter", "reddit", "bluesky", "youtube", "linkedin", "facebook", "instagram", "weibo"]))
          .optional()
          .describe("Platforms to search (default: twitter, reddit, bluesky, youtube)"),
        start_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD").optional().describe("Start date (YYYY-MM-DD)"),
        end_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD").optional().describe("End date (YYYY-MM-DD)"),
        max_post: z.number().int().positive().max(10000).optional().describe("Maximum number of posts to retrieve (default: 100)"),
      },
      async (params) => {
        try {
          const body: Record<string, unknown> = { query: params.query };
          if (params.platforms) body.platforms = params.platforms;
          if (params.start_date) body.start_date = params.start_date;
          if (params.end_date) body.end_date = params.end_date;
          if (params.max_post !== undefined) body.max_post = params.max_post;
    
          const createResult = await apiPost("/iq/keyword_search", body) as Record<string, unknown>;
          const searchId = (createResult.keyword_search as Record<string, unknown>)?.id ?? createResult.id;
          if (searchId == null) {
            return { content: [{ type: "text", text: JSON.stringify(createResult, null, 2) }] };
          }
    
          const startTime = Date.now();
          while (Date.now() - startTime < MAX_POLL_MS) {
            await sleep(POLL_INTERVAL_MS);
            const data = await apiGet(`/iq/keyword_search/${searchId}`) as Record<string, unknown>;
            const status = (data.keyword_search as Record<string, unknown>)?.status ?? data.status;
            if (status === "finished" || status === "failed") {
              return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
            }
          }
    
          return { content: [{ type: "text", text: `Search ${searchId} timed out after 10 minutes. Use get_keyword_search to check status.` }], isError: true };
        } catch (e) {
          return { content: [{ type: "text", text: String(e) }], isError: true };
        }
      }
    );
  • Registration function that registers "keyword_search" (and other related tools) to the MCP server.
    export function register(server: McpServer) {
      server.tool(
        "list_keyword_searches",
        "List all keyword searches. Returns a paginated list filtered by status.",
        {
          show: z
            .enum(["all", "started", "finished", "pending", "failed"])
            .optional()
            .describe("Filter by status (default: all)"),
          page: z.number().int().positive().optional().describe("Page number (100 results per page)"),
        },
        async (params) => {
          try {
            const queryParts: string[] = [];
            if (params.show) queryParts.push(`show=${params.show}`);
            if (params.page !== undefined) queryParts.push(`page=${params.page}`);
            const query = queryParts.length ? `?${queryParts.join("&")}` : "";
            const data = await apiGet(`/iq/keyword_search${query}`);
            return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
          } catch (e) {
            return { content: [{ type: "text", text: String(e) }], isError: true };
          }
        }
      );
    
      server.tool(
        "keyword_search",
        "Create a keyword/hashtag search across social media platforms (X, Reddit, Bluesky, YouTube, LinkedIn, Facebook, Instagram, Weibo). Polls until the search is complete and returns the full results.",
        {
          query: z.string().min(1).max(500).describe("Search query (keyword or hashtag)"),
          platforms: z
            .array(z.enum(["twitter", "reddit", "bluesky", "youtube", "linkedin", "facebook", "instagram", "weibo"]))
            .optional()
            .describe("Platforms to search (default: twitter, reddit, bluesky, youtube)"),
          start_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD").optional().describe("Start date (YYYY-MM-DD)"),
          end_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD").optional().describe("End date (YYYY-MM-DD)"),
          max_post: z.number().int().positive().max(10000).optional().describe("Maximum number of posts to retrieve (default: 100)"),
        },
        async (params) => {
          try {
            const body: Record<string, unknown> = { query: params.query };
            if (params.platforms) body.platforms = params.platforms;
            if (params.start_date) body.start_date = params.start_date;
            if (params.end_date) body.end_date = params.end_date;
            if (params.max_post !== undefined) body.max_post = params.max_post;
    
            const createResult = await apiPost("/iq/keyword_search", body) as Record<string, unknown>;
            const searchId = (createResult.keyword_search as Record<string, unknown>)?.id ?? createResult.id;
            if (searchId == null) {
              return { content: [{ type: "text", text: JSON.stringify(createResult, null, 2) }] };
            }
    
            const startTime = Date.now();
            while (Date.now() - startTime < MAX_POLL_MS) {
              await sleep(POLL_INTERVAL_MS);
              const data = await apiGet(`/iq/keyword_search/${searchId}`) as Record<string, unknown>;
              const status = (data.keyword_search as Record<string, unknown>)?.status ?? data.status;
              if (status === "finished" || status === "failed") {
                return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
              }
            }
    
            return { content: [{ type: "text", text: `Search ${searchId} timed out after 10 minutes. Use get_keyword_search to check status.` }], isError: true };
          } catch (e) {
            return { content: [{ type: "text", text: String(e) }], isError: true };
          }
        }
      );
    
      server.tool(
        "get_keyword_search",
        "Get results for a keyword search by ID. Returns search status, analytics summary, and posts.",
        {
          id: z.number().int().positive().describe("Keyword search ID"),
        },
        async (params) => {
          try {
            const data = await apiGet(`/iq/keyword_search/${params.id}`);
            return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
          } catch (e) {
            return { content: [{ type: "text", text: String(e) }], isError: true };
          }
        }
      );
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'Polls until the search is complete' which is valuable behavioral information, but doesn't cover important aspects like rate limits, authentication requirements, error conditions, or what 'complete' means operationally.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences that convey the core functionality and behavioral characteristic. It's appropriately sized without unnecessary elaboration, though it could potentially be more front-loaded with the most critical information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 5-parameter tool with no annotations and no output schema, the description provides adequate but incomplete context. It covers the basic operation and polling behavior but lacks details about return format, error handling, and operational constraints that would be important for an AI agent to use this tool effectively.

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 description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, maintaining the baseline score of 3 for high schema coverage.

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's purpose: 'Create a keyword/hashtag search across social media platforms' with specific platforms listed. It distinguishes from some siblings like 'get_user_search' but doesn't explicitly differentiate from 'get_keyword_search' or 'list_keyword_searches'.

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

Usage Guidelines3/5

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

The description implies usage for keyword/hashtag searches across social media with polling until completion. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'get_keyword_search' or 'list_keyword_searches' among the sibling tools.

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/rolliinc/rolli-mcp'

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