Show HN: OpenAI Apps Handbook
6 months ago
- #chatGPT
- #FastAPI
- #MCP
- Prerequisites include Python 3.10+, basic understanding of Python dataclasses, FastAPI/async Python, HTTP/REST concepts, and HTML.
- An MCP server app has three core components: widgets, functions to respond to ChatGPT's requests, and FastAPI + Uvicorn serving.
- Widgets require an HTML template, metadata, and a unique template URI.
- Functions include list_tools(), list_resources(), call_tool_request(), and read_resource().
- FastAPI serves GET /mcp for SSE stream and POST /mcp/messages for follow-up messages.
- Step-by-step guide to create a project directory, virtual environment, and install dependencies.
- Basic structure of main.py includes defining widget data structure and initializing FastMCP.
- Adding widgets involves defining them in a list and building lookup dictionaries.
- Input validation is handled using Pydantic models.
- Tool metadata includes OpenAI-specific hints for rendering.
- Handlers for list_tools, list_resources, and call_tool_request are registered.
- Testing the server involves running it locally and using tools like MCP Inspector.
- Deployment considerations include environment variables, Docker, and production setup with gunicorn.
- Common patterns include authentication, rate limiting, database integration, and caching.
- Troubleshooting tips cover server checks, widget validation, input schema, and CORS issues.