Skip to main content
Glama

render_hwp_all_pages

Render each page of HWP/HWPX documents to SVG files, storing them in a specified directory.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
output_dirNo
max_pagesNo

Implementation Reference

  • Main handler for render_hwp_all_pages: opens an HWP document, determines output directory (default: <file>_pages/), iterates over pages up to optional max_pages, renders each page as SVG, writes to disk, and returns a summary.
    export async function renderHwpAllPages(args: RenderAllArgs): 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 baseName = basename(args.file_path, extname(args.file_path));
        const outDir = args.output_dir
          ? resolve(args.output_dir)
          : resolve(dirname(args.file_path), `${baseName}_pages`);
        mkdirSync(outDir, { recursive: true });
        const limit = Math.min(args.max_pages ?? pages, pages);
        const saved: string[] = [];
        for (let i = 0; i < limit; i++) {
          const svg = renderPageSvg(doc, i);
          const fname = `page_${String(i + 1).padStart(3, "0")}.svg`;
          writeFileSync(join(outDir, fname), svg);
          saved.push(fname);
        }
        return [
          `${saved.length}/${pages} 페이지 SVG 저장 (rendered ${saved.length}/${pages} pages):`,
          `저장 위치 (output): ${outDir}`,
          "",
          ...saved.slice(0, 10).map((s) => `  - ${s}`),
          saved.length > 10 ? `  ... and ${saved.length - 10} more` : "",
        ].filter(Boolean).join("\n");
      } catch (e) {
        return `렌더 오류 (render error): ${(e as Error).message}`;
      } finally {
        closeDocument(doc);
      }
    }
  • Type definition for the input arguments of renderHwpAllPages: file_path (required), output_dir (optional), max_pages (optional limit).
    export interface RenderAllArgs {
      file_path: string;
      output_dir?: string;
      max_pages?: number;
    }
  • src/server.ts:203-215 (registration)
    Tool registration entry in the TOOLS array defining the tool name, description, and input JSON schema (file_path required, output_dir and max_pages optional).
    {
      name: "render_hwp_all_pages",
      description:
        "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).",
      inputSchema: {
        type: "object",
        properties: {
          file_path: { type: "string" },
          output_dir: { type: "string" },
          max_pages: { type: "number" },
        },
        required: ["file_path"],
      },
  • src/server.ts:519-519 (registration)
    Handler mapping in the HANDLERS object linking the tool name 'render_hwp_all_pages' to the renderHwpAllPages function.
    render_hwp_all_pages: renderHwpAllPages,
  • Helper function that delegates to the underlying @rhwp/core library's renderPageSvg method to render a single page as SVG.
    export function renderPageSvg(doc: HwpDocument, pageNum: number): string {
      return doc.renderPageSvg(pageNum);
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that files are created in a directory with default naming and an optional limit, but does not mention potential side effects like overwriting, error handling, or performance implications.

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?

The description is two sentences with no unnecessary words. The first sentence states the main purpose, and the second lists the arguments concisely. Ideal structure.

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

Completeness3/5

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

No output schema exists, so the description should hint at the return value or outcome. It does not mention if the tool returns a list of paths or just succeeds. Given the file creation nature, agents may need more info on expected output.

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

Parameters4/5

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

With 0% schema description coverage, the description adds value by explaining the purpose of each parameter, including the default for 'output_dir' and the optional nature of 'max_pages'. However, it could provide more details like file path validity or type hints.

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 verb 'Render every page' and specifies the resource 'HWP/HWPX', output format 'SVG files in a directory', and distinguishes from sibling 'render_hwp_page' which renders a single page.

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

Usage Guidelines3/5

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

The description mentions optional parameters with defaults but does not explicitly state when to use this tool versus alternatives like 'render_hwp_page'. Usage context is implied rather than explicit.

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