Skip to main content
Glama

Get Camera Distance

get_camera_distance

Measure the current camera distance from the origin in 3D scenes. Use this tool to query the dolly position before making relative adjustments to maintain spatial accuracy.

Instructions

Get the current camera distance from origin (dolly position). Query this before relative distance changes 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:1710-1757 (registration)
    Registration of the 'get_camera_distance' tool with the MCP server, including title, description, input schema, and handler function
    mcpServer.registerTool(
      'get_camera_distance',
      {
        title: 'Get Camera Distance',
        description: 'Get the current camera distance from origin (dolly position). ' +
          'Query this before relative distance changes 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 distance = state.camera?.distance ?? 0;
          
          return {
            content: [
              {
                type: 'text',
                text: formatStateResponse(distance.toString(), 'Camera distance', sessionId, metadata)
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error retrieving camera distance: ${error.message}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • Handler function for get_camera_distance tool - retrieves current camera distance from browser state via WebSocket communication and returns formatted response with metadata
    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 distance = state.camera?.distance ?? 0;
        
        return {
          content: [
            {
              type: 'text',
              text: formatStateResponse(distance.toString(), 'Camera distance', sessionId, metadata)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error retrieving camera distance: ${error.message}`
            }
          ],
          isError: true
        };
      }
    }
  • Helper function getState() - queries state from browser via WebSocket with timeout handling, returns state with metadata (source, timestamp, cache status)
    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 formatStateResponse() - formats state query responses with property name, session ID, and metadata including staleness warnings
    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 getCurrentSessionId() - retrieves the current session ID from either STDIO mode or HTTP mode context
    function getCurrentSessionId() {
      if (isStdioMode) {
        return STDIO_SESSION_ID;
      } else {
        return sessionContext.getStore();
      }
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that this is a query operation (implied by 'Get') and mentions accuracy considerations for relative changes, but lacks details on permissions, rate limits, or error behavior. It adds some value but doesn't fully compensate for the lack of annotations.

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 two sentences, front-loaded with the core purpose, and every sentence adds value: the first states what it does, and the second provides usage guidance. There's no wasted text.

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 tool's simplicity (0 parameters, no output schema, no annotations), the description is fairly complete. It explains the purpose and usage, but could be more detailed about behavioral aspects like return format or error handling to achieve a 5.

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 doesn't need to add parameter information, so it meets the baseline of 4. No parameters are present to require additional semantics.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get the current camera distance from origin (dolly position).' It specifies the verb ('Get') and resource ('camera distance'), but doesn't explicitly distinguish it from sibling tools like 'get_camera_fov' or 'dolly_camera', which would require a 5.

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

Usage Guidelines4/5

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

The description provides clear usage context: 'Query this before relative distance changes to ensure accuracy. For absolute changes, you may use recently queried state from context if no manual interactions occurred.' This explains when to use it (before relative changes) and hints at alternatives (using cached state), but doesn't explicitly name sibling tools or state when not to use it.

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