s3-md-pdf-converter-mcp
Integrates with Amazon S3 for downloading markdown files from buckets and uploading generated PDFs back to S3.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@s3-md-pdf-converter-mcpConvert README.md to PDF and save as output.pdf"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
s3-md-pdf-converter-mcp
A powerful Model Context Protocol (MCP) server that converts Markdown files and content to beautifully stylegd PDFs with S3 integration, Mermaid diagrams and ApexCharts support. Built with MCP SDK 1.16.x featuring all transport modes: stdio, HTTP, and SSE.
✨ Features
🚀 Transport Layer Support (MCP SDK 1.16.x)
stdio: Perfect for Claude Desktop integration
Streamable HTTP: Modern web applications with session management
SSE (Server-Sent Events): Legacy compatibility support
CORS enabled: Browser-friendly with proper headers
DNS rebinding protection: Enhanced security
📄 PDF Conversion
🔄 Three conversion modes: File-to-PDF, content-to-PDF, and S3-to-PDF
☁️ S3 Integration: Direct download from S3 buckets and upload PDFs back to S3
📊 Charts & diagrams: Mermaid diagrams + ApexCharts support
🎨 Modern styling: Professional typography with syntax highlighting
📄 Multiple formats: A4, A3, A5, Letter, Legal, Tabloid
⚙️ Configurable margins: Custom spacing in inches, mm, cm
📝 Front matter support: YAML metadata for document properties
🎯 Accessibility: Tagged PDFs with proper outline structure
📦 Large content support: JSON structure for handling 10,000+ line documents
Related MCP server: MCP MD2PDF Server
🚀 Quick Start
Option 1: Use with npx (Recommended)
# Default stdio mode (for Claude Desktop)
npx s3-md-pdf-converter-mcp
# HTTP server mode
npx s3-md-pdf-converter-mcp http 3000
# SSE server mode (legacy)
npx s3-md-pdf-converter-mcp sse 3001Option 2: Global Installation
npm install -g s3-md-pdf-converter-mcp
# Run in different modes
s3-md-pdf-converter-mcp # stdio (default)
s3-md-pdf-converter-mcp http 3000 # HTTP server
s3-md-pdf-converter-mcp sse 3001 # SSE server🔧 Integration Options
Claude Desktop (stdio)
Add to your Claude Desktop configuration:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"s3-markdown-pdf": {
"command": "npx",
"args": ["s3-md-pdf-converter-mcp"]
}
}
}HTTP Server
# Start HTTP server on port 3000
npx s3-md-pdf-converter-mcp http 3000
# Or with npm
npm run start:httpSSE Server (Legacy)
# Start SSE server on port 3001
npx s3-md-pdf-converter-mcp sse 3001
# Or with npm
npm run start:sseRestart Claude Desktop after configuration.
📖 Usage Examples
Convert Markdown File to PDF
"Convert my README.md file to PDF and save it as documentation.pdf"Convert Markdown Content to PDF
"Take this markdown content and create a PDF with A4 format:
# My Document
This is **bold** text with a [link](https://example.com)
"S3 Integration
"Convert S3 markdown from bucket 'my-docs' key 'report.md' and save to 'output.pdf'"
"Convert S3 markdown from bucket 'docs' key 'readme.md' and upload PDF to S3 with key 'readme.pdf' and uploadToS3 true"Large Content Support
"Convert this large markdown content to PDF: {content: 'Main content...', chunks: ['Section 1...', 'Section 2...']}"Custom Formatting
"Convert the markdown file with custom margins of 1 inch on all sides and Letter format"Charts & Diagrams
ApexCharts:
# Sales Data
```chart
{
"chart": { "type": "line", "height": 350 },
"series": [{ "name": "Sales", "data": [30, 40, 35, 50, 49, 60, 70] }],
"xaxis": { "categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"] }
}
**Mermaid:**
```markdown
```mermaid
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Action 1]
B -->|No| D[Action 2]
## 🚀 Transport Modes (MCP SDK 1.16.x)
This server implements **all transport modes** from the latest MCP SDK, making it compatible with various integration scenarios:
### 💻 stdio (Default) - Claude Desktop Ready
**Perfect for**: Claude Desktop, command-line tools, direct integrations
```bash
npx md-mermaid-chart-pdf-mcpFeatures:
Zero configuration required
Direct stdin/stdout communication
Ideal for desktop AI applications
Automatic process lifecycle management
🌐 Streamable HTTP - Modern Web Applications
Perfect for: Web applications, microservices, cloud deployments
npx md-mermaid-chart-pdf-mcp http 3000Features:
Endpoints:
POST/GET/DELETE /mcpSession management with
mcp-session-idheaderCORS enabled for browser clients
DNS rebinding protection for security
Stateful sessions with automatic cleanup
Error handling with proper HTTP status codes
Integration Example:
// Browser/Node.js client
const response = await fetch('http://localhost:3000/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'mcp-session-id': sessionId // Optional for new sessions
},
body: JSON.stringify(mcpRequest)
});📡 SSE (Server-Sent Events) - Legacy Support
Perfect for: Backwards compatibility, existing SSE-based systems
npx md-mermaid-chart-pdf-mcp sse 3001Features:
SSE endpoint:
GET /ssefor real-time notificationsMessage endpoint:
POST /messagesfor client requestsSession-based communication
Legacy compatibility with older MCP implementations
Integration Example:
// SSE connection for notifications
const eventSource = new EventSource('http://localhost:3001/sse');
// POST messages for requests
fetch('http://localhost:3001/messages?sessionId=abc123', {
method: 'POST',
body: JSON.stringify(mcpRequest)
});🛠️ Available Tools
convert_markdown_to_pdf
Converts a markdown file to PDF (supports local files, URLs, and S3 URLs).
Parameters:
markdownPath(string): Path to the markdown file (local path or URL)outputPath(string): Where to save the PDFformat(optional): Page format (A4, A3, A5, Letter, Legal, Tabloid)margin(optional): Custom margins object
convert_s3_markdown_to_pdf
Converts a markdown file from S3 bucket to PDF using bucket and key parameters.
Parameters:
bucket(string): S3 bucket namekey(string): S3 object key (path to the markdown file)outputPath(string): Where to save the PDF (local path or S3 key for upload)uploadToS3(boolean, optional): Whether to upload the PDF back to the same S3 bucketregion(string, optional): AWS region (defaults to us-east-1)format(optional): Page format (A4, A3, A5, Letter, Legal, Tabloid)margin(optional): Custom margins object
markdown_content_to_pdf
Converts markdown content directly to PDF (supports large content with JSON structure).
Parameters:
markdownContent(string or object): Markdown content to convert (string or JSON object with content/chunks)outputPath(string): Where to save the PDFtitle(optional): Document titleformat(optional): Page formatmargin(optional): Custom margins object
📚 API Documentation
MCP Protocol Methods
tools/list
Returns available tools for PDF conversion.
Response:
{
"tools": [
{
"name": "convert_markdown_to_pdf",
"title": "Convert Markdown File to PDF",
"description": "Convert a markdown file to PDF",
"inputSchema": { /* Zod schema */ }
},
{
"name": "markdown_content_to_pdf",
"title": "Convert Markdown Content to PDF",
"description": "Convert markdown content directly to PDF",
"inputSchema": { /* Zod schema */ }
}
]
}tools/call
Execute PDF conversion tools.
Request:
{
"name": "convert_markdown_to_pdf",
"arguments": {
"markdownPath": "./README.md",
"outputPath": "./output.pdf",
"format": "A4",
"margin": {
"top": "1in",
"right": "0.5in",
"bottom": "1in",
"left": "0.5in"
}
}
}Response:
{
"content": [
{
"type": "text",
"text": "Successfully converted markdown to PDF!\nInput: ./README.md\nOutput: /full/path/output.pdf"
}
]
}HTTP API Endpoints (HTTP Transport)
POST /mcp
Main MCP communication endpoint.
Headers:
Content-Type: application/jsonmcp-session-id: <session-id>(optional for new sessions)
Request Body: Standard MCP JSON-RPC 2.0 message
GET /mcp
Server-to-client notifications via Server-Sent Events.
Headers:
mcp-session-id: <session-id>(required)
DELETE /mcp
Terminate MCP session.
Headers:
mcp-session-id: <session-id>(required)
SSE API Endpoints (SSE Transport)
GET /sse
Establish SSE connection for notifications.
Response: Server-Sent Events stream
POST /messages
Send MCP messages to server.
Query Parameters:
sessionId: <session-id>(required)
Request Body: Standard MCP JSON-RPC 2.0 message
🎨 Supported Markdown Features
Headers: H1-H6 with modern styling
Text formatting: Bold, italic, strikethrough
Lists: Ordered and unordered with custom bullets
Tables: Styled with alternating row colors
Code blocks: Syntax highlighting for 100+ languages
Blockquotes: Elegant left-border styling
Links: Styled with hover effects
Images: Embedded with proper scaling
Charts: ApexCharts (line, bar, pie, area, etc.) via
chartblocksMermaid diagrams: Flowcharts, sequence, gantt, and more
🛠️ Installation & Deployment
Local Development
# Clone and install
git clone https://github.com/skmprb/s3-md-pdf-converter-mcp.git
cd s3-md-pdf-converter-mcp
npm install
npm run build
# Run in different modes
npm start # stdio mode
npm run start:http # HTTP server on port 3000
npm run start:sse # SSE server on port 3001Production Deployment
Docker (Recommended)
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "run", "start:http"]PM2 Process Manager
# Install globally
npm install -g s3-md-pdf-converter-mcp pm2
# Start with PM2
pm2 start "s3-md-pdf-converter-mcp http 3000" --name s3-mcp-pdf-server
pm2 startup
pm2 saveSystemd Service
[Unit]
Description=MCP PDF Converter Server
After=network.target
[Service]
Type=simple
User=mcp
WorkingDirectory=/opt/mcp-pdf
ExecStart=/usr/bin/node /opt/mcp-pdf/build/index.js http 3000
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetCloud Deployment
Vercel/Netlify Functions
// api/mcp.js
import { createServer, setupServer } from '../src/index.js';
export default async function handler(req, res) {
const server = createServer();
setupServer(server);
// Handle MCP requests
}AWS Lambda
// lambda.js
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
export const handler = async (event, context) => {
// Lambda handler for MCP requests
};📋 Requirements & Compatibility
System Requirements
Node.js 18+ (LTS recommended)
Chrome/Chromium (automatically installed with Puppeteer)
Memory: 512MB+ available RAM for PDF generation
Disk: 200MB+ for Chromium and dependencies
MCP Compatibility
MCP SDK: 1.16.x (latest with all transport modes)
Protocol Version: 2024-11-05 and later
Backwards Compatible: Supports legacy SSE transport
Client Support: Claude Desktop, custom MCP clients
Transport-Specific Requirements
Transport | Port | Dependencies | Use Case |
stdio | N/A | None | Claude Desktop, CLI |
HTTP | 3000+ | express, cors | Web apps, APIs |
SSE | 3001+ | express | Legacy systems |
🔧 Configuration Examples
Custom Margins
{
"margin": {
"top": "1in",
"right": "0.5in",
"bottom": "1in",
"left": "0.5in"
}
}Front Matter Support
---
title: My Document
author: John Doe
date: 2024-01-01
---
# Document Content
Your markdown content here...Environment Variables
# Server configuration
MCP_PORT=3000 # HTTP server port
MCP_HOST=localhost # HTTP server host
MCP_CORS_ORIGIN=* # CORS allowed origins
MCP_SESSION_TIMEOUT=3600000 # Session timeout (ms)
# PDF generation
PDF_TIMEOUT=30000 # PDF generation timeout (ms)
PDF_QUALITY=100 # PDF quality (1-100)
CHROME_ARGS="--no-sandbox" # Additional Chrome arguments⚡ Performance & Optimization
PDF Generation Performance
Average conversion time: 2-5 seconds for typical documents
Memory usage: 100-300MB per conversion
Concurrent requests: Supports multiple simultaneous conversions
Caching: Automatic font and resource caching
Optimization Tips
// Optimize for large documents
const options = {
format: 'A4',
margin: { top: '0.5in', right: '0.5in', bottom: '0.5in', left: '0.5in' },
// Reduce quality for faster generation
printBackground: false,
// Disable animations for better performance
preferCSSPageSize: true
};Scaling Considerations
Horizontal scaling: Deploy multiple instances behind load balancer
Resource limits: Set appropriate memory limits (1GB+ recommended)
Queue management: Implement request queuing for high load
Monitoring: Track conversion times and error rates
🔍 Troubleshooting
Common Issues
"Chrome not found" Error
# Install Chrome/Chromium manually
sudo apt-get install chromium-browser # Ubuntu/Debian
brew install chromium # macOS
# Or set custom Chrome path
export CHROME_PATH=/path/to/chromeMemory Issues
# Increase Node.js memory limit
node --max-old-space-size=4096 build/index.js
# Or set environment variable
export NODE_OPTIONS="--max-old-space-size=4096"Port Already in Use
# Find process using port
lsof -i :3000
# Kill process
kill -9 <PID>
# Or use different port
npx s3-md-pdf-converter-mcp http 3001CORS Issues
// Custom CORS configuration
app.use(cors({
origin: ['https://yourdomain.com'],
credentials: true,
exposedHeaders: ['Mcp-Session-Id']
}));Debug Mode
# Enable debug logging
DEBUG=mcp:* npx s3-md-pdf-converter-mcp http 3000
# Verbose Puppeteer logging
DEBUG=puppeteer:* npx s3-md-pdf-converter-mcpHealth Check Endpoint
# Add to your HTTP server
app.get('/health', (req, res) => {
res.json({
status: 'healthy',
version: '1.0.0',
uptime: process.uptime(),
memory: process.memoryUsage()
});
});🤝 Contributing
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
📊 Feature Comparison
Feature | stdio | HTTP | SSE | Notes |
Claude Desktop | ✅ | ❌ | ❌ | Primary use case |
Web Applications | ❌ | ✅ | ✅ | HTTP recommended |
Session Management | ❌ | ✅ | ✅ | Stateful connections |
CORS Support | N/A | ✅ | ✅ | Browser compatibility |
Real-time Notifications | ❌ | ✅ | ✅ | Server-to-client |
DNS Protection | N/A | ✅ | ❌ | Security feature |
Process Lifecycle | Auto | Manual | Manual | Automatic cleanup |
Scalability | Low | High | Medium | Concurrent connections |
Setup Complexity | None | Low | Medium | Configuration required |
🛡️ Security Considerations
HTTP Transport Security
DNS Rebinding Protection: Enabled by default
CORS Configuration: Properly configured origins
Session Validation: Secure session ID generation
Input Sanitization: All inputs validated with Zod schemas
Production Security Checklist
Use HTTPS in production
Configure specific CORS origins (not
*)Set up proper firewall rules
Enable rate limiting
Monitor for suspicious activity
Regular security updates
// Production CORS configuration
app.use(cors({
origin: [
'https://yourdomain.com',
'https://app.yourdomain.com'
],
credentials: true,
exposedHeaders: ['Mcp-Session-Id'],
allowedHeaders: ['Content-Type', 'mcp-session-id']
}));📜 Related Projects
MCP TypeScript SDK: Official MCP SDK
Claude Desktop: AI assistant with MCP support
Puppeteer: Headless Chrome for PDF generation
Mermaid: Diagram and flowchart library
ApexCharts: Interactive chart library
🐛 Issues & Support
Found a bug or need help? Please open an issue on GitHub.
Before Opening an Issue
Check existing issues for duplicates
Include your Node.js version
Specify which transport mode you're using
Provide sample markdown content (if applicable)
Include error logs and stack traces
🌟 Show Your Support
Give a ⭐️ if this project helped you!
Ways to Contribute
⭐ Star the repository
🐛 Report bugs and issues
💡 Suggest new features
📝 Improve documentation
🔧 Submit pull requests
💬 Share your use cases
Built with ❤️ using MCP SDK 1.16.x and AWS SDK v3
Available Tools
3 toolsconvert_markdown_to_pdfConvert Markdown File to PDFC
Convert a markdown file to PDF
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | PDF page format (default: A4) | |
| margin | No | PDF margins (e.g., '0.5in', '20mm') | |
| outputPath | Yes | Path where the PDF should be saved | |
| markdownPath | Yes | Path to the markdown file to convert (local path or URL) |
convert_s3_markdown_to_pdfConvert S3 Markdown File to PDFB
Convert a markdown file from S3 bucket to PDF using bucket and key parameters
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | S3 object key (path to the markdown file) | |
| bucket | Yes | S3 bucket name | |
| format | No | PDF page format (default: A4) | |
| margin | No | PDF margins (e.g., '0.5in', '20mm') | |
| region | No | AWS region (defaults to us-east-1) | |
| outputPath | Yes | Path where the PDF should be saved (local path or S3 key for upload) | |
| uploadToS3 | No | Whether to upload the PDF back to the same S3 bucket (default: false) |
markdown_content_to_pdfConvert Markdown Content to PDFC
Convert markdown content directly to PDF
| Name | Required | Description | Default |
|---|---|---|---|
| title | No | Document title for the PDF | |
| format | No | PDF page format (default: A4) | |
| margin | No | PDF margins (e.g., '0.5in', '20mm') | |
| outputPath | Yes | Path where the PDF should be saved | |
| markdownContent | Yes | Markdown content to convert (string or JSON object with content/chunks) |
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.2.3- First observed
convert_markdown_to_pdf - First observed
convert_s3_markdown_to_pdf - First observed
markdown_content_to_pdf
TDQS
Scored across 3 tools
The three tools differ by input source: file, S3 object, and content string. However, the generic 'convert_markdown_to_pdf' could be misread as covering S3 or content, though the explicit S3 and content tools reduce ambiguity.
The first two tools follow a convert_X_to_pdf pattern, but the third breaks convention by starting with 'markdown_content' instead of a verb. This mixed style is readable but not fully consistent.
With three input modes (file, S3, content), each tool serves a distinct purpose and justifies its existence. This is an appropriate scope for a specialized markdown-to-PDF converter.
The server covers the core conversion needs for local files, S3 objects, and raw content. Minor gaps like URL-based conversion or batch processing are absent but not critical for the core purpose.
Maintenance
Related MCP Connectors
Render Markdown and LLM output into accessible PDF/UA-1 PDFs. No headless Chromium.
I create PDF documents from markdown, preview, then generate a downloadable file
Compliant PDFs (PDF/A-2A + PDF/UA-1) from markdown or a compact DSL - fast, no headless browser.
Convert Markdown, HTML, and web pages to high-quality PDF with Prince.
Related MCP Servers
- AlicenseAqualityDmaintenanceConverts Markdown documents to PDF files with support for syntax highlighting, custom styling, Mermaid diagrams, optional page numbers, and configurable watermarks.145 npmMIT
- FlicenseNot gradedqualityDmaintenanceProvides tools for converting Markdown content and files into professional PDF documents with full support for Mermaid diagrams and LaTeX rendering. It allows for high-quality output customization, including paper size, table of contents, and syntax highlighting styles.-
- AlicenseNot gradedqualityDmaintenanceConverts Markdown files and standalone Mermaid diagrams into high-quality PDF or PNG documents using Puppeteer and SVG rendering. It supports custom CSS styling and provides tools for professional document generation from markdown-based content.4MIT
- AlicenseNot gradedqualityDmaintenanceConverts Markdown files and raw content into professionally styled PDFs with full support for Mermaid diagrams and syntax highlighting. It offers customizable page formats, margins, and modern typography for high-quality document generation.11MIT