How to build an MCP server: One-Click PDF Generator
In this tutorial, you will build and publish a Model Context Protocol (MCP) server that converts Markdown to PDF, then call it from a Dedalus agent to return a downloadable file link.
LLMs are great at drafting text, but many cannot generate a real PDF file as a downloadable artifact on their own. An MCP server solves this by exposing PDF generation as a tool your agent can call.
With the Dedalus SDK, your agent can:
- Draft a Markdown document.
- Call an MCP tool to render a PDF from Markdown.
- Return a download URL that people can open, print, or share.
GitHub repo: dedalus-labs/pdf-generator-mcp
How we built the Markdown-to-PDF MCP server
The server is implemented with the Dedalus MCP framework and exposed over streamable HTTP in stateless mode. It is published to the marketplace and referenced by a marketplace slug, so an agent can use it without any local MCP infrastructure.
On the server side, tools are added using decorators. The server reads Python type hints to understand each tool's contract, so you never have to write JSON schemas by hand.
MCP tool schema (PDF and DOCX rendering):
render_pdf(title, markdown, style)->{pdf_id, filename, size_bytes, download_url}render_docx(title, markdown)->{docx_id, filename, size_bytes, download_url}
On the agent side, Dedalus is configured with mcp_servers=[marketplace_slug]. During a streaming response, the agent automatically discovers the tool contract and executes tool calls when it needs to generate a binary artifact.
End-to-end flow (LLM + MCP tool calling)
The agent works in two phases:
- Draft Markdown with headings, tables, and bullet points.
- Call
render_pdfwith a style selector, such asdefault,modern, orminimal. If needed, it can also callrender_docxusing the same Markdown input.
Because PDF and DOCX generation are encapsulated behind MCP tools, the agent code stays small. If you switch to a different PDF generator MCP server later, you only need to change the configured server slug.
Demo prompt
Here is a sample prompt you can use with this setup:
- "Create a one-page proposal for an 'LLM FAQ content sprint'. Include scope, timeline, price, and assumptions. Use modern style. Also provide a DOCX."
From there, the agent drafts Markdown, calls render_pdf (and optionally render_docx), and returns one or two download links, along with a visible MCP tool trace in the output.
Try building your own PDF generator tool
This is one example of how MCP can extend your agents with real file generation. By moving binary artifact creation behind a typed MCP tool, you keep your agent code clean while still delivering output that people can save and share.
To build something similar, start with the Dedalus SDK, wire up an MCP server that exposes render_pdf and render_docx, then point your agent to the marketplace slug.
If you are not sure where to start, check out our docs for more in-depth tutorials and join our developer community on Discord.