Skip to main content
Glama

user_search

Search for user profiles on social media platforms like Twitter, Facebook, or Instagram. Polls until completion and returns comprehensive results including date-range filtering.

Instructions

Create a user profile search on a social media platform. Polls until the search is complete and returns the full results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesUsername or profile URL to search
platformYesPlatform to search
start_dateNoStart date (YYYY-MM-DD)
end_dateNoEnd date (YYYY-MM-DD)

Implementation Reference

  • The handler implementation for the 'user_search' tool, which creates a user search and polls for results.
    server.tool(
      "user_search",
      "Create a user profile search on a social media platform. Polls until the search is complete and returns the full results.",
      {
        query: z.string().min(1).max(500).describe("Username or profile URL to search"),
        platform: z.enum(["twitter", "facebook", "instagram"]).describe("Platform to search"),
        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)"),
      },
      async (params) => {
        try {
          const body: Record<string, unknown> = {
            query: params.query,
            platform: params.platform,
          };
          if (params.start_date) body.start_date = params.start_date;
          if (params.end_date) body.end_date = params.end_date;
    
          const createResult = await apiPost("/iq/user_search", body) as Record<string, unknown>;
          const searchId = (createResult.user_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/user_search/${searchId}`) as Record<string, unknown>;
            const status = (data.user_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_user_search to check status.` }], isError: true };
        } catch (e) {
          return { content: [{ type: "text", text: String(e) }], isError: true };
        }
      }
    );
  • The registration function in which the 'user_search' tool is registered with the McpServer.
    export function register(server: McpServer) {
      server.tool(
        "list_user_searches",
        "List all user 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/user_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(
        "user_search",
        "Create a user profile search on a social media platform. Polls until the search is complete and returns the full results.",
        {
          query: z.string().min(1).max(500).describe("Username or profile URL to search"),
          platform: z.enum(["twitter", "facebook", "instagram"]).describe("Platform to search"),
          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)"),
        },
        async (params) => {
          try {
            const body: Record<string, unknown> = {
              query: params.query,
              platform: params.platform,
            };
            if (params.start_date) body.start_date = params.start_date;
            if (params.end_date) body.end_date = params.end_date;
    
            const createResult = await apiPost("/iq/user_search", body) as Record<string, unknown>;
            const searchId = (createResult.user_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/user_search/${searchId}`) as Record<string, unknown>;
              const status = (data.user_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_user_search to check status.` }], isError: true };
          } catch (e) {
            return { content: [{ type: "text", text: String(e) }], isError: true };
          }
        }
      );
    
      server.tool(
        "get_user_search",
        "Get results for a user search by ID. Returns profile info, metrics, and content analysis.",
        {
          id: z.number().int().positive().describe("User search ID"),
        },
        async (params) => {
          try {
            const data = await apiGet(`/iq/user_search/${params.id}`);
            return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
          } catch (e) {
            return { content: [{ type: "text", text: String(e) }], isError: true };
          }
        }
      );
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the polling behavior ('Polls until the search is complete') and that it returns full results, which is valuable. However, it lacks details on permissions, rate limits, error handling, 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 concise with two sentences that efficiently convey the core functionality and behavior. It's front-loaded with the main purpose, though it could be slightly more structured by explicitly separating purpose from behavioral details.

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 tool with 4 parameters, 100% schema coverage, no annotations, and no output schema, the description is minimally adequate. It covers the action and polling behavior but lacks details on output format, error cases, or integration with sibling tools, leaving gaps for an AI agent.

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 fully documents all parameters. The description adds no parameter-specific information beyond what's in the schema, such as how 'query' interacts with 'platform' or date ranges. Baseline 3 is appropriate when the schema handles parameter documentation.

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 ('Create a user profile search') and resource ('on a social media platform'), with specific details about polling behavior and result return. However, it doesn't distinguish this tool from sibling tools like 'get_user_search' or 'list_user_searches', which appear related to user searches.

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?

The description provides no guidance on when to use this tool versus alternatives. It mentions polling until completion but doesn't specify prerequisites, constraints, or when to choose this over siblings like 'get_user_search' or 'keyword_search'.

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