get_screen
Retrieve metadata and details for a specific screen by providing its UUID. Optionally include full HTML source.
Instructions
Get details and metadata for a specific screen. Set include_html=true to also return the HTML source.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| screen_id | Yes | Screen UUID returned by generate_screen or iterate_screen. | |
| include_html | No | Include full HTML in response (large). |
Implementation Reference
- src/server.ts:241-265 (handler)Handler function for the 'get_screen' tool. Calls getScreen() from storage to fetch screen metadata by ID, returns JSON with optional HTML content based on include_html flag.
async function handleGet(input: z.infer<typeof getInput>) { const screen = await getScreen(input.screen_id); if (!screen) throw new Error(`Screen not found: ${input.screen_id}`); const meta = { id: screen.id, project: screen.project, name: screen.name, createdAt: screen.createdAt, prompt: screen.prompt, designSystem: screen.designSystem, parentId: screen.parentId, tokens: screen.tokens, model: screen.model, htmlPath: screen.htmlPath, pngPath: screen.pngPath, }; const out: Array<{ type: "text"; text: string }> = [ { type: "text", text: JSON.stringify(meta, null, 2) }, ]; if (input.include_html) { const html = await readHtml(screen); out.push({ type: "text", text: "```html\n" + html + "\n```" }); } return { content: out }; } - src/server.ts:67-71 (registration)Tool registration in TOOLS array with name 'get_screen', description, and inputSchema derived from the getInput Zod schema.
name: "get_screen", description: "Get details and metadata for a specific screen. Set include_html=true to also return the HTML source.", inputSchema: zodToJson(getInput), }, ]; - src/server.ts:41-44 (schema)Zod input schema (getInput) defining validation for screen_id (required string) and include_html (optional boolean, default false).
const getInput = z.object({ screen_id: z.string().describe("Screen UUID returned by generate_screen or iterate_screen."), include_html: z.boolean().default(false).describe("Include full HTML in response (large)."), }); - src/storage.ts:78-93 (helper)Storage helper function getScreen() that reads JSON metadata files from all project directories to find a screen matching the given ID.
export async function getScreen(id: string): Promise<SavedScreen | null> { // listProjects() returns directory names that are already slugged on disk. // Slugging them again is idempotent but misleading — read directly. const projects = await listProjects(); for (const project of projects) { const dir = join(DESIGNS_DIR, project); const files = await readdir(dir).catch(() => []); for (const f of files) { if (f.endsWith(".json")) { const meta = JSON.parse(await readFile(join(dir, f), "utf8")) as SavedScreen; if (meta.id === id) return meta; } } } return null; } - src/server.ts:130-131 (registration)Switch-case dispatch routing the 'get_screen' tool name to handleGet() handler.
case "get_screen": return await handleGet(getInput.parse(args));