725190010c
Aggiunge la possibilità di convertire un documento Markdown in PDF
direttamente lato server, senza richiedere al chiamante di avere
md-to-pdf, pandoc o altri tool sull'host. Il PDF è restituito come
stringa base64 nella risposta JSON-RPC, pronto a essere salvato,
allegato o spedito al cliente.
- pdf_renderer.py: nuovo modulo che parsea il frontmatter YAML del
Markdown (incluso il blocco pdf_options stile Puppeteer/md-to-pdf),
rende il body in HTML via markdown-it-py (supporta tabelle e
HTML inline) e produce il PDF tramite Chromium headless gestito
da Playwright. Le pdf_options camelCase (printBackground,
displayHeaderFooter, headerTemplate, ...) vengono tradotte negli
argomenti snake_case di page.pdf().
- mcp_tools.py: nuovo tool `document_to_pdf(markdown)` che ritorna
`{pdf_b64, size_bytes}`; `document_generate` esteso con il
parametro `output_format ∈ {md, pdf, both}` per emettere il PDF
contestualmente alla generazione del Markdown.
- pyproject.toml + uv.lock: aggiunte le dipendenze playwright>=1.48
e markdown-it-py[plugins]>=3.0.
- mcp-docugen.Dockerfile: nuova fase di runtime che installa le
librerie native richieste da Chromium (libnss3, libgbm1, ecc.) e
scarica il binario Chromium di Playwright in /opt/ms-playwright.
- 7 nuovi test unit (83 totali) che coprono lo split del frontmatter,
il rendering Markdown→HTML con tabelle, la traduzione delle
pdf_options camelCase→snake_case e l'errore su YAML invalido. Il
test E2E che richiede Chromium è marcato skip in unit; lo smoke
via MCP conferma generazione PDF da 134 KB / 4 pagine.
README aggiornato con le tre strade di conversione (server-side,
client-side, bundling) e la stima del nuovo costo immagine.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
912 B
TOML
43 lines
912 B
TOML
[project]
|
|
name = "mcp-docugen"
|
|
version = "0.1.0"
|
|
description = "MCP server for document generation from Markdown templates via OpenRouter"
|
|
requires-python = ">=3.11"
|
|
dependencies = [
|
|
"mcp>=1.2",
|
|
"fastapi>=0.115",
|
|
"uvicorn[standard]>=0.34",
|
|
"pydantic>=2.0",
|
|
"pydantic-settings>=2.0",
|
|
"httpx>=0.27",
|
|
"aiosqlite>=0.20",
|
|
"aiofiles>=24.0",
|
|
"pyyaml>=6.0",
|
|
"pillow>=11.0",
|
|
"python-multipart>=0.0.9",
|
|
"playwright>=1.48",
|
|
"markdown-it-py[plugins]>=3.0",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=8.0",
|
|
"pytest-asyncio>=0.24",
|
|
"respx>=0.21",
|
|
"pytest-cov>=5.0",
|
|
]
|
|
|
|
[project.scripts]
|
|
mcp-docugen = "mcp_docugen.main:run"
|
|
|
|
[tool.coverage.run]
|
|
source = ["src/mcp_docugen"]
|
|
omit = ["src/mcp_docugen/main.py"]
|
|
|
|
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["src/mcp_docugen"]
|