feat(mcp): natural-language measurements for tool inputs via @pascal-app/lingo
Measurement/angle parameters on the scene tools now accept a bare number OR a
natural-language string ("6 in", "180cm", "45°", "1.57rad"), canonicalized to
the unit the handler already expects (meters for length, radians/degrees for
angles) with min/max bounds and model-readable errors. Makes LLM tool calls
safer — "6 in" no longer has to be pre-converted to 0.1524, and a bad value is
rejected with a message the model can self-correct from.
A shared `measurement(kind, unit)` zod field wraps lingo's parseQuantity as a
`number | string` union+transform; numbers pass through unchanged (backward
compatible), so no handler changes were needed. Covers create_wall, cut_opening,
place_item, create_level, create_story_shell, create_roof,
create_stair_between_levels, create_room, add_door, add_window, photo_to_scene.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
a5963560b1
commit
f66dcd438b
@@ -5,14 +5,15 @@ import { z } from 'zod'
|
||||
import type { SceneOperations } from '../operations'
|
||||
import { ErrorCode, throwMcpError } from './errors'
|
||||
import { publishLiveSceneSnapshot } from './live-sync'
|
||||
import { measurement } from './measurement'
|
||||
import { NodeIdSchema, Vec2Schema } from './schemas'
|
||||
|
||||
export const createWallInput = {
|
||||
levelId: NodeIdSchema,
|
||||
start: Vec2Schema,
|
||||
end: Vec2Schema,
|
||||
thickness: z.number().positive().optional(),
|
||||
height: z.number().positive().optional(),
|
||||
thickness: measurement('length', 'm', { min: 0, description: 'Wall thickness.' }).optional(),
|
||||
height: measurement('length', 'm', { min: 0, description: 'Wall height.' }).optional(),
|
||||
}
|
||||
|
||||
export const createWallOutput = {
|
||||
|
||||
Reference in New Issue
Block a user