DEV Community

Whatsonyourmind
Whatsonyourmind

Posted on

How I Built an x402-Monetized MCP Server for AI Presentation Generation

AI agents can write code, search the web, query databases, and manage files. But ask one to create a PowerPoint deck and you get a code block with python-pptx boilerplate that positions shapes by pixel offset. The output looks like a 2003 corporate template, and it breaks the moment content overflows a text box.

I built DeckForge to fix this: an API-first presentation generation platform with an MCP server that gives AI agents real slide creation capabilities. And because I wanted autonomous agents to pay per-call without API key management, I integrated x402 -- the HTTP-native micropayment protocol that settles in USDC on Base L2.

This article covers the architecture, the MCP integration, and how x402 payments work in practice.

The Problem

There are three ways to generate slides programmatically today:

  1. python-pptx -- the standard library. It gives you element-level control, but you manually position every shape. There's no layout engine, no theme system, no chart rendering.

  2. GUI tools like Gamma and Tome -- beautiful output, but zero API access. You can't call them from code or an agent.

  3. Ask an LLM to write python-pptx code -- the LLM doesn't know the actual dimensions of rendered text, so content overflow is guaranteed. And you're generating code that generates slides, which is one abstraction too many.

The gap is: send structured data, get a polished deck. That's DeckForge.

Architecture

DeckForge is a FastAPI service with a JSON intermediate representation (IR) at the core. The IR schema uses Pydantic discriminated unions. There are 32 slide types -- 23 universal (title, bullets, chart, table, comparison, timeline, funnel, matrix, org chart, etc.) and 9 finance-specific (DCF summary, comp table, waterfall, deal overview, capital structure, market landscape, risk matrix, investment thesis).

The key insight: layout is a constraint satisfaction problem, not a coordinate problem. Instead of hardcoding positions, each slide type defines layout constraints. Kiwisolver resolves these into coordinates at render time, and the overflow handler cascades through font reduction -> reflow -> slide splitting if content doesn't fit.

MCP Integration

The Model Context Protocol is how AI agents discover and invoke tools. DeckForge exposes 6 MCP tools:

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("DeckForge")

@mcp.tool()
async def render(ir_json: str, theme: str = "corporate-blue") -> dict:
    """Render a Presentation IR into a PowerPoint file."""
    return await render_presentation(ir_json, theme)

@mcp.tool()
async def generate(prompt: str, slide_count: int = 10, theme: str = "corporate-blue") -> dict:
    """Generate a complete presentation from a natural language prompt."""
    return await generate_presentation(prompt, slide_count, theme)

@mcp.tool()
async def themes() -> list[dict]:
    """List all 15 available themes."""
    return await list_themes()
Enter fullscreen mode Exit fullscreen mode

To use with Claude Desktop, add this to your MCP config:

{
  "mcpServers": {
    "deckforge": {
      "command": "python",
      "args": ["-m", "deckforge.mcp.server"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Now Claude can create actual PowerPoint files -- not code snippets.

x402: Machine-Native Payments

Traditional API billing assumes a human signs up and enters a credit card. But autonomous AI agents don't have credit cards. They have wallets.

x402 brings the 402 Payment Required status code to life. The agent hits a protected endpoint, gets back a 402 with pricing, constructs a signed USDC transfer on Base L2, and retries with a payment header. DeckForge verifies and settles on-chain.

x402-authenticated requests skip rate limiting -- per-call payment is inherently self-throttling. The agent pays $0.05 per render and $0.15 per generate. No subscription, no credit card, no API key signup.

This matters because the direction of AI tooling is toward autonomous agent workflows. An agent that discovers a tool via MCP and pays via x402 doesn't need human intervention at any step.

TypeScript SDK

For human developers, there's a typed SDK on npm:

npm install @lukastan/deckforge
Enter fullscreen mode Exit fullscreen mode
import { DeckForge, Presentation, Slides } from "@lukastan/deckforge";

const client = new DeckForge({ apiKey: "dk_test_..." });

const deck = Presentation.create("Q4 Board Update", "corporate-blue")
  .addSlide(Slides.titleSlide({ title: "Q4 2026 Board Update", subtitle: "Acme Corp" }))
  .addSlide(Slides.statsCallout({
    title: "Key Metrics",
    metrics: [
      { value: "$4.2M", label: "ARR" },
      { value: "142%", label: "YoY Growth" },
    ],
  }));

const pptx = await client.render(deck);
Enter fullscreen mode Exit fullscreen mode

The Finance Angle

The finance vertical is deliberate. PE firms, investment banks, and consulting firms generate massive volumes of standardized presentations: IC memos, teasers, CIMs, board decks. The formatting is rigid, repetitive, and time-consuming.

The 9 finance slide types encode domain conventions: DCF summary with assumption labels, comp table with conditional formatting, returns waterfall showing entry to exit value creation, deal overview with standardized layout, capital structure with debt/equity stack visualization.

Current State

This is v0.1. The API is live, 846 tests passing, MIT licensed. Pre-revenue, sole developer.

What works well: IR-to-PPTX rendering is solid, finance slides look close to real deal team output, MCP integration works with Claude Desktop.

What needs work: NL-to-IR quality varies by LLM provider, Google Slides output is less polished, x402 untested in production with real agent wallets.

Links:

Top comments (0)