Table of contents
← Back to blog

Running DOOM in ChatGPT: A Step-by-Step Guide

Learn how we made DOOM playable in ChatGPT using xmcp's Apps SDK integration. This guide shows you how to build interactive game experiences that run directly inside ChatGPT.

What You'll Learn

By the end of this guide, you'll understand:

  • How to use xmcp
  • How to use Apps SDK
  • How to build a retro arcade experience with multiple games

Prerequisites

Before starting, make sure you have:

  • An existing xmcp project (or create one)
  • Basic understanding of Next.js and React
  • ChatGPT Plus subscription (for testing the integration) or you can alternatively use MCPJam

How It Works

The project consists of two main components:

  1. MCP Server built with xmcp: Exposes tools to ChatGPT that return interactive widgets
  2. Next.js Application: Renders the game selection interface and runs the games using js-dos

You can find the complete project on GitHub.

Users can interact with the arcade in two ways:

  • arcade tool: Displays the full arcade interface with multiple game options
  • launch_game tool: Directly launches a specific game like DOOM

When ChatGPT invokes either tool, it receives a URL pointing to the hosted Next.js application. The OpenAI Apps SDK then renders this as an interactive widget within the chat interface.

Building the MCP Server

With xmcp's Apps SDK support, creating interactive tools is straightforward. Let's look at how we defined the tools.

The Arcade Tool

The arcade tool displays the game selection interface:

The Launch Game Tool

The launch_game tool directly launches a specific game:

To understand how the metadata works, you can read the Tools Metadata.

Implementing Tool Handlers

Now let's look at how the tool handlers actually work. Instead of manually building widget URLs, we fetch the complete HTML from our Next.js application.

Launching The Arcade

The arcade tool fetches the HTML for the game selection interface:

Utility Function

The getAppsSdkCompatibleHtml utility function fetches the rendered HTML from your Next.js app:

Launching A Game

The launch_game tool accepts parameters, validates input, and returns structured content that the widget can access:

The key here is the structuredContent - this data is accessible to your Next.js widget via the useToolOutput() hook, enabling communication between tools and widgets.

Widget-to-Tool Communication

One of the most powerful features is that widgets can call MCP tools directly. This creates a dynamic, interactive experience.

Custom Hooks for Communication

Your Next.js application uses custom hooks to interact with the MCP server:

Arcade Interface Implementation

The arcade widget displays game cards. When a user clicks a card, it invokes the launch_game tool:

Checking Tool Output

The widget can check if a game has been launched by reading the toolOutput:

Project Structure

Here's how the project is organized:

Testing in ChatGPT

Here's the complete user flow for testing your arcade:

  1. Deploy your MCP server and Next.js app
  2. Enable Developer Mode: Navigate to Apps & ConnectorsAdvanced Settings and enable developer mode
  3. Create Connector:
    • Go back to Apps & Connectors and click Create
    • Enter a name for your connector and your MCP server URL
    • Select No Authentication
  4. Connect in Chat:
    • Create a new chat
    • Use the / command followed by your connector name
    • Ask "Show me the arcade." ChatGPT will display the arcade

Conclusion

You've now learned how to create interactive game experiences in ChatGPT using xmcp's Apps SDK! This same pattern can be applied to build any interactive widget from data visualizations to interactive forms.

Dive deeper

You can find the complete framework guide in the xmcp Documentation, browse source code and examples on the GitHub Repository, or join the Discord Community to get help and share your projects.

Contributing

Share your feedback and help shape the future of xmcp: GitHub

One framework to rule them all