validate_zugferd
Validate a ZUGFeRD or Factur-X PDF for compliance against electronic invoice standards. Returns validation result with profile, errors, and warnings.
Instructions
Validate a ZUGFeRD/Factur-X PDF for compliance.
Args: pdf_base64: Base64-encoded PDF with embedded ZUGFeRD data.
Returns: JSON validation result (valid, profile, errors, warnings).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pdf_base64 | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp/src/docgen_mcp/server.py:550-563 (handler)The core handler function for the 'validate_zugferd' tool. It is decorated with @mcp.tool(), receives a base64-encoded PDF, decodes it, calls dg.zugferd.validate(), and returns the JSON result.
@mcp.tool() def validate_zugferd(pdf_base64: str) -> str: """Validate a ZUGFeRD/Factur-X PDF for compliance. Args: pdf_base64: Base64-encoded PDF with embedded ZUGFeRD data. Returns: JSON validation result (valid, profile, errors, warnings). """ dg = _get_client() result = dg.zugferd.validate(base64.b64decode(pdf_base64)) from docgen._serialization import to_dict return json.dumps(to_dict(result)) - mcp/src/docgen_mcp/server.py:549-550 (registration)The @mcp.tool() decorator registers 'validate_zugferd' as an MCP tool on the FastMCP instance.
@mcp.tool() - mcp/src/docgen_mcp/server.py:28-47 (helper)The _get_client() helper lazily initializes the DocGen API client used by the handler.
def _get_client(): """Lazy-initialise the DocGen client.""" global _client if _client is None: # Import here so the module can be imported without the SDK installed # (useful for schema introspection) from docgen import DocGen api_key = os.environ.get("DOCGEN_API_KEY", "") if not api_key: raise RuntimeError( "DOCGEN_API_KEY environment variable is required. " "Set it to your DocGen API key before starting the server." ) base_url = os.environ.get("DOCGEN_BASE_URL") kwargs: dict[str, Any] = {"api_key": api_key} if base_url: kwargs["base_url"] = base_url _client = DocGen(**kwargs) return _client