ChatAppSDKStarter
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
index.ts
https://damixnr--019a47e69c5d74fea8b3e5c7106984a4.web.val.run
A starter template for building ChatGPT apps with interactive widgets using MCP (Model Context Protocol) on Val Town.
- Backend: Hono + MCP Lite + Drizzle ORM + SQLite
 - Widget: React 19 + TanStack Router + OpenAI App SDK
 
- 
Visit your deployment URL to get the MCP endpoint
 - 
Add to ChatGPT:
- Open ChatGPT settings → Apps & Connectors -> Create (you will need developer mode enabled)
 - Add MCP server with your endpoint URL
 
 - 
Test in ChatGPT:
- "List all messages"
 - "Add a message: Hello!"
 - "Show me message #1"
 
 
list_messages- Shows all messages in an interactive widgetadd_message- Adds a new message and shows updated listget_message- Shows details for a specific message
Tools return discriminated unions that drive widget navigation:
{ kind: "message_list", messages: [...] }      // → /list route
{ kind: "message_detail", id: 1, ... }         // → /detail/:id route
The widget automatically navigates based on the kind field.
Messages are automatically scoped using the openai/subject field that ChatGPT includes in request metadata. This provides authless data isolation - each subject gets its own message board.
The scoping happens in tool handlers:
const subject = ctx.request.params._meta?.["openai/subject"];
const messages = await getMessages(subject);
The exact semantics of openai/subject are determined by ChatGPT.
- Add tool in 
backend/mcp/server.ts - Define output schema in 
shared/types.ts - Create widget route in 
frontend/widgets/routes.tsx - Update 
NavigationSync.tsxto handle newkind