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.
Agents are here. As agent-human collaboration becomes the norm, LLMs need to express their work in formats we can actually understand.
But there's a gap between how LLMs like to write, plaintext and markdown files that overwhelm human readers, and what we like to read, well formatted documents and PDFs.
Today, we're bridging that gap. In this tutorial, you'll learn how to build and deploy an MCP server using Dedalus that gives your agents the ability to generate PDF and .docx files in one line of code.
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, so you can use this agent in one line of code.
On the server side, tools are implemented using the @tool decorator. The server discovers the tool's schema by inspecting the Python type hints and makes them accessible to the LLM behind your agent.
On the agent side, Dedalus is configured with mcp_servers=[marketplace_slug]. The LLM receives your server's schema and learns what tools are available and what arguments they need. When the model calls render_pdf, it already knows which variables (title, markdown, style) to provide for document generation.
This relationship combines the natural language and non-deterministic intelligence of LLMs with the power of repeatable and clearly defined workflows to create an agent that can do real work on your behalf.
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 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.