delete_hwp_table_column
Removes a specified column from a table in an .hwpx file. Provide the file path, table index, and column index to delete the column.
Instructions
Delete the Mth column (0-based) from the Nth table in an .hwpx (removes one hp:tc from every row). Args: file_path, table_index, col_index, output_path (optional).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| table_index | Yes | ||
| col_index | Yes | ||
| output_path | No |
Implementation Reference
- src/tools/edit.ts:238-250 (handler)Main handler for the delete_hwp_table_column tool. Validates input, computes output path, calls deleteHwpxTableColumn from core, and returns a result string.
export async function deleteHwpTableColumn(args: DeleteColumnArgs): 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, "col-deleted"); try { const r = await deleteHwpxTableColumn(args.file_path, out, args.table_index, args.col_index); return `표 ${args.table_index} 열 ${args.col_index} 삭제 (deleted) — ${r.rowsAffected}행 영향\n저장 (saved): ${out}`; } catch (e) { return `표 열 삭제 오류 (delete column error): ${(e as Error).message}`; } } - src/tools/edit.ts:231-236 (schema)TypeScript interface for the DeleteColumnArgs, defining the input schema (file_path, table_index, col_index, output_path optional).
export interface DeleteColumnArgs { file_path: string; table_index: number; col_index: number; output_path?: string; } - src/server.ts:337-350 (registration)Registration of the delete_hwp_table_column tool in the MCP server tools array, with its description and JSON input schema.
{ name: "delete_hwp_table_column", description: "Delete the Mth column (0-based) from the Nth table in an .hwpx (removes one <hp:tc> from every row). Args: file_path, table_index, col_index, output_path (optional).", inputSchema: { type: "object", properties: { file_path: { type: "string" }, table_index: { type: "number" }, col_index: { type: "number" }, output_path: { type: "string" }, }, required: ["file_path", "table_index", "col_index"], }, - src/core/hwpx-mutate.ts:430-459 (helper)Core utility function that performs the actual column deletion in the .hwpx XML. Loads the zip, finds the table by index, removes the <hp:tc> element at the given col_index from each row, and writes the result.
export async function deleteHwpxTableColumn( inputPath: string, outputPath: string, tableIndex: number, colIndex: number ): Promise<{ removed: number; rowsAffected: 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) { throw new Error(`Table index out of range: ${tableIndex}`); } const tableXml = tables[tableIndex][0]; const trRegex = /<hp:tr(?:\s[^>]*)?>[\s\S]*?<\/hp:tr>/g; const trs = [...tableXml.matchAll(trRegex)]; let newTableXml = tableXml; let affected = 0; for (let r = 0; r < trs.length; r++) { const trXml = trs[r][0]; const tcMatches = [...trXml.matchAll(/<hp:tc(?:\s[^>]*)?>[\s\S]*?<\/hp:tc>/g)]; if (colIndex < 0 || colIndex >= tcMatches.length) continue; const target = tcMatches[colIndex][0]; const newTrXml = trXml.replace(target, ""); newTableXml = newTableXml.replace(trXml, newTrXml); affected++; } const newXml = xml.replace(tableXml, newTableXml); await writeSection(zip, sectionName, newXml, outputPath); return { removed: 1, rowsAffected: affected }; } - src/server.ts:531-532 (registration)Tool name-to-function mapping in the server's handler dispatch object.
delete_hwp_table_column: deleteHwpTableColumn, insert_hwp_image: insertHwpImage,