delete_hwp_table_row
Delete a specific row from a table in an HWPX file. Specify the file, table index, and row index to remove unwanted data.
Instructions
Delete the Mth row (0-based) from the Nth table (0-based) in an .hwpx. Args: file_path, table_index, row_index, output_path (optional).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| table_index | Yes | ||
| row_index | Yes | ||
| output_path | No |
Implementation Reference
- src/tools/edit.ts:121-134 (handler)The tool handler function that validates input, calls the core mutation function (deleteHwpxTableRow), and returns a human-readable result string.
export async function deleteHwpTableRow(args: DeleteRowArgs): Promise<string> { const err = preflight(args.file_path); if (err) return err; const out = args.output_path && args.output_path.length > 0 ? args.output_path : defaultOutput(args.file_path, "row-deleted"); try { const r = await deleteHwpxTableRow(args.file_path, out, args.table_index, args.row_index); if (r.deleted === 0) return `행 인덱스 범위 초과 (row index out of range): ${args.row_index} (남은 ${r.remaining})`; return `표 ${args.table_index} 행 ${args.row_index} 삭제 (deleted)\n남은 행: ${r.remaining}\n저장 (saved): ${out}`; } catch (e) { return `표 행 삭제 오류 (delete row error): ${(e as Error).message}`; } } - src/tools/edit.ts:114-119 (schema)TypeScript interface defining the input arguments for deleteHwpTableRow.
export interface DeleteRowArgs { file_path: string; table_index: number; row_index: number; output_path?: string; } - src/core/hwpx-mutate.ts:268-291 (helper)Core mutation helper that loads an .hwpx file, finds the Nth table and Mth row via regex, removes the row XML, and writes the modified file.
export async function deleteHwpxTableRow( inputPath: string, outputPath: string, tableIndex: number, rowIndex: number ): Promise<{ deleted: number; remaining: number }> { const { zip, sectionName, xml } = await loadSection(inputPath); const tblRegex = /<hp:tbl [^>]*>[\s\S]*?<\/hp:tbl>/g; const tables = [...xml.matchAll(tblRegex)]; if (tableIndex < 0 || tableIndex >= tables.length) { return { deleted: 0, remaining: tables.length }; } const tableXml = tables[tableIndex][0]; const trRegex = /<hp:tr(?:\s[^>]*)?>[\s\S]*?<\/hp:tr>/g; const trs = [...tableXml.matchAll(trRegex)]; if (rowIndex < 0 || rowIndex >= trs.length) { return { deleted: 0, remaining: trs.length }; } const target = trs[rowIndex][0]; const newTableXml = tableXml.replace(target, ""); const newXml = xml.replace(tableXml, newTableXml); await writeSection(zip, sectionName, newXml, outputPath); return { deleted: 1, remaining: trs.length - 1 }; } - src/server.ts:260-274 (registration)MCP tool registration with name, description, and JSON Schema input validation.
{ name: "delete_hwp_table_row", description: "Delete the Mth row (0-based) from the Nth table (0-based) in an .hwpx. Args: file_path, table_index, row_index, output_path (optional).", inputSchema: { type: "object", properties: { file_path: { type: "string" }, table_index: { type: "number" }, row_index: { type: "number" }, output_path: { type: "string" }, }, required: ["file_path", "table_index", "row_index"], }, }, - src/server.ts:529-529 (registration)The tool handler mapping in the server's tool handler object, linking the snake_case name to the imported function.
delete_hwp_table_row: deleteHwpTableRow,