魂斗罗 MCP Demo
魂斗罗 MCP Demo
本项目遵循 Chris Nager 关于 DOOM MCP App 的架构说明,但使用了一个具有魂斗罗风格横版射击功能的原创占位浏览器游戏。
重点不在于“MCP 创建了一个游戏”,而在于:
MCP 可以返回一个实时应用 UI,而不仅仅是文本或 JSON。在兼容的客户端中,游戏会直接出现在对话界面内。
本项目不包含任何原版魂斗罗的素材、音乐、角色、关卡或 ROM 数据。
主要流程
create_game_session:创建一个内联游戏会话并返回 MCP 应用元数据,以便兼容的主机能够内联渲染游戏。它特意不暴露浏览器回退 URL。get_game_launch_url:为无法内联渲染 MCP 应用的主机创建一个签名的/game/play?token=...URL。/game/play?token=...:浏览器回退路由。该令牌足以启动相同的游戏会话,无需持久化的服务器端会话存储。ui://contra-style/mcp-app.html:内联 MCP 应用资源。它监听create_game_session工具的结果,提取会话,并直接在主机 iframe 中运行游戏。
可选扩展工具:
update-game-state:MCP 应用可以发布分数、生命值 (HP)、位置、敌人、弹药和关卡信息。get-game-state:读取最新状态。suggest-next-move:根据最新状态返回中文游戏建议。
Related MCP server: antics-mcp
运行
npm install
npm run build
npm run serveMCP 端点:
http://localhost:3001/mcp在 Codex 或其他 MCP 主机中使用
要求主机调用:
create_game_session如果主机支持 MCP 应用,它应该从以下地址内联渲染游戏:
ui://contra-style/mcp-app.html这是主要的演示:主机调用工具,工具结果导致一个可玩的游戏 UI 出现在聊天界面中。在此路径中不要显示或打开回退链接。
如果无法进行内联渲染,请调用:
get_game_launch_url然后打开返回的 /game/play?token=... URL。
浏览器回退
执行 npm run build && npm run serve 后,调用 get_game_launch_url 并打开返回的 URL。
仅用于快速 UI 开发:
npm run dev这将在没有签名会话的情况下打开游戏,因此它适用于视觉测试,但不是主要的演示流程。
控制方式
移动:
WASD或方向键射击:
Space或J重启:
R
视频讨论要点
本项目仿照 DOOM MCP App 架构,而非从零开始的游戏开发教程。
核心亮点是:MCP 可以在对话中返回交互式游戏 UI。
主要路径仅限内联;签名的浏览器启动 URL 仅通过
get_game_launch_url暴露。MCP 应用直接在主机 iframe 中运行游戏;它不会在应用内嵌套另一个页面。
真正的 MCP 经验:协议 + UI 资源 + 签名启动流程可以将 Web 功能转化为 AI 客户端原生应用。
验证
npm run check
npm run build
curl -sS -X POST http://localhost:3001/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
--data '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'This server cannot be deployed
Maintenance
Related MCP Connectors
Create instant multiplayer browser-game rooms friends join from a link. No account or app needed.
1Build your own tools from chat: design, test and host them on a shareable MCP server URL.
Build, deploy, and operate hosted web apps on VibeKit (vibekit.bot) from any MCP client.
Create, test and play AI-native games through server-authoritative contracts.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides a fully playable Flappy Bird game that runs inline within AI chat clients. It enables users to launch the game, submit scores, and track session high scores using Model Context Protocol tools.2-

antics-mcpofficial
FlicenseAqualityDmaintenanceEnables AI agents to deploy multiplayer web games as playable URLs with rooms, live state sync, and leaderboards, all through a single tool call.459 npm5-- AlicenseAqualityCmaintenanceEnables any local AI agent to play turn-based games over MCP by exposing reset, observe, and act verbs with structured observations and validated legal actions.6MIT
- AlicenseNot gradedqualityBmaintenanceEnables users to play a fully interactive Snake game directly inside MCP-compatible chat clients by launching a self-contained browser-based game with smooth client-side controls and no per-frame network calls.ISC