A Model Context Protocol (MCP) server for creating and managing structured documents. DocGen2 enables LLMs to create books, reports, resumes, and other documents with a flexible block-based architecture.
- Block-Based Documents: Documents are composed of discrete content blocks (headings, markdown, images, tables, page breaks)
- Chapter Support: Create books and large documents with chapter organization
- Document Search: Search within documents to find and update specific content
- Multiple Export Formats: Export to PDF, DOCX, and HTML (Pandoc integration planned)
- Terminal Mode: CLI interface for testing and direct document manipulation
- File-Based Storage: All documents stored as YAML and markdown files for easy version control
- Go 1.23 or higher
- Pandoc (for export functionality - coming soon)
# Clone the repository
cd mcp_servers/docgen2
# Build the server
./run.sh build
# Or directly with go
go build -o bin/docgen2 ./cmdRun as an MCP server for integration with Claude or other LLM clients:
./bin/docgen2
# or
./run.sh runDocGen2 includes a comprehensive terminal mode for testing and direct manipulation:
# Create a new document
./bin/docgen2 -create "My Document Title"
./bin/docgen2 -create "My Book" -chapters # With chapter support
# List all documents
./bin/docgen2 -list
# Show document structure
./bin/docgen2 -overview <document-id>
# Add content
./bin/docgen2 -add-heading <doc-id> -level 1 -text "Introduction"
./bin/docgen2 -add-markdown <doc-id> -content "Your markdown content here"
# Export document (coming soon)
./bin/docgen2 -export <doc-id> -format pdfDocuments are stored in a hierarchical file structure:
docgen_data/
└── documents/
└── my-document/
├── manifest.yaml # Document metadata
├── blocks/ # Content blocks
│ ├── hd-001-heading.yaml
│ ├── md-001.md
│ └── img-001-image.yaml
└── assets/ # Images and attachments
└── image.png
- Heading: Section titles with levels h1-h6
- Markdown: General formatted text, lists, code blocks, quotes
- Image: Images with optional captions and alt text
- Table: Structured data in CSV-like format
- Page Break: Force page breaks in PDF/DOCX output
The server provides the following MCP tools:
create_document- Create a new documentlist_documents- List all documentsget_document_overview- Get document structuredelete_document- Delete a documentsearch_blocks- Search within documents
add_heading- Add a heading blockadd_markdown- Add markdown contentadd_image- Add an image with metadataadd_table- Add a structured tableadd_page_break- Add a page breakadd_multiple_blocks- Add multiple blocks at onceget_block- Get specific block contentupdate_block- Update existing block (planned)delete_block- Delete a block (planned)move_block- Reorder blocks (planned)
add_chapter- Add a chapter to chaptered documentsupdate_chapter- Update chapter title (planned)delete_chapter- Delete a chapter (planned)move_chapter- Reorder chapters (planned)
export_document- Export to PDF/DOCX/HTML (planned)
Set the document storage location using environment variable:
export DOCGEN_ROOT=/path/to/documentsDefault location is ./docgen_data in the current directory.
# Unit tests
./run.sh test
# Integration tests
./run.sh integration
# All tests
go test ./... -vdocgen2/
├── cmd/ # Main entry point
├── pkg/
│ ├── blocks/ # Block types and interfaces
│ ├── config/ # Configuration management
│ ├── document/ # Document types and operations
│ ├── handler/ # MCP protocol handlers
│ └── storage/ # File system operations
└── test/ # Integration tests
- Block-Based Architecture: Enables granular editing without regenerating entire documents
- File Storage: No database required, easy backup and version control
- Minimal Complexity: Focus on current requirements, no over-engineering
- Fail Fast: Clear error messages, no silent failures
See docs/docgen2-design-document.md for detailed design documentation.
MIT License