Skip to main content
Glama

render_hwp_html

Convert a single page of an HWP/HWPX file to HTML. Useful for AI processing when SVG output is not suitable.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
pageNo
output_pathNo

Implementation Reference

  • The main handler function `renderHwpHtml` that executes the tool logic: opens an HWP/HWPX document, renders a specified page as HTML string, optionally saves to output_path. Uses `doc.renderPageHtml(page)` to generate HTML.
    export async function renderHwpHtml(args: RenderHtmlArgs): Promise<string> {
      let doc;
      try {
        doc = await openDocument(args.file_path);
      } catch (e) {
        return (e as Error).message;
      }
      try {
        const pages = getPageCount(doc);
        if (pages === 0) return "(렌더할 페이지가 없습니다 / no pages)";
        const page = args.page ?? 0;
        if (page < 0 || page >= pages) {
          return `페이지 범위 오류 (page out of range): ${page} (총 ${pages}페이지, 0-based)`;
        }
        const html = doc.renderPageHtml(page);
        if (!args.output_path) return html;
        writeFileSync(args.output_path, html);
        return `HTML 저장 완료 (saved): ${args.output_path}\n페이지: ${page + 1}/${pages} | 크기: ${html.length} bytes`;
      } catch (e) {
        return `HTML 렌더 오류 (HTML render error): ${(e as Error).message}`;
      } finally {
        closeDocument(doc);
      }
    }
  • TypeScript interface `RenderHtmlArgs` defining the input schema: file_path (required), page (optional, default 0), output_path (optional).
    export interface RenderHtmlArgs {
      file_path: string;
      page?: number;
      output_path?: string;
    }
  • src/server.ts:466-479 (registration)
    Tool registration in the TOOLS array with name 'render_hwp_html', description, and inputSchema (JSON Schema format with file_path, page, output_path).
    {
      name: "render_hwp_html",
      description:
        "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).",
      inputSchema: {
        type: "object",
        properties: {
          file_path: { type: "string" },
          page: { type: "number" },
          output_path: { type: "string" },
        },
        required: ["file_path"],
      },
    },
  • src/server.ts:542-543 (registration)
    Handler mapping in the HANDLERS record: `render_hwp_html: renderHwpHtml` which maps the tool name to the handler function.
    render_hwp_html: renderHwpHtml,
    render_hwp_equation_svg: renderHwpEquationSvg,
  • Imports used by the handler: writeFileSync from fs, and closeDocument/getPageCount/openDocument from '../core/document.js', and initRhwp from '../core/wasm-init.js'.
    import { writeFileSync } from "node:fs";
    import {
      closeDocument,
      getPageCount,
      openDocument,
    } from "../core/document.js";
    import { initRhwp } from "../core/wasm-init.js";
Behavior3/5

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

The description discloses page indexing and optional output path, but with no annotations, it omits whether the operation is read-only, error handling, or file existence requirements.

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

Conciseness5/5

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

Three sentences with no wasted words: purpose, usage context, and parameter list. Front-loaded and efficient.

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

Completeness4/5

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

Covers key aspects for a simple tool: purpose, when to use, parameter details. Lacks mention of errors or prerequisites, but sufficient for the tool's complexity.

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?

With 0% schema coverage, the description compensates by explaining page (0-based, default 0) and output_path (optional), but file_path has no added meaning beyond its name.

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 'Render a single page of an HWP/HWPX as HTML' with a specific verb and resource, differentiating it from siblings like render_hwp_all_pages or render_hwp_equation_svg.

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

Usage Guidelines4/5

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

It provides context by stating 'Useful for AI consumption when SVG isn't ideal', implying when to use over alternatives, but lacks explicit exclusions or alternative names.

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