Get Key Light Size
get_key_light_sizeRetrieve the current key light area dimensions (width and height) to ensure accurate relative size adjustments in the 3D scene.
Instructions
Get the current key light area size (width and height in units). Query this before relative size changes to ensure accuracy. For absolute changes, you may use recently queried state from context if no manual interactions occurred.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:1262-1310 (registration)Registration of the 'get_key_light_size' tool via mcpServer.registerTool, including its input schema (empty), title 'Get Key Light Size', description, and handler function that queries state and returns the key light size (width and height).
mcpServer.registerTool( 'get_key_light_size', { title: 'Get Key Light Size', description: 'Get the current key light area size (width and height in units). ' + 'Query this before relative size 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 size = state.keyLight?.size || { width: 1, height: 1 }; const sizeText = `width ${size.width}, height ${size.height}`; return { content: [ { type: 'text', text: formatStateResponse(sizeText, 'Key light size', sessionId, metadata) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error retrieving key light size: ${error.message}` } ], isError: true }; } } ); - server.js:1262-1310 (handler)The handler function for 'get_key_light_size' - an async function that gets the current session ID, queries state using getState(sessionId), extracts state.keyLight?.size (defaulting to {width:1,height:1}), and returns a formatted response with the size information.
mcpServer.registerTool( 'get_key_light_size', { title: 'Get Key Light Size', description: 'Get the current key light area size (width and height in units). ' + 'Query this before relative size 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 size = state.keyLight?.size || { width: 1, height: 1 }; const sizeText = `width ${size.width}, height ${size.height}`; return { content: [ { type: 'text', text: formatStateResponse(sizeText, 'Key light size', sessionId, metadata) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error retrieving key light size: ${error.message}` } ], isError: true }; } } ); - server.js:1262-1310 (schema)Input schema definition for 'get_key_light_size' - an empty object (inputSchema: {}) as this tool takes no input parameters. It only reads state.
mcpServer.registerTool( 'get_key_light_size', { title: 'Get Key Light Size', description: 'Get the current key light area size (width and height in units). ' + 'Query this before relative size 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 size = state.keyLight?.size || { width: 1, height: 1 }; const sizeText = `width ${size.width}, height ${size.height}`; return { content: [ { type: 'text', text: formatStateResponse(sizeText, 'Key light size', sessionId, metadata) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error retrieving key light size: ${error.message}` } ], isError: true }; } } ); - server.js:329-338 (helper)Helper function queryFreshStateForManipulation used by relative adjustment tools (not directly by get_key_light_size but part of the same key light feature set).
// Helper function to query fresh state before relative manipulations async function queryFreshStateForManipulation(sessionId) { try { const { state } = await getState(sessionId); return state; } catch (error) { console.warn(`Failed to query fresh state before manipulation: ${error.message}`); return null; } } - server.js:319-327 (helper)Helper function formatStateResponse used to format the state response with metadata (timestamp, source, staleness warning) for the get_key_light_size tool output.
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})`; }