part.inspect
Analyze UI component details by ID to retrieve styles, HTML structure, bounding box measurements, interaction data, and embedding status for design inspection.
Instructions
特定のUIコンポーネントパーツの詳細情報を取得します。スタイル、HTML、バウンディングボックス、インタラクション情報、Embedding有無等を返します。 / Inspect a specific UI component part by ID. Returns styles, HTML, bounding box, interaction info, embedding status, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| part_id | Yes | パーツID(UUID) / Part ID (UUID) | |
| include_html | No | サニタイズ済みHTMLスニペットを含める / Include sanitized HTML snippet | |
| include_embedding | No | Embedding有無情報を含める / Include embedding availability info |
Implementation Reference
- Handler implementation for part.inspect tool.
export async function partInspectHandler(input: unknown): Promise<PartInspectOutput> { if (isDevelopment()) { logger.info("[MCP Tool] part.inspect called", { partId: (input as Record<string, unknown>)?.part_id ? truncateId(String((input as Record<string, unknown>).part_id)) : undefined, }); } // 入力バリデーション / Input validation let validated: PartInspectInput; try { validated = partInspectInputSchema.parse(input); } catch (error) { if (error instanceof ZodError) { const errorMessage = error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", "); logger.warn("[MCP Tool] part.inspect validation error", { errors: error.errors, }); return { success: false, error: { code: PART_INSPECT_ERROR_CODES.VALIDATION_ERROR, message: `Validation error: ${errorMessage}`, }, }; } throw error; } // PrismaClient取得 / Get PrismaClient if (!prismaClientFactory) { return { success: false, error: { code: PART_INSPECT_ERROR_CODES.SERVICE_UNAVAILABLE, message: "Part inspect service is not available", }, }; } const prisma = prismaClientFactory(); try { // パーツ詳細を取得 / Get part details const rows = await prisma.$queryRawUnsafe<PartDetailRow[]>( `SELECT cp.id, cp.part_type, cp.part_subtype, ${validated.include_html ? "cp.html_snippet," : "NULL AS html_snippet,"} cp.computed_styles, cp.bounding_box, cp.css_classes, cp.attributes, cp.interaction_info, cp.visual_signature, cp.sample_index, cp.pii_risk_level, cp.tags, cp.metadata, cp.source_url, cp.usage_scope, sp.section_type, wp.url AS web_page_url, cp.created_at::text AS created_at, ${ validated.include_embedding ? "(cpe.text_embedding IS NOT NULL) AS has_text_embedding, (cpe.visual_embedding IS NOT NULL) AS has_visual_embedding" : "FALSE AS has_text_embedding, FALSE AS has_visual_embedding" } FROM component_parts cp INNER JOIN section_patterns sp ON sp.id = cp.section_pattern_id INNER JOIN web_pages wp ON wp.id = cp.web_page_id ${ validated.include_embedding ? "LEFT JOIN component_part_embeddings cpe ON cpe.component_part_id = cp.id" : "" } WHERE cp.id = $1 LIMIT 1`, validated.part_id ); if (rows.length === 0) { return { success: false, error: { code: PART_INSPECT_ERROR_CODES.NOT_FOUND, message: `Part not found: ${truncateId(validated.part_id)}`, }, }; } const row = rows[0]; if (!row) { return { success: false, error: { code: PART_INSPECT_ERROR_CODES.NOT_FOUND, message: `Part not found: ${truncateId(validated.part_id)}`, }, }; } // レスポンス構築 / Build response const detail: PartInspectDetail = { id: row.id, partType: row.part_type, partSubtype: row.part_subtype, htmlSnippet: row.html_snippet ? sanitizeHtml(row.html_snippet) : row.html_snippet, computedStyles: row.computed_styles ?? {}, boundingBox: row.bounding_box ?? {}, cssClasses: row.css_classes ?? [], attributes: row.attributes ?? {}, interactionInfo: row.interaction_info ?? {}, visualSignature: row.visual_signature, sampleIndex: row.sample_index, piiRiskLevel: row.pii_risk_level, tags: row.tags ?? [], metadata: row.metadata ?? {}, sourceUrl: row.source_url, usageScope: row.usage_scope, sectionType: row.section_type, webPageUrl: row.web_page_url, createdAt: row.created_at, }; if (validated.include_embedding) { detail.hasTextEmbedding = row.has_text_embedding; detail.hasVisualEmbedding = row.has_visual_embedding; } if (isDevelopment()) { logger.info("[MCP Tool] part.inspect completed", { partId: truncateId(validated.part_id), partType: detail.partType, }); } return { success: true, data: detail, }; } catch (error) { logger.warn("[MCP Tool] part.inspect error", { error: sanitizePartInspectError(error), partId: truncateId(validated.part_id), }); return { success: false, error: { code: PART_INSPECT_ERROR_CODES.INTERNAL_ERROR, message: sanitizePartInspectError(error), }, }; } } - apps/mcp-server/src/tools/part/inspect.tool.ts:358-392 (registration)MCP tool definition for part.inspect.
export const partInspectToolDefinition = { name: "part.inspect", description: "特定のUIコンポーネントパーツの詳細情報を取得します。" + "スタイル、HTML、バウンディングボックス、インタラクション情報、Embedding有無等を返します。" + " / Inspect a specific UI component part by ID. " + "Returns styles, HTML, bounding box, interaction info, embedding status, etc.", annotations: { title: "Part Inspect", readOnlyHint: true, idempotentHint: true, openWorldHint: false, }, inputSchema: { type: "object" as const, properties: { part_id: { type: "string", format: "uuid", description: "パーツID(UUID) / Part ID (UUID)", }, include_html: { type: "boolean", default: false, description: "サニタイズ済みHTMLスニペットを含める / Include sanitized HTML snippet", }, include_embedding: { type: "boolean", default: false, description: "Embedding有無情報を含める / Include embedding availability info", }, }, required: ["part_id"], }, };