Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created November 9, 2025 07:45
Show Gist options
  • Save ynonp/e8e670e10a6504421df6e7eda3ba73ef to your computer and use it in GitHub Desktop.
Save ynonp/e8e670e10a6504421df6e7eda3ba73ef to your computer and use it in GitHub Desktop.
ChatGPT Apps Webinar

Add GUI To Your MCP Server => ChatGPT Apps

  1. Create the GUI
server.registerResource(
  'joke-widget',
  templateURI,
  {},
  async () => ({
    contents: [
      {
        uri: templateURI,
        mimeType: "text/html+skybridge",
        text: `
        <style>
          #dad-joke { height: 300px; }
          p { color: green; font-size: 48px }          
        </style>
        <div id="dad-joke">
          <p>Dad joke will appear here</p>
        </div>
        <script>
          window.addEventListener("openai:set_globals", () => {
            const container = document.querySelector('#dad-joke p');
            if (openai.toolOutput && openai.toolOutput.joke) {
              container.textContent = openai.toolOutput.joke;
            } else {
              container.textContent = "joke not found";
            }          
          });          
        </script>
        `,
        _meta: {
          "openai/widgetPrefersBorder": true,          
        }
      }
    ]
  })
)
  1. Use the template
    _meta: {
      "openai/outputTemplate": templateURI,
      "openai/toolInvocation/invoking": "Displaying a joke",
      "openai/toolInvocation/invoked": "Displayed a joke"
    },
    annotations: {
      destructiveHint: false,
      openWorldHint: false,
      readOnlyHint: true,
    }
  1. Deploy

  2. Read More

    _meta: { "openai/outputTemplate": templateURI, },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment