Skip to main content
Glama
nks-hub

rybbit-mcp

by nks-hub

User Traits

rybbit_get_user_traits
Read-onlyIdempotent

Retrieve user trait data from Rybbit Analytics: list trait keys, view distinct values for specific keys, or find users matching trait criteria to analyze user behavior and segmentation.

Instructions

Get user trait keys, values, or find users by trait. mode='keys' lists all trait keys. mode='values' (default when key is provided) returns distinct values for a trait key. mode='users' finds users matching a specific trait key+value pair (case-insensitive).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteIdYesSite ID (numeric ID or domain identifier)
modeNo'keys' to list trait keys, 'values' to get values for a key, 'users' to find users by trait. Default: 'keys' if no key provided, 'values' if key is provided.
keyNoTrait key (required for 'values' and 'users' modes)
valueNoTrait value (required for 'users' mode)
limitNoMax results to return

Implementation Reference

  • The handler logic for the rybbit_get_user_traits tool, which determines the mode ('keys', 'values', 'users') and fetches data from the appropriate API endpoint.
      async (args) => {
        try {
          let data: unknown;
          const resolvedMode = args.mode ?? (args.key ? "values" : "keys");
    
          if (resolvedMode === "users") {
            // API does exact (case-sensitive) match, so resolve the correct case first
            let resolvedValue = args.value;
            if (args.key && args.value) {
              const valuesData = await client.get<{ values: { value: string }[] }>(
                `/sites/${args.siteId}/user-traits/values`,
                { key: args.key, limit: 1000 }
              );
              const match = valuesData.values?.find(
                (v) => v.value.toLowerCase() === args.value!.toLowerCase()
              );
              if (match) resolvedValue = match.value;
            }
            const params: Record<string, string | number> = {};
            if (args.key !== undefined) params.key = args.key;
            if (resolvedValue !== undefined) params.value = resolvedValue;
            if (args.limit !== undefined) params.limit = args.limit;
            data = await client.get(`/sites/${args.siteId}/user-traits/users`, params);
          } else if (resolvedMode === "values" && args.key !== undefined) {
            const params: Record<string, string | number> = { key: args.key };
            if (args.limit !== undefined) params.limit = args.limit;
            data = await client.get(`/sites/${args.siteId}/user-traits/values`, params);
          } else {
            data = await client.get(`/sites/${args.siteId}/user-traits/keys`);
          }
          return {
            content: [{ type: "text" as const, text: truncateResponse(data) }],
          };
        } catch (err) {
          const message = err instanceof Error ? err.message : String(err);
          return {
            content: [{ type: "text" as const, text: `Error: ${message}` }],
            isError: true,
          };
        }
      }
    );
  • The registration of the rybbit_get_user_traits tool, including its metadata, description, and input schema.
    server.registerTool(
      "rybbit_get_user_traits",
      {
        title: "User Traits",
        annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true, destructiveHint: false },
        description:
          "Get user trait keys, values, or find users by trait. mode='keys' lists all trait keys. mode='values' (default when key is provided) returns distinct values for a trait key. mode='users' finds users matching a specific trait key+value pair (case-insensitive).",
        inputSchema: {
          siteId: siteIdSchema,
          mode: z
            .enum(["keys", "values", "users"])
            .optional()
            .describe("'keys' to list trait keys, 'values' to get values for a key, 'users' to find users by trait. Default: 'keys' if no key provided, 'values' if key is provided."),
          key: z
            .string()
            .optional()
            .describe(
              "Trait key (required for 'values' and 'users' modes)"
            ),
          value: z
            .string()
            .optional()
            .describe("Trait value (required for 'users' mode)"),
          limit: z.number().optional().describe("Max results to return"),
        },
      },
      async (args) => {
        try {
          let data: unknown;
          const resolvedMode = args.mode ?? (args.key ? "values" : "keys");
    
          if (resolvedMode === "users") {
            // API does exact (case-sensitive) match, so resolve the correct case first
            let resolvedValue = args.value;
            if (args.key && args.value) {
              const valuesData = await client.get<{ values: { value: string }[] }>(
                `/sites/${args.siteId}/user-traits/values`,
                { key: args.key, limit: 1000 }
              );
              const match = valuesData.values?.find(
                (v) => v.value.toLowerCase() === args.value!.toLowerCase()
              );
              if (match) resolvedValue = match.value;
            }
            const params: Record<string, string | number> = {};
            if (args.key !== undefined) params.key = args.key;
            if (resolvedValue !== undefined) params.value = resolvedValue;
            if (args.limit !== undefined) params.limit = args.limit;
            data = await client.get(`/sites/${args.siteId}/user-traits/users`, params);
          } else if (resolvedMode === "values" && args.key !== undefined) {
            const params: Record<string, string | number> = { key: args.key };
            if (args.limit !== undefined) params.limit = args.limit;
            data = await client.get(`/sites/${args.siteId}/user-traits/values`, params);
          } else {
            data = await client.get(`/sites/${args.siteId}/user-traits/keys`);
          }
          return {
            content: [{ type: "text" as const, text: truncateResponse(data) }],
          };
        } catch (err) {
          const message = err instanceof Error ? err.message : String(err);
          return {
            content: [{ type: "text" as const, text: `Error: ${message}` }],
            isError: true,
          };
        }
      }
    );
Behavior4/5

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

Annotations declare readOnly/idempotent/safety properties, so the description focuses on functional behavior. It adds valuable context not in annotations: case-insensitive matching for 'users' mode and the default mode switching logic ('keys' if no key, 'values' if key provided). It could mention pagination behavior with 'limit' or error conditions.

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?

Single, dense sentence front-loaded with the core purpose ('Get user trait keys, values, or find users by trait'). The three mode clauses follow logically, each adding specific behavioral details. Zero wasted words; every clause earns its place by conveying distinct operational semantics.

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

Completeness4/5

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

Given the 5-parameter complexity, 100% schema coverage, and comprehensive annotations, the description provides sufficient context for invocation. It explains return types for each mode (keys list, distinct values, user list). Minor gap: no mention of output structure or pagination limits, though this is partially mitigated by the 'limit' parameter description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage, the baseline is 3. The description adds the critical case-insensitivity detail for user matching (not in schema) and clarifies the conditional relationships between parameters (e.g., which modes require which fields). It effectively complements the comprehensive schema without excessive repetition.

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

Purpose5/5

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

Description clearly states the three distinct operations (get keys, get values, find users) with specific verbs and resources. It distinguishes this from siblings like rybbit_get_user or rybbit_list_users by focusing specifically on 'traits' and the three-mode query pattern.

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 effectively explains the three modes and their parameter requirements (e.g., key required for 'values' and 'users'), but lacks explicit guidance on when to use this tool versus alternatives like rybbit_get_user or rybbit_list_users. The usage guidance is implied through mode descriptions rather than explicit comparison.

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/nks-hub/rybbit-mcp'

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