# PDF

Agent document export: render Markdown or HTML to PDF (Chromium print) or DOCX (structured Word styles), return a staging URL. No LLM — deliverable output.

**Service id:** `pdf`  
**Version:** `0.2.0`  
**Status:** `available`

## Authentication

MCP endpoint: `https://mcp.glc-rag.hu/mcp` (streamable HTTP)

**Agents (recommended):** self-register with `account_type=agent` to get an
auto-approved token — see [https://mcp.glc-rag.hu/guide/agent](https://mcp.glc-rag.hu/guide/agent).

Or register as a human on the public site (all listed services are auto-approved),
wait for system-admin approval, then create a token.

```http
Authorization: Bearer mcp_...
```

Cursor `mcp.json` example:

```json
{
  "mcpServers": {
    "pdf": {
      "url": "https://mcp.glc-rag.hu/mcp",
      "headers": {
        "Authorization": "Bearer mcp_YOUR_TOKEN"
      }
    }
  }
}
```

## Tools

### `markdown_to_pdf`

Render Markdown to PDF and publish to staging. Provide markdown string, or url / content_base64 for larger content.

**Input schema:**

```json
{
  "type": "object",
  "properties": {
    "markdown": {
      "type": "string",
      "description": "Markdown source text"
    },
    "url": {
      "type": "string",
      "description": "Public or staging URL of a UTF-8 markdown/text file"
    },
    "content_base64": {
      "type": "string",
      "description": "Small markdown as base64 or data: URL"
    },
    "filename": {
      "type": "string",
      "description": "Output filename (default document.pdf)"
    },
    "page_format": {
      "type": "string",
      "enum": [
        "A4",
        "Letter"
      ],
      "default": "A4"
    },
    "margin_mm": {
      "type": "number",
      "minimum": 4,
      "maximum": 40,
      "default": 12,
      "description": "Page margin in millimeters"
    },
    "css": {
      "type": "string",
      "description": "Optional extra CSS (size-limited)"
    }
  },
  "additionalProperties": false
}
```

**Examples:**

```json
{
  "markdown": "# Report\n\nHello **world**.\n",
  "filename": "report.pdf"
}
```

```json
{
  "url": "https://mcp.glc-rag.hu/staging/EXAMPLE"
}
```

### `html_to_pdf`

Render HTML (document or fragment) to PDF and publish to staging. Provide html string, or url / content_base64. Does not navigate to live pages.

**Input schema:**

```json
{
  "type": "object",
  "properties": {
    "html": {
      "type": "string",
      "description": "HTML document or fragment"
    },
    "url": {
      "type": "string",
      "description": "Public or staging URL of a UTF-8 HTML file (downloaded, not navigated)"
    },
    "content_base64": {
      "type": "string",
      "description": "Small HTML as base64 or data: URL"
    },
    "filename": {
      "type": "string",
      "description": "Output filename (default document.pdf)"
    },
    "page_format": {
      "type": "string",
      "enum": [
        "A4",
        "Letter"
      ],
      "default": "A4"
    },
    "margin_mm": {
      "type": "number",
      "minimum": 4,
      "maximum": 40,
      "default": 12,
      "description": "Page margin in millimeters"
    },
    "css": {
      "type": "string",
      "description": "Optional extra CSS (size-limited)"
    }
  },
  "additionalProperties": false
}
```

**Examples:**

```json
{
  "html": "<h1>Invoice</h1><p>Total: 42 EUR</p>",
  "page_format": "A4"
}
```

### `markdown_to_docx`

Render Markdown to a formatted DOCX (headings, lists, tables, code, links) and publish to staging. Provide markdown string, or url / content_base64.

**Input schema:**

```json
{
  "type": "object",
  "properties": {
    "markdown": {
      "type": "string",
      "description": "Markdown source text"
    },
    "url": {
      "type": "string",
      "description": "Public or staging URL of a UTF-8 markdown/text file"
    },
    "content_base64": {
      "type": "string",
      "description": "Small markdown as base64 or data: URL"
    },
    "filename": {
      "type": "string",
      "description": "Output filename (default document.docx)"
    },
    "page_format": {
      "type": "string",
      "enum": [
        "A4",
        "Letter"
      ],
      "default": "A4",
      "description": "Word page size"
    },
    "margin_mm": {
      "type": "number",
      "minimum": 4,
      "maximum": 40,
      "default": 12,
      "description": "Page margin in millimeters"
    }
  },
  "additionalProperties": false
}
```

**Examples:**

```json
{
  "markdown": "# Report\n\nHello **world**.\n\n- item\n",
  "filename": "report.docx"
}
```

### `html_to_docx`

Render HTML (document or fragment) to a formatted DOCX and publish to staging. Maps headings, paragraphs, lists, tables, pre/code, blockquotes, links. Does not navigate to live pages; css is ignored.

**Input schema:**

```json
{
  "type": "object",
  "properties": {
    "html": {
      "type": "string",
      "description": "HTML document or fragment"
    },
    "url": {
      "type": "string",
      "description": "Public or staging URL of a UTF-8 HTML file (downloaded, not navigated)"
    },
    "content_base64": {
      "type": "string",
      "description": "Small HTML as base64 or data: URL"
    },
    "filename": {
      "type": "string",
      "description": "Output filename (default document.docx)"
    },
    "page_format": {
      "type": "string",
      "enum": [
        "A4",
        "Letter"
      ],
      "default": "A4",
      "description": "Word page size"
    },
    "margin_mm": {
      "type": "number",
      "minimum": 4,
      "maximum": 40,
      "default": 12,
      "description": "Page margin in millimeters"
    }
  },
  "additionalProperties": false
}
```

**Examples:**

```json
{
  "html": "<h1>Invoice</h1><p>Total: <strong>42 EUR</strong></p>",
  "filename": "invoice.docx"
}
```

### `pdf_status`

PDF/DOCX service health, Chromium path, and limits.

**Input schema:**

```json
{
  "type": "object",
  "properties": {},
  "additionalProperties": false
}
```

**Examples:**

```json
{}
```

## Usage notes

PDF: markdown_to_pdf / html_to_pdf. DOCX: markdown_to_docx / html_to_docx (headings, lists, tables, code, links). Large / shared source: staging_put_text({ text }) → url → same tools with { url } (or POST /staging/upload). PDF options: page_format A4|Letter, margin_mm, optional css. DOCX options: page_format, margin_mm (css not applied). Output is always a staging URL (no base64). Credits: PDF base + per page; DOCX base only; pdf_status is free.

## Errors / limits

SSRF-blocked URL, oversize input/output, page limit (PDF), Chromium missing, or render timeout → `{error, is_error}`. Insufficient credits → platform debit error.

## Agent discovery

- Agent registration: `https://mcp.glc-rag.hu/guide/agent`
- Markdown: `https://mcp.glc-rag.hu/guide/pdf.md`
- Index: `https://mcp.glc-rag.hu/llms.txt`
- MCP resource: `docs://pdf`
