口袋妖怪战斗模拟-MCP服务器
该项目是模型上下文协议(MCP)服务器的高级实现,最初是为技术评估而开发的。它提供了一个全面的Pokémon数据资源和一个动态战斗模拟工具,可通过全钉网络应用程序、交互式终端查看器和原始API访问。
✨ 特性
这个项目远远超出了简单的模拟,包括了广泛的高级功能:
- 全栈Web界面:使用FastAPI和Jinja2构建的用户友好的web UI,用于选择口袋妖怪和观看战斗。
- 现场战斗解说:网络界面显示了一个自动滚动的战斗日志,其中包括动画健康栏和神奇宝贝图像。
- 先进战斗引擎:仿真逻辑特征:
- 真实动作:Pokémon从他们从PokéAPI获取的实际移动集中选择。 - 物理攻击与特殊攻击:损坏计算器正确使用 Attack/Defense 对于身体动作和 Special-Attack/Special-Defense 对于特殊动作。 - 类型有效性 和 状态影响 (瘫痪、烧伤、中毒)。
- 玩家与LLM模式:一种特殊的战斗模式,其中一个口袋妖怪由 谷歌双子座法学硕士,它会做出战略动作选择,而其他宝可梦则完全随机地选择动作。
- 交互式终端查看器:对于喜欢命令行的用户,使用以下工具构建的交互式查看器
rich和questionary提供丰富多彩、菜单驱动的战斗体验。 - 核心MCP API:底层的API提供了一个资源来获取任何Pokémon的详细数据。
💻 技术栈
- 后端:Python、FastAPI、Uvicorn
- 前端:HTML、Jinja2、CSS、JavaScript
- 人工智能:Google Gemini API
- 命令行界面:丰富,可疑
- API通信:HTTPX
🚀 设置和安装
项目先决条件
1. Git
这是从GitHub存储库下载(克隆)项目代码所需的版本控制工具。
目的:运行git clone命令。
下载链接:https://git-scm.com/downloads
2. python
这是整个项目所使用的编程语言。
目的:运行FastAPI服务器和所有Python脚本。
下载链接:https://www.python.org/downloads/
重要提示:在Windows上安装时,请确保选中“将Python添加到PATH”的复选框。
按照以下步骤在本地设置和运行项目。
1.克隆存储库
git clone https://github.com/Timex9/mcp-pokemon-server.git
cd mcp-pokemon-server2. Create and Activate Virtual Environment
# For macOS/Linux
python3 -m venv venv
source venv/bin/activate
# For Windows
python -m venv venv
.\venv\Scripts\activate3. Install Dependencies
pip install -r requirements.txt🕹️ How to Use
1. Run the Server
With your virtual environment active, start the FastAPI server from the root project directory:
uvicorn app.main:app --reloadThe server will be running at http://127.0.0.1:8000.
2. Use the Web Interface (Recommended)
This is the primary way to interact with the application.
- Open your web browser and navigate to http://127.0.0.1:8000.
- Select two Pokémon from the dropdowns.
- Choose your battle mode: "Player vs. Player" (a fast, automated simulation) or "Player vs. LLM" (a slower, strategic battle against the AI).
3. Use the Interactive Terminal Viewer
For a command-line experience:
- Make sure the server is running.
- Open a new terminal window, run the following code in new terminal window make sure earlier terminal window is open and server is running.
cd mcp-pokemon-server
pip install -r requirements.txt
python battle_viewer.py- Follow the on-screen menu to select your fighters.# mcp-pokemon-server
