Skip to main content
Glama

get_keyword_search

Retrieve keyword search results by ID to access status, analytics summaries, and relevant posts from multiple social media platforms.

Instructions

Get results for a keyword search by ID. Returns search status, analytics summary, and posts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesKeyword search ID

Implementation Reference

  • The get_keyword_search tool handler is registered and implemented within the register function of src/tools/keyword-search.ts. It takes a numeric ID as input and fetches the search results from the API.
    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 };
        }
      }
    );
  • The get_keyword_search tool is registered within the export function register(server: McpServer) in src/tools/keyword-search.ts.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the return data but doesn't cover critical aspects like whether this is a read-only operation, error handling, rate limits, or authentication needs, which are essential for a tool that retrieves search results.

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 a single, efficient sentence that front-loads the purpose and return values. It avoids unnecessary details, though it could be slightly more structured by explicitly separating the action from the output.

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?

Given no annotations and no output schema, the description is incomplete for a tool that returns multiple data types (status, analytics, posts). It lacks details on response structure, error cases, or behavioral traits, leaving significant gaps for the agent to handle.

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 input schema already documents the 'id' parameter as a positive integer. The description adds no additional meaning beyond this, such as explaining where to obtain the ID or its format, but meets the baseline 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 action ('Get results') and resource ('keyword search by ID'), specifying what data is returned (search status, analytics summary, and posts). However, it doesn't differentiate from sibling tools like 'get_keyword_search_posts' or 'keyword_search', which likely serve related functions.

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 is provided on when to use this tool versus alternatives. With siblings like 'get_keyword_search_posts' and 'keyword_search', the description lacks context on prerequisites, such as needing an existing search ID, or exclusions, leaving the agent to infer usage.

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