宝可梦MCP服务器
一种模型上下文协议(MCP)服务器,为AI模型提供对口袋妖怪数据和战斗模拟功能的访问。包括一个基于Streamlit的MCP检查器,用于视觉测试。
✨ 特性
- 🎮 交互式作战系统 -有详细日志的回合制战斗
- 📊 完整的口袋妖怪数据 -通过PokeAPI获取统计数据、类型、能力和动作
- ⚔️ 战斗模拟 -类型有效性、损伤计算、状态效应
- 🤖 MCP集成 -LLM访问的资源和工具
- 🌐 流线型检查员 -用于测试MCP功能的可视化界面
🚀 快速开始
先决条件
- Python 3.10+
- 互联网连接(适用于PokeAPI)
安装
# Clone the repository
git clone https://github.com/yourusername/pokemon-mcp-server.git
cd pokemon-mcp-server
# Create virtual environment
python -m venv .venv
# Activate (Windows PowerShell)
.\.venv\Scripts\Activate.ps1
# Activate (macOS/Linux)
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt运行服务器
选项1:流线型MCP检查器(推荐)
cd pokemon-mcp-server
streamlit run app.py在以下位置打开可视化界面 http://localhost:8501
选项2:交互式作战系统
python interactive_battle.py选项3:MCP开发模式
mcp dev main.py📋 项目结构
pokemon-mcp-server/ # Streamlit Interface
├── app.py # MCP Inspector UI
├── server_logic.py # MCP resources & tools
└── requirements.txt # Dependencies
pokemon-mcp-server-improved/ # Full MCP Server
├── src/pokemon_mcp/
│ ├── server.py # MCP server implementation
│ ├── pokemon_data.py # PokeAPI integration
│ ├── battle_mechanics.py # Battle simulation engine
│ └── models.py # Pydantic data models
├── main.py # Server entry point
├── interactive_battle.py # Interactive battle CLI
├── test_server.py # Basic tests
└── test_assignment_requirements.py # Compliance tests🔧 MCP资源和工具
资源
| 资源URI | 描述 |
|---|---|
pokemon://{name} | 获取全面的口袋妖怪数据 |
pokemon://search/{query} | 按名称搜索宝可梦 |
pokemon://types/{type} | 获取类型有效性信息 |
工具
| 工具 | 说明 |
|---|---|
simulate_battle(pokemon1, pokemon2) | 模拟两个宝可梦之间的战斗 |
get_evolution_chain(pokemon) | 获取进化信息 |
⚔️ 战斗力学
- 类型有效性:完整的18型矩阵(2x、0.5x、0x乘数)
- 伤害公式:基于攻击/防御统计数据和移动能力
- 翻转顺序:由速度统计决定
- 状态效果:瘫痪、烧伤、中毒、睡眠、冰冻
🧪 测试
# Basic functionality test
python test_server.py
# Assignment requirements compliance
python test_assignment_requirements.py
# Quick demo
python quick_demo.py🌐 Streamlit云部署
- 推一下
pokemon-mcp-server/文件夹到GitHub - 首选 share.streamlit.io
- 点击 新应用程序 → 选择存储库→ 部署
🔌 Claude桌面集成
添加到您的Claude Desktop配置中:
{
"mcpServers": {
"pokemon": {
"command": "python",
"args": ["path/to/main.py"]
}
}
}📖 示例用法
LLM资源查询
Resource: pokemon://pikachu
Returns:
- Base stats (HP, Attack, Defense, Sp.Atk, Sp.Def, Speed)
- Types, abilities, moves
- Evolution information战斗模拟
{
"tool": "simulate_battle",
"arguments": {
"pokemon1_name": "charizard",
"pokemon2_name": "blastoise"
}
}🛠️ 故障排除
| 问题 | 解决方案 |
|---|---|
| 未找到模块 | pip install -r requirements.txt |
| PokeAPI错误 | 检查互联网连接 |
| 服务器挂起 | 正常-MCP等待stdin。改用测试脚本 |
📝 许可证
MIT许可证-可以自由使用和修改。
______________________________________________________________________
准备好战斗了吗? 从...开始 python interactive_battle.py 或 streamlit run app.py 🏆
👨💻 作者
Arya Yadav
Bennett University
📧 Email | 🐙 GitHub
______________________________________________________________________
