MCP Server
MCP Server
Aspose.Page FOSS for Python includes an optional MCP server that exposes conversion
functions as remote tools. The server is built on FastMCP and registers ps_to_pdf,
ps_to_image, xps_to_pdf, and xps_to_image as callable tools.
FastMCP is an optional dependency — the core conversion functionality works without it.
McpInput and McpOutput
McpInput accepts either a file path (as a string) or base64-encoded bytes as the source
document. McpOutput returns the result as base64 bytes or writes directly to a file path.
from aspose.page.mcp.models import McpInput, McpOutput
# Input from file path
input_from_path = McpInput(path="input.ps")
# Input from base64 bytes
import base64
with open("input.ps", "rb") as f:
b64 = base64.b64encode(f.read()).decode()
input_from_b64 = McpInput(base64_data=b64)McpConversionOptions
McpConversionOptions controls the output format and DPI for image conversions.
from aspose.page.mcp.models import McpConversionOptions
opts = McpConversionOptions(format="png", dpi=150)Tips and Best Practices
- FastMCP must be installed separately (
pip install fastmcp) to run the MCP server. - The core
PsDocumentandXpsDocumentconversion APIs work without FastMCP. - Use
McpInput(base64_data=...)when the client cannot provide a local file path.
API Reference Summary
| Class / Property | Description |
|---|---|
McpInput | MCP input: file path or base64 bytes |
McpOutput | MCP output: base64 bytes or file path |
McpConversionOptions | Output format and DPI for image conversion |