Skip to main content
Glama
MCP Dynamic HTML App

MCP Dynamic HTML App

by vikkysarswat

๐Ÿš€ MCP Dynamic HTML App

A Python-based Model Context Protocol (MCP) server that demonstrates dynamic HTML rendering with live data for ChatGPT applications.

๐ŸŽฏ What This Does

This app showcases how to build a dynamic ChatGPT app where:

  • HTML is rendered based on live data (not static assets)

  • Data is fetched from a simulated database

  • Content changes dynamically based on user queries

  • Perfect for dashboards, reports, and data visualizations

Related MCP server: widget-studio

๐Ÿ—๏ธ Architecture

Based on the Server-Side Dynamic HTML Rendering pattern:

ChatGPT โ†’ MCP Tool Call โ†’ Python Server โ†’ Fetch DB Data โ†’ Render HTML โ†’ Return to ChatGPT

๐Ÿ“ฆ Features

โœ… Three Dynamic Tools:

  1. get_dynamic_dashboard - Live metrics dashboard with theme support

  2. get_user_profile - User profile cards with real-time data

  3. get_metrics_table - Interactive data tables (sales, performance, engagement)

โœ… Simulated Database - No setup required, works out of the box

โœ… Beautiful HTML - Modern, responsive designs with CSS

โœ… Easy Deployment - Deploy to Railway, Render, or any Python hosting

๐Ÿš€ Quick Start

1. Clone the Repository

git clone https://github.com/vikkysarswat/mcp-dynamic-html-app.git
cd mcp-dynamic-html-app

2. Install Dependencies

pip install -r requirements.txt

3. Run the Server

python server.py

๐Ÿ”ง How to Use

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "dynamic-html": {
      "command": "python",
      "args": ["/path/to/mcp-dynamic-html-app/server.py"]
    }
  }
}

Example Prompts

"Show me the dashboard"
"Get user profile for user_001"
"Display sales metrics table"
"Show me performance metrics with dark theme"

๐Ÿ“ Project Structure

mcp-dynamic-html-app/
โ”œโ”€โ”€ server.py           # Main MCP server with tool definitions
โ”œโ”€โ”€ database.py         # Simulated database with sample data
โ”œโ”€โ”€ html_renderer.py    # HTML rendering templates
โ”œโ”€โ”€ requirements.txt    # Python dependencies
โ””โ”€โ”€ README.md          # This file

๐Ÿ› ๏ธ Customization

Add Your Own Data Source

Replace the simulated database in database.py:

import sqlite3

async def get_user_data(user_id: str):
    conn = sqlite3.connect('your_database.db')
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM users WHERE id = ?", (user_id,))
    return cursor.fetchone()

Create Custom HTML Templates

Add new rendering functions in html_renderer.py:

def render_custom_view(data):
    return f"""
    <!DOCTYPE html>
    <html>
        <!-- Your custom HTML -->
    </html>
    """

Add New Tools

Extend the tools list in server.py:

@server.list_tools()
async def handle_list_tools():
    return [
        # ... existing tools
        types.Tool(
            name="your_custom_tool",
            description="Your tool description",
            inputSchema={...}
        )
    ]

๐Ÿšข Deployment Options

Deploy to Railway

  1. Fork this repository

  2. Go to Railway.app

  3. Click "New Project" โ†’ "Deploy from GitHub"

  4. Select this repository

  5. Railway will auto-detect Python and deploy

Deploy to Render

  1. Go to Render.com

  2. Click "New" โ†’ "Background Worker"

  3. Connect your GitHub repository

  4. Set build command: pip install -r requirements.txt

  5. Set start command: python server.py

Deploy to Heroku

heroku create your-app-name
git push heroku main

๐Ÿ“Š Example Use Cases

  • Business Dashboards - Real-time KPIs and metrics

  • User Management - Dynamic user profiles and lists

  • Data Reports - Interactive tables and charts

  • Analytics Views - Performance and engagement tracking

  • Admin Panels - System monitoring and alerts

๐Ÿงช Testing

Test the tools directly:

import asyncio
from database import get_user_data
from html_renderer import render_user_card

async def test():
    user = await get_user_data("user_001")
    html = render_user_card(user)
    print(html)

asyncio.run(test())

๐Ÿ“š Learn More

๐Ÿค Contributing

Contributions welcome! Feel free to:

  • Add new HTML templates

  • Create additional tools

  • Improve the database layer

  • Add tests

๐Ÿ“„ License

MIT License - feel free to use this in your projects!

๐ŸŽ‰ Credits

Created by Nilesh Vikky based on MCP dynamic HTML rendering patterns.


Happy Building! ๐Ÿš€

If you have questions or need help, open an issue or reach out!

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server that lets agents create, display, and export rich UI widgets (cards, dashboards, charts, forms) inline in conversations, with interactive iframe support in MCP Apps hosts and PNG image fallback for other clients.
      3
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      A standalone stdio MCP server that exposes 13 resources, 3 prompts and 7 tools for assembling interactive, replayable HTML interfaces such as calculators, charts, maps, flowcharts and small apps. It returns the generated HTML document for the calling client to decide whether and how to display.
      MIT