Skip to main content
Glama

Get Model Color

get_model_color

Retrieve the current color of a 3D model as a hex code to enable accurate color adjustments in visualization applications.

Instructions

Get the current model color as a hex color code (e.g., "#ff0000"). Query this before relative color changes (e.g., "darken by 10%") to ensure accuracy. For absolute changes, you may use recently queried state from context if no manual interactions occurred.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • server.js:1860-1906 (registration)
    Registration of the 'get_model_color' tool with its handler implementation. The tool queries the browser state to get the current model color as a hex code, with proper error handling and session management.
      'get_model_color',
      {
        title: 'Get Model Color',
        description: 'Get the current model color as a hex color code (e.g., "#ff0000"). ' +
          'Query this before relative color changes (e.g., "darken by 10%") to ensure accuracy. ' +
          'For absolute changes, you may use recently queried state from context if no manual interactions occurred.',
        inputSchema: {}
      },
      async () => {
        const sessionId = getCurrentSessionId();
        if (!sessionId) {
          return {
            content: [
              {
                type: 'text',
                text: 'Error: No active session found.'
              }
            ],
            isError: true
          };
        }
    
        try {
          const { state, metadata } = await getState(sessionId);
          const color = state.model?.color || '#808080';
          
          return {
            content: [
              {
                type: 'text',
                text: formatStateResponse(color, 'Model color', sessionId, metadata)
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error retrieving model color: ${error.message}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • The handler function for 'get_model_color' that executes the tool logic: gets the current session ID, queries the browser state for the model color, formats the response with metadata, and handles errors appropriately.
    async () => {
      const sessionId = getCurrentSessionId();
      if (!sessionId) {
        return {
          content: [
            {
              type: 'text',
              text: 'Error: No active session found.'
            }
          ],
          isError: true
        };
      }
    
      try {
        const { state, metadata } = await getState(sessionId);
        const color = state.model?.color || '#808080';
        
        return {
          content: [
            {
              type: 'text',
              text: formatStateResponse(color, 'Model color', sessionId, metadata)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error retrieving model color: ${error.message}`
            }
          ],
          isError: true
        };
      }
    }
  • Helper function that queries state from the browser with fallback to cached state. Used by get_model_color to retrieve the current model color. Returns state with metadata including source (fresh/cached) and timestamp.
    async function getState(sessionId) {
      let state;
      let source;
      let wasCached = false;
      
      // Always query browser for current state
      try {
        state = await queryStateFromBrowser(sessionId);
        source = 'fresh';
      } catch (error) {
        // If query fails, fall back to cache if available (browser may be disconnected)
        const cached = sessionStateCache.get(sessionId);
        if (cached) {
          console.warn(`Browser query failed for session ${sessionId}, returning cached state: ${error.message}`);
          state = cached.state;
          source = 'cache';
          wasCached = true;
        } else {
          // No cache available, throw error
          throw new Error(`Unable to retrieve state: ${error.message}. Browser may be disconnected.`);
        }
      }
      
      // Return state with metadata
      return {
        state,
        metadata: {
          source,
          wasCached,
          timestamp: new Date().toISOString()
        }
      };
    }
  • Helper function used by get_model_color to format the response with metadata. It formats the state value with property name, timestamp, source info, and a staleness warning if using cached state.
    function formatStateResponse(value, propertyName, sessionId, metadata) {
      const timestamp = metadata.timestamp;
      const source = metadata.source;
      const stalenessWarning = metadata.wasCached 
        ? ' (using cached state - browser may be disconnected)' 
        : '';
      
      return `${propertyName}: ${value} (queried at ${timestamp}, source: ${source}${stalenessWarning})`;
    }
  • Helper function that retrieves the current session ID, working in both STDIO mode (using a unique ID) and HTTP mode (using AsyncLocalStorage context). Used by get_model_color to identify which browser session to query.
    function getCurrentSessionId() {
      if (isStdioMode) {
        return STDIO_SESSION_ID;
      } else {
        return sessionContext.getStore();
      }
    }
Behavior4/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 clearly indicates this is a read-only operation (implied by 'Get'), specifies the return format (hex color code), and provides context about state accuracy considerations. It doesn't mention error conditions or performance characteristics, but covers the essential behavioral aspects for a simple query tool.

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 perfectly sized at two sentences, with the first stating the core purpose and the second providing crucial usage guidance. Every word earns its place, and the information is front-loaded with the most important details first.

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 zero-parameter query tool with no annotations or output schema, the description provides complete context: it specifies what the tool does, the exact return format, when to use it, and considerations about state accuracy. It fully compensates for the lack of structured metadata.

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?

The tool has 0 parameters with 100% schema description coverage. The description appropriately doesn't discuss parameters since none exist, maintaining focus on the tool's purpose and usage. It adds value by explaining the return format and context considerations beyond what the empty schema provides.

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 specific action ('Get') and resource ('current model color'), including the exact output format ('as a hex color code, e.g., "#ff0000"'). It distinguishes from siblings like 'change_model_color' by focusing on retrieval rather than modification.

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?

The description provides explicit guidance on when to use this tool ('before relative color changes') and when alternatives may be appropriate ('For absolute changes, you may use recently queried state from context'). It directly addresses sibling tools like 'change_model_color' by specifying the pre-change verification use case.

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/aidenlab/hello3dmcp-server'

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