Joke Button MCP Server

Joke Button MCP Server

A minimal MCP server that exposes a single-button UI. Clicking the button prompts the assistant to deliver a short, family-friendly joke.

Category
访问服务器

README

MCP Joke Button App

This project is a tiny MCP server that exposes one MCP App UI: a single button. When the button is clicked, the app sends a message to the host asking the assistant to answer with one short, family-friendly joke.

It intentionally uses only Node.js built-in modules. There are no runtime package dependencies.

What It Demonstrates

  • MCP core protocol version 2026-07-28
  • Stateless Streamable HTTP on one endpoint: /mcp
  • server/discover, tools/list, tools/call, resources/list, and resources/read
  • MCP Apps UI resource metadata with _meta.ui.resourceUri
  • A sandbox-friendly text/html;profile=mcp-app widget
  • ui/initialize and ui/message over postMessage

Requirements

Install Node.js 20 or newer from nodejs.org. The LTS download is fine.

You do not need to run npm install; this project has no third-party libraries.

Start the Server

Open a terminal in this folder and run:

npm start

You should see:

MCP Joke Button server listening on http://127.0.0.1:8787/mcp
Preview the widget shell at http://127.0.0.1:8787/preview

Leave that terminal open while you test.

MCP requests are logged by method while the server is running. For an interactive app render, the log should include a successful UI resource read similar to:

[mcp] request method=resources/read name=ui://joke-button/app.html
[mcp] response method=resources/read status=200

Set MCP_LOG_REQUESTS=false if you want to disable these development logs.

Heroku Deployment

The joke-button Heroku app is deployed at:

https://joke-button-31cddc4bc964.herokuapp.com

Its MCP endpoint is:

https://joke-button-31cddc4bc964.herokuapp.com/mcp

Deploy the current branch with:

git push heroku HEAD:main

Quick Local Check

Open this address in a browser:

http://127.0.0.1:8787/preview

This only previews the button's appearance. The button can ask the AI for a joke only when it is rendered inside an MCP Apps-compatible host such as ChatGPT.

Use with ChatGPT Desktop or ChatGPT Web

ChatGPT needs an HTTPS URL for a remote MCP server during development. Keep npm start running, then expose port 8787 with a tunnel tool such as ngrok or Cloudflare Tunnel.

Example with ngrok:

ngrok http 8787

Copy the HTTPS forwarding URL and add /mcp to the end, for example:

https://example.ngrok.app/mcp

Then connect it in ChatGPT:

  1. Open ChatGPT.
  2. Open Settings.
  3. Open Security and login.
  4. Turn on Developer mode if it is not already enabled.
  5. Open Plugins. If you are in the desktop app and do not see it in the sidebar, open https://chatgpt.com/plugins in a browser while signed in to the same account.
  6. Select the plus button to add a developer MCP server connection.
  7. Paste the HTTPS URL ending in /mcp.
  8. Name it Joke Button.
  9. Start a new chat, select the plugin from the More menu, and ask: Show the joke button.
  10. Click Tell a joke.

You do not need a setting named MCP servers for this ChatGPT UI test. That setting is for Codex's local MCP host configuration, not for adding a ChatGPT developer plugin connection.

If Developer mode or the plus button is missing, check that the desktop app is up to date and that your account or workspace allows plugin development.

If the app is working, ChatGPT should receive the button's message and respond with a short joke.

Use with Codex in the ChatGPT Desktop App

Codex can connect to Streamable HTTP MCP servers from the shared MCP settings.

The MCP servers setting appears only on Codex-capable local clients and may not appear in a regular ChatGPT chat settings view. If it is available:

  1. Keep npm start running.
  2. Open the ChatGPT desktop app.
  3. Open Settings, then MCP servers.
  4. Select Add server.
  5. Choose Streamable HTTP.
  6. Name the server joke_button.
  7. Use this URL:
http://127.0.0.1:8787/mcp
  1. Save, then restart when prompted.
  2. In a Codex task, type /mcp to confirm the server is connected.
  3. Ask Codex: Use the Joke Button MCP server.

Codex MCP tool support may show the text fallback rather than rendering the iframe UI, depending on the surface. For the actual one-button UI, use ChatGPT with MCP Apps UI support.

If the setting is not visible, copy the sample configuration from codex-config.example.toml into a trusted project's .codex/config.toml or into your user ~/.codex/config.toml, then restart the ChatGPT desktop app or Codex client.

Useful URLs

  • Health check: http://127.0.0.1:8787/health
  • MCP endpoint: http://127.0.0.1:8787/mcp
  • Widget preview: http://127.0.0.1:8787/preview

Security Notes

The server validates the MCP protocol version and mirrored MCP headers required by the 2026-07-28 Streamable HTTP transport.

For local development, requests without an Origin header are accepted, loopback browser origins are accepted, and common OpenAI host origins are accepted. For another host origin, start the server with:

$env:MCP_ALLOWED_ORIGINS="https://your-host.example"
npm start

Use authentication before exposing a real MCP server that can access private data or perform actions. This sample does neither.

Project Files

  • server.js: dependency-free MCP server
  • public/joke-button.html: MCP App UI widget
  • codex-config.example.toml: sample Codex MCP configuration

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选