Skip to main content
Glama

get_constants

Look up LSL constants by category or exact name. Browse available categories or search for specific values.

Instructions

Return LSL constants, optionally filtered by category or name.

Call with no arguments to see available categories and total count. Use category to browse a group (e.g. "permissions", "prim_params"). Use name for a direct lookup (e.g. "NULL_KEY", "PERMISSION_TAKE_CONTROLS").

Args: category: Optional category filter. See response for valid categories. name: Optional exact constant name. Takes precedence over category.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNo
nameNo

Implementation Reference

  • Core handler implementing lsl_constants() logic: queries SQLite DB for LSL constants, filtered by name (exact/case-insensitive with substring fallback) or category, or returns all constants grouped by category.
    def lsl_constants(category: str | None = None, name: str | None = None) -> dict:
        """
        Return LSL constants, optionally filtered by category or looked up by name.
    
        Args:
            category: Optional category filter. Call lsl_constants() with no args
                      to see the list of valid categories in the response.
            name:     Optional exact constant name to look up, e.g. "NULL_KEY" or
                      "PERMISSION_TAKE_CONTROLS". Takes precedence over category.
    
        Returns:
            If name provided:
                Single constant record: {name, type, value, category, description, deprecated}
                On miss: {"error": str, "did_you_mean": list[str]}
            If category provided:
                {"category": str, "count": int, "constants": list of records}
            If neither:
                {"categories": list[str], "total": int,
                 "constants": list of all records}
        """
        con = _connect()
    
        # ── Single constant lookup ────────────────────────────────────────────────
        if name:
            row = con.execute(
                "SELECT * FROM constants WHERE lower(name) = lower(?)", (name,)
            ).fetchone()
    
            if not row:
                # Substring fallback
                suggestions = con.execute(
                    """
                    SELECT name FROM constants
                    WHERE lower(name) LIKE lower(?)
                    ORDER BY name
                    LIMIT 8
                    """,
                    (f"%{name}%",),
                ).fetchall()
                return {
                    "error": f"No LSL constant found matching '{name}'.",
                    "did_you_mean": [s["name"] for s in suggestions],
                }
    
            return {
                "name":        row["name"],
                "type":        row["type"],
                "value":       row["value"],
                "category":    row["category"],
                "description": row["description"],
                "deprecated":  bool(row["deprecated"]),
            }
    
        # ── Category filter ───────────────────────────────────────────────────────
        if category:
            if category not in CONSTANT_CATEGORIES:
                return {
                    "error": f"Unknown category '{category}'.",
                    "valid_categories": CONSTANT_CATEGORIES,
                }
    
            rows = con.execute(
                """
                SELECT name, type, value, category, description, deprecated
                FROM constants
                WHERE category = ?
                ORDER BY name
                """,
                (category,),
            ).fetchall()
    
            return {
                "category":  category,
                "count":     len(rows),
                "constants": [
                    {
                        "name":        r["name"],
                        "type":        r["type"],
                        "value":       r["value"],
                        "description": r["description"],
                        "deprecated":  bool(r["deprecated"]),
                    }
                    for r in rows
                ],
            }
    
        # ── All constants ─────────────────────────────────────────────────────────
        rows = con.execute(
            """
            SELECT name, type, value, category, description, deprecated
            FROM constants
            ORDER BY category, name
            """,
        ).fetchall()
    
        # Summarise by category for the response header
        category_counts: dict[str, int] = {}
        for r in rows:
            cat = r["category"] or "uncategorised"
            category_counts[cat] = category_counts.get(cat, 0) + 1
    
        return {
            "total":      len(rows),
            "categories": category_counts,
            "constants": [
                {
                    "name":        r["name"],
                    "type":        r["type"],
                    "value":       r["value"],
                    "category":    r["category"],
                    "description": r["description"],
                    "deprecated":  bool(r["deprecated"]),
                }
                for r in rows
            ],
        }
  • MCP tool decorator for 'get_constants' — the public-facing handler that delegates to lsl_constants().
    @mcp.tool()
    def get_constants(
        category: str | None = None,
        name: str | None = None,
    ) -> dict:
        """
        Return LSL constants, optionally filtered by category or name.
    
        Call with no arguments to see available categories and total count.
        Use category to browse a group (e.g. "permissions", "prim_params").
        Use name for a direct lookup (e.g. "NULL_KEY", "PERMISSION_TAKE_CONTROLS").
    
        Args:
            category: Optional category filter. See response for valid categories.
            name:     Optional exact constant name. Takes precedence over category.
        """
        log.info("get_constants(category=%r, name=%r)", category, name)
        return lsl_constants(category, name)
  • server.py:178-182 (registration)
    Registration of get_constants as an MCP tool via @mcp.tool() decorator.
    @mcp.tool()
    def get_constants(
        category: str | None = None,
        name: str | None = None,
    ) -> dict:
  • Type annotations and docstring for get_constants: accepts optional category (str | None) and name (str | None), returns dict.
    @mcp.tool()
    def get_constants(
        category: str | None = None,
        name: str | None = None,
    ) -> dict:
  • CONSTANT_CATEGORIES list — defines valid categories used for validation in lsl_constants.
    # Canonical category list — used for validation and discovery
    CONSTANT_CATEGORIES = [
        "agent_info",
        "attach_points",
        "camera",
        "channels",
        "chat",
        "click_action",
        "controls",
        "dataserver",
        "http",
        "inventory",
        "link",
        "list",
        "math",
        "object",
        "parcel",
        "permissions",
        "prim_params",
        "region",
        "sensor",
        "sound",
        "status",
        "string",
        "texture",
        "vehicle",
    ]
Behavior4/5

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

Given no annotations, the description adequately explains behavior: default returns categories/count, category filters, name overrides category. It lacks mention of error handling for invalid inputs but covers core mechanics.

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?

The description is concise with a clear summary followed by usage scenarios and structured Arg section. Every sentence adds value without redundancy.

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

Completeness5/5

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

For a simple two-parameter tool with no output schema, the description covers all scenarios: no args, category, name, and precedence. It provides complete guidance for an AI agent to use correctly.

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

Parameters5/5

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

With 0% schema coverage, the description fully compensates by explaining both parameters: category as a filter, name as exact lookup with precedence over category. This adds essential meaning beyond the schema's bare types.

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?

The description clearly states the tool returns LSL constants with optional filtering by category or name. It distinctly separates from siblings like 'check_code' and 'get_pitfalls' by specifying the exact resource and operation.

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

Usage Guidelines5/5

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

Explicit instructions are given: call with no arguments to see categories, use category for browsing, use name for direct lookup with precedence. This clarifies when to use each parameter and contrasts with 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/Treeeeeeeeeeeeee/second-life-mcp-server'

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