list_hwp_fields
List Hancom-style fields from a document to identify field names and types for template filling.
Instructions
List Hancom-style fields (<hp:fldBegin>/end pairs) in the document, with name and type when available. Useful before fill_hwp_template. Args: file_path.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Implementation Reference
- src/tools/info.ts:120-154 (handler)The actual handler function `listHwpFields` that opens a document, calls `doc.getFieldList()`, parses the JSON result, and returns a formatted list of all Hancom-style fields in the document.
export async function listHwpFields(args: FilePathArgs): Promise<string> { let doc; try { doc = await openDocument(args.file_path); } catch (e) { return (e as Error).message; } try { let raw: string; try { raw = doc.getFieldList(); } catch (e) { return `필드 목록 오류 (field list error): ${(e as Error).message}`; } let list: any[] = []; try { list = JSON.parse(raw); } catch { return raw; // return as-is if not JSON } if (!Array.isArray(list) || list.length === 0) { return "(필드가 없습니다 / no fields)"; } return list .map((f, i) => { const name = f?.name ?? f?.field_name ?? f?.fieldName ?? "?"; const type = f?.type ?? f?.fieldType ?? ""; const value = f?.value ?? ""; return `${i + 1}. ${name}${type ? ` [${type}]` : ""}${value ? ` = ${String(value).slice(0, 40)}` : ""}`; }) .join("\n"); } finally { closeDocument(doc); } } - src/tools/info.ts:12-14 (schema)The `FilePathArgs` interface used as input schema for list_hwp_fields (requires a `file_path` string).
export interface FilePathArgs { file_path: string; } - src/server.ts:155-163 (registration)Tool registration in the TOOLS array with name 'list_hwp_fields', description, and inputSchema (file_path string required).
name: "list_hwp_fields", description: "List Hancom-style fields (`<hp:fldBegin>`/end pairs) in the document, with name and type when available. Useful before fill_hwp_template. Args: file_path.", inputSchema: { type: "object", properties: { file_path: { type: "string" } }, required: ["file_path"], }, }, - src/server.ts:522-522 (registration)Handler mapping in the HANDLERS record that maps the string 'list_hwp_fields' to the imported `listHwpFields` function.
list_hwp_fields: listHwpFields, - src/server.ts:17-17 (registration)Import statement that brings `listHwpFields` from './tools/info.js' into the server module.
import { getHwpInfo, listHwpFields, getHwpFieldValue, getHwpPageDef } from "./tools/info.js";