Skip to main content

Get Tokens by Mode

Get all tokens from a specific mode in a tokenset. This flexible tool can find modes by name or use the default mode, making it easy to access tokens from any mode without needing to know mode IDs.

Description

This helper tool provides flexible access to tokens from any mode in a tokenset. You can specify a mode by name (e.g., “Light”, “Dark”, “Mobile”) or let it automatically use the default mode. Perfect for getting tokens from specific themes or contexts.

Parameters

ParameterTypeRequiredDescription
tokenset_idstringYesThe ID of the tokenset
mode_namestringNoOptional mode name to search for (e.g., ‘Light’, ‘Dark’). If not provided, uses the default mode

Response

Returns all tokens from the specified mode with:
  • mode: Mode information (id, name, is_default)
  • tokens: Array of tokens with simplified information
  • total: Total number of tokens

Example Usage

Get tokens from a specific mode

get_tokens_by_mode(
  tokenset_id: "164809aa-cbd2-4c5f-ac1a-af6902c29f6e",
  mode_name: "Light"
)

get_tokens_by_mode(
  tokenset_id: "164809aa-cbd2-4c5f-ac1a-af6902c29f6e",
  mode_name: "Dark"
)

Get tokens from default mode

get_tokens_by_mode(tokenset_id: "164809aa-cbd2-4c5f-ac1a-af6902c29f6e")

Example Response

{
  "mode": {
    "id": "2edd637b-5088-4c9b-abbc-e431e5816e94",
    "name": "Light",
    "is_default": true
  },
  "tokens": [
    {
      "id": "6422fc25-bfd0-4c97-8e23-bea8e7b6a77a",
      "name": "primary-oxygrox-tete",
      "type": "color",
      "value": "#ce3bf7",
      "description": null,
      "alias_to": null
    },
    {
      "id": "44432f60-d9ae-4a50-b3ca-9727bc705e7d",
      "name": "colors.primary.50",
      "type": "color",
      "value": "#eff6ff",
      "description": "Lightest primary color",
      "alias_to": null
    }
  ],
  "total": 2
}

Error Response

If the mode is not found, the tool returns available modes:
{
  "error": "Mode 'Mobile' not found in this tokenset",
  "available_modes": [
    {
      "id": "2edd637b-5088-4c9b-abbc-e431e5816e94",
      "name": "Light",
      "is_default": true
    },
    {
      "id": "7ed86b46-40d1-4b48-9fc5-3aaac71c7353",
      "name": "Dark",
      "is_default": false
    }
  ]
}

Use Cases

  • Theme-specific tokens: Get tokens from Light, Dark, or any theme
  • Context-specific tokens: Get tokens from Mobile, Desktop, or other contexts
  • Default mode access: Get tokens from the default mode without specifying name
  • Mode exploration: Discover available modes and their tokens
  • Token comparison: Compare tokens between different modes

Mode Selection Logic

The tool uses this priority for mode selection:
  1. Exact name match: If mode_name provided, finds exact match (case insensitive)
  2. Default mode: If no mode_name provided, uses the mode with is_default: true
  3. First mode: If no default mode, uses the first available mode
  • list_resources - Get tokenset IDs and available modes
  • search_tokens - Search for specific tokens across modes
  • export_mode - Export tokens from a specific mode
  • create_token - Create new tokens in specific modes

Workflow Example

# 1. Get workspace and tokenset info
list_resources()

# 2. Get tokens from Light mode
get_tokens_by_mode(
  tokenset_id: "164809aa-cbd2-4c5f-ac1a-af6902c29f6e",
  mode_name: "Light"
)

# 3. Get tokens from Dark mode
get_tokens_by_mode(
  tokenset_id: "164809aa-cbd2-4c5f-ac1a-af6902c29f6e",
  mode_name: "Dark"
)

# 4. Use token IDs for operations
update_token(
  tokenset_id: "164809aa-cbd2-4c5f-ac1a-af6902c29f6e",
  mode_id: "2edd637b-5088-4c9b-abbc-e431e5816e94",
  token_id: "6422fc25-bfd0-4c97-8e23-bea8e7b6a77a",
  value: "#0066CC"
)

Best Practices

  1. Use descriptive mode names: Be specific with mode names for clarity
  2. Check available modes: Use error response to see available modes
  3. Use default mode: Omit mode_name to get default mode tokens
  4. Copy exact IDs: Use the exact token and mode IDs from results

Error Prevention

This tool helps prevent common errors:
  • ❌ Using invalid mode IDs
  • ❌ Guessing mode names
  • ❌ Using wrong mode for tokens
  • ✅ Finding modes by name
  • ✅ Getting tokens from the correct mode
  • ✅ Discovering available modes when errors occur

Common Mode Names

  • Light: Light theme mode
  • Dark: Dark theme mode
  • Mobile: Mobile-specific tokens
  • Desktop: Desktop-specific tokens
  • Brand: Brand-specific tokens
  • Default: Default mode (usually Light)