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
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | ||
| name | No |
Implementation Reference
- tools/reference.py:157-272 (handler)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 ], } - server.py:178-195 (handler)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: - server.py:178-182 (schema)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: - tools/reference.py:128-154 (helper)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", ]