krishna663-wq/pokemon_mcp_server
If you are the rightful owner of pokemon_mcp_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Pokémon Battle Simulation MCP Server provides AI models with access to comprehensive Pokémon data and battle simulation capabilities using the Model Context Protocol.
Pokémon Battle Simulation MCP Server
A Model Context Protocol (MCP) server that provides AI models with access to Pokémon data and battle simulation capabilities.
Features
1. Pokémon Data Resource
- Comprehensive Pokémon information from PokéAPI
- Base stats (HP, Attack, Defense, Special Attack, Special Defense, Speed)
- Types, abilities, and moves
- Evolution information and sprite URLs
- Intelligent caching for improved performance
2. Battle Simulation Tool
- Full battle mechanics implementation
- Type effectiveness calculations
- Damage calculations based on stats and moves
- Turn order determination by Speed stats
- Status effects: Burn, Poison, Paralysis, Sleep
- Detailed battle logs with turn-by-turn breakdown
- Winner determination
Installation
-
Clone or download the project files
-
Install dependencies:
pip install -r requirements.txt -
Run the server:
python pkmon_core/server.pyOr as a module:
python -m pkmon_core.server
Usage
Starting the Server
Run the MCP server:
python pkmon_core/server.py
The server communicates via stdin/stdout following the MCP protocol.
Available Resources
Pokemon Data Resource
- URI:
pokemon://data/search - Description: Access comprehensive Pokémon data
- Usage: Query using the
get_pokemon_datatool
Available Tools
1. get_pokemon_data
Get detailed information about any Pokémon.
Parameters:
name(string): Pokémon name or Pokédex ID
Example:
{
"name": "get_pokemon_data",
"arguments": {
"name": "pikachu"
}
}
Response includes:
- ID and name
- Types (e.g., ["electric"])
- Base stats (HP, Attack, Defense, etc.)
- Abilities
- Available moves with power, accuracy, and effects
- Physical characteristics (height, weight)
- Sprite URL
2. simulate_battle
Simulate a battle between two Pokémon with realistic mechanics.
Parameters:
pokemon1(string): First Pokémon name or IDpokemon2(string): Second Pokémon name or ID
Example:
{
"name": "simulate_battle",
"arguments": {
"pokemon1": "pikachu",
"pokemon2": "charizard"
}
}
Response includes:
- Final HP for both Pokémon
- Winner determination
- Complete battle log with:
- Move usage and damage
- Type effectiveness messages
- Status effect applications
- Turn-by-turn progression
Battle Mechanics
Damage Calculation
- Based on official Pokémon formulas
- Considers attack/defense stats and move power
- Includes type effectiveness multipliers
- STAB (Same Type Attack Bonus) applied
- Random damage variation (85-100%)
Type Effectiveness
- Complete type chart implementation
- Super effective (2x damage)
- Not very effective (0.5x damage)
- No effect (0x damage)
Status Effects
- Burn: Reduces physical move damage by 50%, deals HP/16 damage per turn
- Poison: Deals HP/8 damage per turn
- Paralysis: 25% chance to be unable to move each turn
- Sleep: Pokémon cannot move for 1-3 turns
Turn Order
- Determined by Speed stats
- Faster Pokémon moves first
- Status effects processed at start of each turn
Example Usage
Getting Pokémon Data
# Example LLM query to the server
"Get me information about Charizard"
The server will return comprehensive data including:
- Base stats: HP 78, Attack 84, Defense 78, etc.
- Types: Fire/Flying
- Abilities: Blaze, Solar Power
- Notable moves: Flamethrower, Dragon Pulse, etc.
Battle Simulation
# Example LLM query
"Simulate a battle between Pikachu and Squirtle"
Sample battle output:
Battle begins! pikachu vs squirtle!
pikachu: 35 HP
squirtle: 44 HP
---
Turn 1
pikachu uses thunder-shock! Deals 12 damage to squirtle.
squirtle: 32/44 HP
squirtle uses water-gun! Deals 8 damage to pikachu.
pikachu: 27/35 HP
---
Turn 2
pikachu uses quick-attack! Deals 6 damage to squirtle.
squirtle: 26/44 HP
...
Winner: pikachu!
API Integration
The server uses the PokéAPI to fetch real-time Pokémon data:
- Automatic caching to reduce API calls
- Comprehensive move data including effects
- Official stats and type information
- High-quality sprite images
Architecture
Core Components
- PokemonMCPServer: Main server class handling MCP protocol
- Pokemon Data Models: Type-safe data structures using dataclasses
- Battle Engine: Implements game mechanics and calculations
- API Client: Async HTTP client for PokéAPI integration
Data Flow
- LLM requests Pokémon data or battle simulation
- Server validates request and parameters
- Fetches required data from PokéAPI (with caching)
- Processes battle mechanics if simulating
- Returns structured JSON response
Configuration
Environment Variables
No environment variables required - the server works out of the box.
Customization Options
- Modify
type_effectivenessdictionary for custom type charts - Adjust status effect durations in
apply_status_effect() - Change battle turn limit (default: 50 turns)
- Customize move selection logic in
simulate_battle()
Troubleshooting
Common Issues
-
"Could not find Pokemon" error
- Ensure correct spelling of Pokémon name
- Try using Pokédex ID number instead
- Check PokéAPI availability
-
Network connection errors
- Verify internet connection
- Check if PokéAPI (pokeapi.co) is accessible
- Consider firewall/proxy issues
-
MCP protocol errors
- Ensure MCP library is properly installed
- Check that client supports MCP version 1.0+
- Verify JSON formatting in requests
Performance Notes
- First request for each Pokémon may be slower (API fetch)
- Subsequent requests use cached data for speed
- Battle simulations are computed locally (fast)
Development
Adding New Features
New Status Effects:
- Add to
StatusEffectenum - Implement logic in
process_status_effects() - Add application logic in battle loop
New Battle Mechanics:
- Modify damage calculation in
calculate_damage() - Update battle simulation loop as needed
- Add new parameters to tool schemas
Additional Data Sources:
- Extend
Pokemondataclass - Update
fetch_pokemon_data()method - Modify resource responses
Testing
Test the server using any MCP-compatible client:
# Test Pokemon data retrieval
{
"method": "tools/call",
"params": {
"name": "get_pokemon_data",
"arguments": {"name": "ditto"}
}
}
# Test battle simulation
{
"method": "tools/call",
"params": {
"name": "simulate_battle",
"arguments": {"pokemon1": "mewtwo", "pokemon2": "mew"}
}
}
License
This project is for educational purposes. Pokémon is a trademark of Nintendo/Game Freak/Creatures Inc.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test with multiple Pokémon and battle scenarios
- Submit a pull request
Happy Training, Pokémon Masters! 🎮⚡