口袋妖怪MCP服务器
模型上下文协议(MCP)服务器,为AI模型提供口袋妖怪数据资源和战斗模拟工具。
特性
🎯 口袋妖怪数据资源
- 完整的口袋妖怪数据库,包括基本统计数据(生命值、攻击、防御等)
- 类型信息(火、水、电等)
- 能力和动作
- 进化信息
- 类型有效性图
⚔️ 作战模拟工具
- 实时口袋妖怪战斗模拟
- 类型有效性计算
- 状态效果(烧伤、中毒、瘫痪、睡眠)
- 具有详细日志的回合制战斗系统
- 基于口袋妖怪属性的伤害计算
文件结构
pokemon-mcp-server/
├── pokemon_server.py # Main MCP server file
├── requirements.txt # Python dependencies
├── setup.py # Package setup
├── config.json # MCP configuration
├── README.md # This file
├── tests/ # Test files
│ └── test_pokemon.py
└── examples/ # Usage examples
└── example_usage.pyVS代码设置
1.创建项目目录
mkdir pokemon-mcp-server
cd pokemon-mcp-server2.创建虚拟环境
python -m venv pokemon-env
# Windows
pokemon-env\Scripts\activate
# macOS/Linux
source pokemon-env/bin/activate3.安装依赖项
pip install -r requirements.txt4.环境变量(可选)
创建一个 .env 文件:
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here
GOOGLE_API_KEY=your_google_key_here可用的口袋妖怪
数据库中的当前口袋妖怪:
- 皮卡丘 (电气)
- 查里扎德 (火/飞)
- 水箭龟 (水)
- 妙蛙花 (草/毒药)
- 耿鬼 (鬼/毒)
- 富迪 (心理学)
MCP资源
1. pokemon://database/all
完整的口袋妖怪数据库,包含所有统计数据和信息。
2. pokemon://database/moves
所有可用的动作都具有力量、准确性和效果。
3. pokemon://types/effectiveness
键入战斗计算的效能乘数。
4.公共数据集支持的资源(PokeAPI)
pokemon://public/pokemon/{name}:原始PokeAPIpokemon实体(属性、类型、能力、移动)pokemon://public/move/{name}:原始PokeAPImove实体(力量、准确性、效果)pokemon://public/species/{name}:原始PokeAPIpokemon-species实体(进化链元数据)
笔记:
- 这些端点从以下位置获取实时数据
https://pokeapi.co/api/v2具有轻量级的内存缓存。 - 它们是可选的,不影响离线测试;如果网络不可用,核心资源仍然可以工作。
MCP工具
1. get_pokemon_info
获取特定口袋妖怪的详细信息。
{
"name": "pikachu"
}2. battle_simulation
模拟两个口袋妖怪之间的战斗。
{
"pokemon1": "pikachu",
"pokemon2": "charizard"
}3. compare_pokemon
比较两个口袋妖怪之间的统计数据。
{
"pokemon1": "pikachu",
"pokemon2": "alakazam"
}LLM如何查询资源(MCP示例)
列出资源
resources = await server.list_resources()
print([r.uri for r in resources])读取本地数据库(为LLM消费而构建)
data = await server.read_resource("pokemon://database/all")
pokemon_list = json.loads(data)读取公共数据集(PokeAPI)
raw = await server.read_resource("pokemon://public/pokemon/pikachu")
payload = json.loads(raw)运行服务器
方法1:直接使用Python
python pokemon_server.py方法2:使用MCP客户端
# Install MCP client first
pip install mcp
# Run server
mcp run config.json方法三:开发模式
# Install in development mode
pip install -e .
# Run server
pokemon-mcp-server作战系统功能
⚡ 状态影响
- 燃烧:每回合造成1/16点气血伤害
- 毒药:每回合造成1/8点气血伤害
- 麻痹:有25%的机会跳过转弯
- 睡眠:口袋妖怪醒来后才能移动
🎯 类型有效性
- 超级有效(2倍伤害)
- 正常有效(1x损坏)
- 效果不佳(0.5倍伤害)
- 无影响(0x损坏)
📊 损伤计算
- 基于口袋妖怪等级、统计数据和移动能力
- 包括STAB(同类攻击奖金)
- 随机损伤方差(85%-100%)
- 暴击几率
示例用法
import asyncio
import json
from pokemon_server import pokemon_data, battle_simulator
# Get Pokemon info
pikachu = pokemon_data.get_pokemon("pikachu")
print(f"Pikachu HP: {pikachu.hp}")
# Simulate battle
result = battle_simulator.simulate_battle("pikachu", "charizard")
print(f"Winner: {result['winner']}")
print("Battle Log:")
for log in result['battle_log']:
print(log)VS代码扩展推荐
- python -Python语言支持
- Python文档字符串生成器 -自动生成文档字符串
- GitLens -Git增压
- 迅雷客户端 -API测试
- 对象符号 -JSON文件支持
开发命令
# Format code
black pokemon_server.py
# Lint code
flake8 pokemon_server.py
# Run tests
pytest tests/
# Type checking
mypy pokemon_server.py扩展服务器
添加新的口袋妖怪
new_pokemon = Pokemon(
name="Snorlax",
hp=160, attack=110, defense=65,
sp_attack=65, sp_defense=110, speed=30,
type1="Normal",
abilities=["Immunity", "Thick Fat"],
moves=["Body Slam", "Rest", "Sleep Talk", "Earthquake"]
)
pokemon_data.pokemon_db["snorlax"] = new_pokemon添加新动作
new_move = Move(
name="Thunder",
type="Electric",
power=110,
accuracy=70,
pp=10,
status_effect="paralysis"
)
pokemon_data.moves_db["thunder"] = new_moveAPI集成(可选)
如果你想添加人工智能功能:
import openai
import anthropic
import google.generativeai as genai
# Configure APIs
openai.api_key = "your-openai-key"
anthropic_client = anthropic.Anthropic(api_key="your-anthropic-key")
genai.configure(api_key="your-google-key")故障排除
常见问题
- 导入错误:确保安装了所有依赖项
pip install -r requirements.txt- 未找到口袋妖怪:查看可用的口袋妖怪列表
available = [p.name for p in pokemon_data.get_all_pokemon()]
print(available)- MCP连接问题:验证config.json的格式是否正确
调试模式
export DEBUG=1
python pokemon_server.py贡献
- 分叉存储库
- 创建特征分支(
git checkout -b feature/amazing-feature) - 提交更改(
git commit -m 'Add amazing feature') - 推送到分支(
git push origin feature/amazing-feature) - 打开拉取请求
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
联系
你的名字your.email@example.com
项目链接:
