Skip to main content
Glama

delete_hwp_paragraph

Delete a specific paragraph from an HWPX document by providing its zero-based index. Optionally save to a new file path.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
indexYes
output_pathNo

Implementation Reference

  • src/server.ts:231-244 (registration)
    Registration of the 'delete_hwp_paragraph' tool in the MCP server tool list with its name, description, and input schema.
    {
      name: "delete_hwp_paragraph",
      description:
        "Delete the Nth paragraph (0-based) from an .hwpx body. Args: file_path, index, output_path (optional).",
      inputSchema: {
        type: "object",
        properties: {
          file_path: { type: "string" },
          index: { type: "number" },
          output_path: { type: "string" },
        },
        required: ["file_path", "index"],
      },
    },
  • src/server.ts:527-527 (registration)
    Binding the tool name 'delete_hwp_paragraph' to the handler function deleteHwpParagraph in the tool dispatch map.
    delete_hwp_paragraph: deleteHwpParagraph,
  • src/server.ts:20-20 (registration)
    Import of deleteHwpParagraph handler from src/tools/edit.ts.
    deleteHwpParagraph,
  • The DeleteParaArgs interface defining the input schema (file_path, index, output_path) for delete_hwp_paragraph.
    export interface DeleteParaArgs {
      file_path: string;
      index: number;
      output_path?: string;
    }
  • The deleteHwpParagraph handler function that validates input, preflights the file, and delegates to deleteHwpxParagraph in core.
    export async function deleteHwpParagraph(args: DeleteParaArgs): 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, "deleted");
      try {
        const r = await deleteHwpxParagraph(args.file_path, out, args.index);
        if (r.deleted === 0) return `인덱스 범위 초과 (index out of range): ${args.index} (총 ${r.total})`;
        return `문단 ${args.index} 삭제 (deleted): 1건 / 전체 ${r.total}\n저장 (saved): ${out}`;
      } catch (e) {
        return `문단 삭제 오류 (delete error): ${(e as Error).message}`;
      }
    }
  • The deleteHwpxParagraph core helper that loads the .hwpx zip, finds the paragraph by index using PARA_REGEX, removes its XML, and writes the modified file.
    export async function deleteHwpxParagraph(
      inputPath: string,
      outputPath: string,
      index: number
    ): Promise<{ deleted: number; total: number }> {
      const { zip, sectionName, xml } = await loadSection(inputPath);
      const matches = [...xml.matchAll(PARA_REGEX)];
      if (index < 0 || index >= matches.length) {
        return { deleted: 0, total: matches.length };
      }
      const target = matches[index][0];
      const newXml = xml.replace(target, "");
      await writeSection(zip, sectionName, newXml, outputPath);
      return { deleted: 1, total: matches.length };
    }
  • The PARA_REGEX constant used to match <hp:p> paragraphs in the XML.
    const PARA_REGEX = /<hp:p [^>]*>[\s\S]*?<\/hp:p>/g;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description bears full burden. It does not clarify side effects like in-place modification when output_path is omitted, or whether file must be closed. Minimal behavioral detail.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence that front-loads the action. Concise, though could separate parameter explanations for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-parameter destructive tool with no output schema or annotations, the description leaves out return behavior, error handling, and file mutation details. Incomplete for safe invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so description must compensate. It adds that index is 0-based and output_path is optional, but still lacks full meaning (e.g., file_path is path to .hwpx file, index is paragraph number). Partial improvement over bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: delete the Nth paragraph (0-based) from an .hwpx body. It distinguishes from sibling delete tools (image, table column, table row) by targeting paragraphs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like other paragraph manipulation or delete tools. No prerequisites or exclusions mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/treesoop/hwp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server