hwp-mcp

v0.3.0
hwp-mcp Checked 5 hours ago Published 4 months ago

MCP server for reading and writing HWP/HWPX (Korean Hangul) documents — built on rhwp.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

read_hwp

Read full HWP/HWPX document content as text + tables (markdown) + image listing. Args: file_path (absolute path).

ParameterTypeDescription
file_path *string

read_hwp_text

Extract plain body text from an HWP/HWPX file (no tables, no images). Args: file_path.

ParameterTypeDescription
file_path *string

read_hwp_tables

Extract every table from an HWP/HWPX file as GitHub-flavored markdown. Args: file_path.

ParameterTypeDescription
file_path *string

convert_hwp_markdown

Convert an HWP/HWPX document to Markdown preserving document flow order: tables as GFM in place, images extracted with relative links, equations inline ($…$), footnotes at end. If output_path is omitted, the Markdown string is returned inline with image placeholders. Args: file_path, output_path (optional .md path), image_dir (optional, default <md name>_images/ next to output).

ParameterTypeDescription
file_path *string
image_dirstring
output_pathstring

list_hwp_images

List embedded images (mime, byte length, locator) in an HWP/HWPX file. Args: file_path.

ParameterTypeDescription
file_path *string

extract_hwp_images

Save every embedded image to disk. Args: file_path, output_dir (optional; defaults to <file>_images/).

ParameterTypeDescription
file_path *string
output_dirstring

replace_hwp_text

Find and replace text in an HWPX file. v0.2: only .hwpx is supported as input/output. Args: file_path, old_text, new_text, output_path (optional).

ParameterTypeDescription
file_path *string
new_text *string
old_text *string
output_pathstring

fill_hwp_template

Fill multiple placeholders in an HWPX template. `replacements` is a JSON object string, e.g. {"{{name}}":"Kim","{{company}}":"Acme"}. v0.2: .hwpx only. Args: file_path, replacements, output_path (optional).

ParameterTypeDescription
file_path *string
replacements *string
output_pathstring

get_hwp_info

Get document metadata (version, page count, section count, fonts used, totals for tables/images/footnotes/equations/headers/footers). Args: file_path.

ParameterTypeDescription
file_path *string

get_hwp_page_def

Get per-section page definition (paper size, margins, columns) and section properties. Useful for understanding document layout. Args: file_path.

ParameterTypeDescription
file_path *string

get_hwp_field_value

Get a Hancom field's current value by name. Args: file_path, name.

ParameterTypeDescription
file_path *string
name *string

list_hwp_fields

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.

ParameterTypeDescription
file_path *string

list_hwp_bindata

List ZIP entries under BinData/ inside an .hwpx (image and binary attachments). Useful before replace_hwp_image. Args: file_path.

ParameterTypeDescription
file_path *string

replace_hwp_image

Replace an embedded image inside an .hwpx by overwriting its BinData/ ZIP entry with new file contents. `target` accepts either basename ('image1.bmp') or full entry path ('BinData/image1.bmp'). Args: file_path, target, source_path, output_path (optional).

ParameterTypeDescription
file_path *string
source_path *string
target *string
output_pathstring

render_hwp_page

Render a single page of an HWP/HWPX document as SVG. If output_path is omitted, the raw SVG string is returned inline (useful for direct LLM consumption). Args: file_path, page (0-based, default 0), output_path (optional).

ParameterTypeDescription
file_path *string
output_pathstring
pagenumber

render_hwp_all_pages

Render every page of an HWP/HWPX as SVG files in a directory. Args: file_path, output_dir (default <file>_pages/), max_pages (optional limit).

ParameterTypeDescription
file_path *string
max_pagesnumber
output_dirstring

append_hwp_paragraph

Append a new paragraph to the end of an .hwpx document body. Clones the last paragraph's structure (paraPr/charPr/style refs) and replaces text. Args: file_path, text, output_path (optional).

ParameterTypeDescription
file_path *string
text *string
output_pathstring

delete_hwp_paragraph

Delete the Nth paragraph (0-based) from an .hwpx body. Args: file_path, index, output_path (optional).

ParameterTypeDescription
file_path *string
index *number
output_pathstring

append_hwp_table_row

Append a new row to the Nth table (0-based) in an .hwpx. `cells` is a JSON string array of cell texts (length should match table column count). Args: file_path, table_index, cells, output_path (optional).

ParameterTypeDescription
cells *string
file_path *string
table_index *number
output_pathstring

delete_hwp_table_row

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).

ParameterTypeDescription
file_path *string
row_index *number
table_index *number
output_pathstring

set_hwp_paragraph_text

Replace the entire text of the Nth paragraph (0-based) in an .hwpx body with new text. The paragraph attributes (paraPr/style refs) are preserved; runs are collapsed into a single <hp:run> with the new text. Args: file_path, index, text, output_path (optional).

ParameterTypeDescription
file_path *string
index *number
text *string
output_pathstring

set_hwp_cell_text

Replace a single cell's text in a table inside an .hwpx. Args: file_path, table_index, row, col (all 0-based), text, output_path (optional).

ParameterTypeDescription
col *number
file_path *string
row *number
table_index *number
text *string
output_pathstring

set_hwp_field_value

Set a Hancom field's value by name in an .hwpx (writes the new text between the matching `<hp:fldBegin name=...>` and `<hp:fldEnd>`). Use list_hwp_fields first to discover names. Args: file_path, name, value, output_path (optional).

ParameterTypeDescription
file_path *string
name *string
value *string
output_pathstring

append_hwp_table_column

Append a new column to the Nth table in an .hwpx. `cells` is a JSON string array of cell texts (one per row, top-to-bottom). Args: file_path, table_index, cells, output_path (optional).

ParameterTypeDescription
cells *string
file_path *string
table_index *number
output_pathstring

delete_hwp_table_column

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).

ParameterTypeDescription
col_index *number
file_path *string
table_index *number
output_pathstring

insert_hwp_image

Insert a new image into an .hwpx — adds the file to BinData/, registers it in content.hpf, and appends a paragraph with an inline <hp:pic>. Args: file_path, source_path, ext (png/jpg/bmp/gif; auto from source_path if omitted), output_path (optional).

ParameterTypeDescription
file_path *string
source_path *string
extstring
output_pathstring

apply_hwp_paragraph_style

Apply paragraph formatting (alignment·indent·line_spacing) to the Nth paragraph in an .hwpx. Adds a new paraPr to header.xml and retargets the paragraph's paraPrIDRef. align: LEFT|CENTER|RIGHT|JUSTIFY|DISTRIBUTE. Args: file_path, paragraph_index, align/indent/line_spacing (any subset), output_path (optional).

ParameterTypeDescription
file_path *string
paragraph_index *number
alignstring
indentnumber
line_spacingnumber
output_pathstring

insert_hwp_table

Insert a real OWPML table at the end of an .hwpx body (proper <hp:tbl>/<hp:tr>/<hp:tc>). headers and rows are both JSON string arrays — `headers` is a single-row array of strings, `rows` is an array of row arrays. Args: file_path, headers, rows, output_path (optional).

ParameterTypeDescription
file_path *string
headers *string
rows *string
output_pathstring

merge_hwp_cells_vertical

Merge vertical cells across rows in a single column by setting rowSpan on the first cell and removing absorbed cells in following rows. Args: file_path, table_index, col, row_start, row_count (>=2), output_path (optional).

ParameterTypeDescription
col *number
file_path *string
row_count *number
row_start *number
table_index *number
output_pathstring

merge_hwp_cells_horizontal

Merge horizontal cells in a row of a table by setting colSpan on the first cell and removing the absorbed cells. Args: file_path, table_index, row, col_start, col_count (>=2), output_path (optional).

ParameterTypeDescription
col_count *number
col_start *number
file_path *string
row *number
table_index *number
output_pathstring

apply_hwp_text_style

Apply formatting (color/bold/italic/underline/font_size) to the first run that contains target_text. Adds a new charPr to header.xml and retargets the matching <hp:run>. Color is a 6-digit hex (e.g. 'FF0000'). Args: file_path, target_text, color/bold/italic/underline/font_size (any subset), output_path (optional).

ParameterTypeDescription
file_path *string
target_text *string
boldboolean
colorstring
font_sizenumber
italicboolean
output_pathstring
underlineboolean

delete_hwp_image

Delete a BinData/ ZIP entry inside an .hwpx (effectively removes the embedded image bytes). Args: file_path, target (basename or full entry), output_path (optional).

ParameterTypeDescription
file_path *string
target *string
output_pathstring

render_hwp_html

Render a single page of an HWP/HWPX as HTML. Useful for AI consumption when SVG isn't ideal. Args: file_path, page (0-based, default 0), output_path (optional).

ParameterTypeDescription
file_path *string
output_pathstring
pagenumber

render_hwp_equation_svg

Render an OWPML equation script (e.g. 'TIMES LEFT ( {a} over {b} RIGHT )') to SVG. Args: script, font_size (HWP units, default 1300), color (default 0).

ParameterTypeDescription
script *string
colornumber
font_sizenumber

create_hwpx_document

Create a new .hwpx file from a JSON content list of {type:'text',text} items. Tables (type:'table',headers,rows) are rendered as flat text rows in v0.2. Args: output_path (must end with .hwpx), content (JSON string of items).

ParameterTypeDescription
content *string
output_path *string