chatgpt-apps-sdk-nextjs-starter  by vercel-labs

Next.js starter for building OpenAI Apps SDK compatible MCP servers

Created 6 months ago
250 stars

Top 100.0% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

This starter project provides a minimal Next.js application template for building OpenAI Apps SDK compatible MCP (Model Context Protocol) servers. It enables developers to expose tools and resources that can be called from ChatGPT, with responses rendered natively within the ChatGPT interface as interactive widgets. The primary benefit is seamless integration, allowing Next.js applications to act as dynamic components within the ChatGPT user experience.

How It Works

The project leverages a Next.js application as an MCP server. A dedicated route (app/mcp/route.ts) registers tools and resources, including HTML content for iframe rendering, using OpenAI-specific metadata. Crucially, next.config.ts is configured with an assetPrefix to ensure static assets load correctly within the iframe context. A CORS middleware handles preflight requests for cross-origin communication. The NextChatSDKBootstrap component in app/layout.tsx patches browser APIs like window.fetch and history.pushState to ensure proper functionality within the ChatGPT iframe environment.

Quick Start & Requirements

Highlighted Details

  • MCP Server Route: Implements tool and resource registration with OpenAI-specific metadata, including openai/resultCanProduceWidget: true to enable widget rendering.
  • Asset Prefixing: Essential assetPrefix configuration in next.config.ts prevents 404 errors for static assets loaded within the iframe.
  • SDK Bootstrap: Patches browser APIs for iframe compatibility, requiring suppressHydrationWarning due to initial HTML modifications by ChatGPT.
  • Vercel Deployment: Designed for seamless deployment on Vercel, automatically configuring production and preview URLs and asset prefixes.

Maintenance & Community

No specific details regarding maintainers, community channels, or project health signals were found in the provided README.

Licensing & Compatibility

The README does not explicitly state the project's license. Compatibility for commercial use or closed-source linking is undetermined without a specified license.

Limitations & Caveats

Connecting MCP servers to ChatGPT requires developer mode access. The suppressHydrationWarning prop is currently a mandatory configuration due to ChatGPT modifying the initial HTML before Next.js hydration.

Health Check
Last Commit

4 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
2 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.