How utyagi24/klarpdf works
KlarPDF is an offline Windows PDF viewer and editor, with a separate MCP bridge exposing document operations to agents. In the desktop workflow, a user opens a PDF, navigates and edits its virtual document, then saves edits through the materialization engine. The MCP server offers a parallel agent-facing route for queries, tables, annotations, redaction, and transforms. The sampled source establishes several model and viewer relationships; some UI wiring and MCP subsystems are only documented or indexed, so uncertain links are omitted.
Main entry points: server.py MCP server · queries.py Document queries · main_window.py Document window · pdf_view.py PDF view
Components 23
Desktop app
- App lifecycle
app.py - Document window
main_window.py - Page organizer
organize/thumbnail_panel.py - Outline panel
organize/outline_panel.py - Annotations panel
organize/annotations_panel.py
Viewing and markup
- PDF view
viewer/pdf_view.py - Search
viewer/search.py - Markup tools
viewer/annotations.py
PDF document model
- Virtual document
klarpdf/model/virtual_document.py - Page edits
klarpdf/model/page_edits.py - Content marks
klarpdf/model/content_marks.py - Foreign annotations
klarpdf/model/foreign_annots.py - Save engine
klarpdf/model/edit_engine.py - Page text
klarpdf/model/page_text.py
MCP bridge
- MCP server
klarpdf/mcp_bridge/server.py - Document queries
klarpdf/mcp_bridge/queries.py - Table extraction
klarpdf/mcp_bridge/tables.py - Heading tools
klarpdf/mcp_bridge/headings.py - Redaction tools
klarpdf/mcp_bridge/redaction.py - Document transforms
klarpdf/mcp_bridge/transforms.py - MCP replies
klarpdf/mcp_bridge/replies.py
Other components
- PDF user
- MCP client
Connections 29
- PDF user → App lifecycle: opens PDF
app.py - App lifecycle → Document window: creates window
app.py - Document window → Virtual document: opens document
main_window.py - PDF user → PDF view: reads and navigates
- PDF view → Virtual document: displays pages
viewer/pdf_view.py - Document window → Page organizer: organizes pages
main_window.py - Document window → Outline panel: shows outline
main_window.py - Document window → Annotations panel: lists annotations
organize/annotations_panel.py - PDF view → Search: routes search
viewer/pdf_view.py - Search → Page text: searches text
viewer/search.py - PDF view → Markup tools: routes markup
viewer/pdf_view.py - Markup tools → Page edits: edits annotations
viewer/annotations.py - Page edits → Content marks: uses mark descriptors
klarpdf/model/page_edits.py - Page edits → Foreign annotations: handles foreign marks
klarpdf/model/page_edits.py - Virtual document → Save engine: materializes on save
klarpdf/model/virtual_document.py - MCP client → MCP server: requests tools
- MCP server → Document queries: dispatches queries
klarpdf/mcp_bridge/server.py - MCP server → Table extraction: dispatches table tools
klarpdf/mcp_bridge/server.py - MCP server → Heading tools: dispatches heading tools
klarpdf/mcp_bridge/server.py - MCP server → Redaction tools: dispatches redaction
klarpdf/mcp_bridge/server.py - MCP server → Document transforms: dispatches transforms
klarpdf/mcp_bridge/server.py - Document queries → Virtual document: queries document
klarpdf/mcp_bridge/queries.py - Document queries → Page text: reads page text
klarpdf/mcp_bridge/queries.py - Document queries → MCP replies: formats results
klarpdf/mcp_bridge/queries.py - Table extraction → Document queries: uses query helpers
klarpdf/mcp_bridge/tables.py - Table extraction → MCP replies: formats results
klarpdf/mcp_bridge/tables.py - Heading tools → Document queries: uses query helpers
klarpdf/mcp_bridge/headings.py - Heading tools → Table extraction: uses table helpers
klarpdf/mcp_bridge/headings.py - Redaction tools → Page edits: applies redactions
klarpdf/mcp_bridge/redaction.py