Skip to main content
Glama

VisualDoc

Visual-layout QA untuk dokumen — "Playwright, tapi untuk DOCX / Google Docs / Word." Satu MCP server yang dipakai identik oleh Claude Code dan OpenCode: render → ukur → cek → patch → diff → ulangi.

Status: Fase 0 + Fase 1 (+ penguatan) ✅ terverifikasi end-to-end lewat klien MCP stdio sungguhan, 47 pytest hijau. Loop tertutup: doc_autofix membawa dokumen contoh dari {critical:1}{critical:0} dalam 1 iterasi. Penguatan: anchor stabil w14:paraId, mode review/safe/full, regression guard (revisi yang memunculkan isu baru → rollback), dan guardrails input: validasi DOCX, deteksi halaman di luar rentang, serta error terstruktur {ok:false, error{code}} — menutup celah "laporan hijau padahal salah".

doc_render_report → 1 critical (table_overflow) + 1 warning (image_low_dpi)
doc_autofix       → baseline{critical:1} → final{critical:0}  accepted=True
                    iter1: set_table_width(el-4) → resolved [p1:table_overflow]
                    unresolved: [p1:image_low_dpi]   (butuh aset resolusi lebih tinggi)

Loop (Fase 1)

doc_get_structure ──► el-N (posisional) + anchor (w14:paraId, stabil) + version_hash
        │
doc_apply_patch(ops, expected_version_hash) ──► revisi + validasi round-trip
        │            target = el-N | anchor      (file asli tak disentuh)
doc_render_report(revisi) ──► ukur ulang
        │
doc_diff_versions ──► resolved / new(regresi) / delta
        ↺  (dibungkus jadi satu tool: doc_autofix — mode review|safe|full)
   berhenti saat tak ada yang bisa diperbaiki / max_iter / regression guard
   (revisi yang memunculkan warning baru → dibuang, versi sebelumnya dipertahankan)

Loop hidup sebagai satu tool (doc_autofix), bukan Claude Code hook — supaya portabel ke OpenCode (docs/01-compatibility.md). Agen juga bisa menyetir loop lebih halus sendiri via doc_get_structure + doc_apply_patch.

Related MCP server: docx-forge-mcp

Struktur

namanya-nanti/
├── .mcp.json · pyproject.toml · README.md
├── docs/  00-concept · 01-compatibility · 02-preview-model (DOCX vs LaTeX)
├── src/visualdoc/
│   ├── server.py          # MCP server (FastMCP, stdio) — 7 tool
│   ├── core/              # FORMAT-AGNOSTIC (bekerja atas PDF apa pun)
│   │   ├── geometry.py    #   PDF -> bbox/font/DPI/tabel
│   │   ├── rules.py       #   rule engine (+ engine_sensitivity)
│   │   ├── report.py      #   analyze_pdf()
│   │   ├── diff.py        #   diff_reports() before/after
│   │   └── raster.py      #   PDF page -> PNG (kanal visual opsional)
│   └── adapters/docx/     # FORMAT-SPECIFIC
│       ├── render.py      #   DOCX -> PDF (LibreOffice)
│       ├── meta.py        #   margin/style OOXML
│       ├── patch.py       #   get_structure + ops aman + validasi round-trip
│       ├── autofix.py     #   loop deterministik (structure-driven, render-verified)
│       └── pipeline.py    #   build_report()
├── rules/general.yaml · configs/ · scripts/
└── workspace/  original/ revisions/ renders/ reports/

Tool (7)

Tool

Fungsi

doc_selftest()

Cek kesehatan (soffice/PyMuPDF/python-docx) + daftar patch_ops.

doc_render_report(document, pages?, rules?)

Render + ukur + cek → JSON (summary.headline, pages[]). Tanpa gambar.

doc_get_structure(document, assign_anchors?, output?)

Elemen ter-alamat: el-N + anchor (w14:paraId, stabil) + version_hash + text_column_mm. assign_anchorsnormalized_output.

doc_apply_patch(document, ops, expected_version_hash?, output?)

Op aman ke salinan (target el-N | anchor) + validasi round-trip.

doc_autofix(document, rules?, max_iter?, mode?)

Loop tertutup + regression guard → revisi final + history/diff. mode: review|safe|full.

doc_diff_versions(before, after, rules?)

Diff dua versi: resolved / new / delta.

doc_get_page_image(document, page?, dpi?)

Opsional: PNG satu halaman (mahal token; pakai hemat).

Op aman (doc_apply_patch): set_spacing, set_keep_with_next, set_page_break_before, set_paragraph_style, set_font, set_table_width. Tiap op melapor applied/error independen; op salah tak menggagalkan yang benar. target bisa el-N (posisional) atau anchor (w14:paraId — bertahan lintas-edit; doc_get_structure(assign_anchors=true) menuliskannya ke normalized_output).

Mode doc_autofix: review (rencana saja) · safe (invariant: fit tabel) · full (safe + heading keep_with_next + clamp spacing). Warning membawa engine_sensitivity (invariant benar di renderer manapun; dependent hanya valid untuk layout LibreOffice ini) — lihat docs/02-preview-model.md.

Kontrak error: tiap tool mengembalikan ok: true saat sukses, atau {ok: false, error: {code, message, detail?}} saat gagal — code ∈ {not_found, invalid_docx, invalid_rules, pages_out_of_range, stale_version, bad_argument, no_ops, no_ops_applied, render_unavailable, render_failed, internal}. Input DOCX & rule-pack divalidasi (bukan-DOCX / .doc lama / korup / YAML rusak ditolak), render yang gagal/timeout terbedakan dari input salah, dan halaman di luar rentang tak pernah menghasilkan laporan "hijau" palsu (semua di luar rentang → error; sebagian → di-flag). apply_patch yang 0-perubahan tidak menulis file (no_ops/no_ops_applied).

Keandalan tabel (#4): table_overflow dikoroborasi dengan lebar OOXML (patch._table_width_mm) — jumlah kolom di pesan direkonsiliasi ke angka OOXML yang otoritatif (mis. render 7 → OOXML 8), tiap tabel render dijembatani ke element_id, dan overflow yang tak terdeteksi renderer (mis. tabel tanpa border) tetap muncul sebagai isu struktural, bukan hilang diam-diam.

Prinsip desain

Semua analisis di server, dikembalikan sebagai teks/JSON — bukan gambar ke model. Rule engine jalan murni atas angka geometri (PyMuPDF), tanpa vision → murah token, deterministik, jalan di kedua klien bahkan dengan model text-only. Alasan: docs/01-compatibility.md.

Quickstart

# Prasyarat sistem (sekali):
sudo apt-get install -y --no-install-recommends libreoffice-writer python3-venv fonts-liberation
python3 -m venv .venv && .venv/bin/pip install -e .

# Coba:
.venv/bin/python scripts/make_sample.py    # -> workspace/original/sample.docx
.venv/bin/python scripts/mcp_smoke.py       # uji 7 tool end-to-end lewat protokol MCP
.venv/bin/mcp dev src/visualdoc/server.py   # (opsional) MCP Inspector interaktif

# Test (mengunci semua perilaku agar tak regres):
.venv/bin/pip install -e ".[test]" && .venv/bin/python -m pytest

Registrasi di klien

  • Claude Code.mcp.json sudah ada di root: /mcp → approve visualdoc (perlu restart sesi; server MCP tak hot-load).

  • OpenCode — salin configs/opencode.json ke opencode.json project Anda.

Contoh perintah ke agen: "jalankan doc_autofix pada workspace/original/sample.docx, ringkas apa yang diperbaiki dan apa yang tersisa."

Batasan (jujur, by design)

  • Anchor elemen stabil (w14:paraId) sudah ada; pemetaan elemen↔halaman presisi (korelasi render↔OOXML, mis. inject-marker) masih penyempurnaan lanjut.

  • Auto-fix: table overflow (safe) + heading keep_with_next & clamp spacing (full). image_low_dpi & orphan_heading dilaporkan, belum di-auto-fix (butuh aset/keputusan).

  • Satu engine (LibreOffice) — temuan dependent (page-break/orphan) perlu engine target (Word) untuk kepercayaan penuh. Multi-engine = Fase 4.

  • Belum ada preview-ui/ (viewer manusia) dan adapter non-DOCX. Roadmap → docs/00-concept.md.

Available Tools

2 tools
doc_diff_versionsB

Render two DOCX versions and diff their layout reports: what got resolved, what regressed (new), page-count delta, and per-severity count deltas.

ParametersJSON Schema
NameRequiredDescriptionDefault
afterYes
rulesNo
beforeYes

TDQS

B3.2/5.0
Behavior2/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 does not disclose whether the tool is read-only, mutates data, requires permissions, or has rate limits. 'Render two DOCX versions' suggests a read operation, but there is no explicit statement about behavioral traits beyond the basic action.

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?

The description is a single sentence that fronts the main action and diff outputs. It is concise and avoids redundancy, but could be improved by structuring with bullet points or clearer separation of actions and outputs.

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?

Given the tool has three parameters (two required), no output schema, and no annotations, the description is incomplete. It does not specify the return format, behavior on errors, prerequisites (e.g., document existence), or what 'layout reports' are. The provided detail about diff outputs is helpful but insufficient for full understanding.

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

Parameters2/5

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

The input schema has three parameters ('before', 'after', 'rules') with 0% schema description coverage. The description does not explain any parameter, leaving the agent to infer what 'before' and 'after' refer to (version identifiers?) and what 'rules' controls. This is a significant gap for a tool with no output 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 tool renders two DOCX versions and diffs their layout reports, listing specific outputs like resolved/regressed items, page-count delta, and severity count deltas. This verb+resource combination is specific and distinguishes from the sibling tool 'doc_get_page_image'.

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 implies the tool is for comparing DOCX versions but provides no explicit guidance on when to use it versus alternatives, nor any exclusions or prerequisites. The sibling tool 'doc_get_page_image' is different, but no direct comparison or when-not-to-use is given.

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

doc_get_page_imageA

OPTIONAL visual channel: render ONE page of the DOCX to a PNG for the agent to eyeball a specific concern.

Use sparingly — images are costly in model context (see docs/01-compatibility.md); the deterministic doc_render_report (no images) is the primary signal. dpi is clamped to 36..300. On failure returns a structured {ok:false, error} instead.

ParametersJSON Schema
NameRequiredDescriptionDefault
dpiNo
pageNo
documentYes

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries the full disclosure burden. It mentions that dpi is clamped (36-300), on failure returns a structured {ok:false, error}, and that images are costly. However, it does not specify whether the tool is read-only or any side effects, though the 'render' action implies no mutation.

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 concise with three sentences. It front-loads the purpose, adds usage guidance, and finishes with behavioral details. Every sentence earns its place without redundancy.

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?

The description fails to explain the success return format (presumably a PNG image). Without an output schema, the agent does not know what to expect on success. It also omits document input constraints (e.g., valid DOCX). Given the tool's complexity and no output schema, the description is incomplete.

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?

The input schema has 0% description coverage, so the description must compensate. It adds clamping info for 'dpi' and implies 'page' refers to a single page, but does not clarify page numbering (0- or 1-indexed) or the format of 'document' (path/ID). The description adds value but leaves gaps.

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 tool renders one DOCX page to a PNG for visual inspection, using a specific verb ('render') and resource ('DOCX page'). It differentiates from sibling tool 'doc_diff_versions' by noting this is an optional visual channel, while the primary signal is 'doc_render_report'.

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

Usage Guidelines5/5

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

The description explicitly advises 'use sparingly' due to image cost, contrasts with the deterministic 'doc_render_report' as the primary signal, and directs to documentation for further guidance. This clearly tells the agent when and when not to use this tool.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 2 tool updatesv0.1.0
    • First observeddoc_diff_versions
    • First observeddoc_get_page_image

TDQS

B3.4/5.0
Disambiguation5/5

The two tools have clearly distinct purposes: one for comparing versions via diff, the other for extracting a single page image. There is no overlap.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern with the 'doc_' prefix: doc_diff_versions and doc_get_page_image.

Tool Count2/5

Only two tools are provided for a documentation visualization server. The description references a primary tool (doc_render_report) that is not included, making the surface too thin for its stated purpose.

Completeness1/5

The primary signal for the server (the deterministic report without images) is missing as a tool. There is no way to get the main report, only a diff and a page image, leaving a severe gap in coverage.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

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/Alvnvnc/visualdoc-mcp'

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