Skip to main content
Glama
code-cheers

魂斗罗 MCP Demo

by code-cheers

魂斗罗 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 serve

MCP 端点:

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 或方向键

  • 射击:SpaceJ

  • 重启: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":{}}'

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides 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.
    1
    -
  • A
    license
    A
    quality
    B
    maintenance
    Enables AI agents to deploy multiplayer web games as playable URLs with rooms, live state sync, and leaderboards, all through a single tool call.
    4
    96
    5
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    MCP server that lets LLMs play a terminal Space Invaders game with the SUPERHOT rule: time only moves when the agent moves. Exposes tools to start a game, inspect the board state, and act by holding left/right/fire for N frames.
    13
    1
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/code-cheers/contra-mcp-app'

If you have feedback or need assistance with the MCP directory API, please join our Discord server