pokemon_Mcp-server

shailendra31888/pokemon_Mcp-server

3.2

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.

This project implements a comprehensive MCP server that provides AI models with access to Pokémon data and battle simulation capabilities.

Tools
1
Resources
0
Prompts
0

🚀 Pokémon MCP Server — Data Resource + Battle Simulation Tool

🌟 Overview

This project implements a comprehensive MCP (Model Context Protocol) server that provides AI models with access to three powerful capabilities:

1. 🐾 Pokémon Data Resource – A resource that exposes comprehensive Pokémon data from the public PokéAPI (https://pokeapi.co/), including stats, types, abilities, moves, and evolution chains.

2. ⚔️ Battle Simulation Tool – An advanced tool that simulates realistic battles between any two Pokémon, featuring type effectiveness, stats-based damage calculations, turn order, and multiple status effects.

3. 🎮 Interactive Web Demo – A beautiful Streamlit web interface that showcases all features with high-quality Pokémon images, interactive battle simulation, and detailed analytics.

This server acts as a bridge between AI and the Pokémon world, enabling LLMs to both retrieve comprehensive knowledge and interactively simulate battles with full combat mechanics.

🐾 Part 1: Pokémon Data Resource

✨ Implementation Features

  • 🌐 PokéAPI Integration: Connects to the public PokéAPI (https://pokeapi.co/) with robust error handling and retry logic
  • 📊 Comprehensive Data: Exposes detailed Pokémon information including:
    • Base Stats: HP, Attack, Defense, Special Attack, Special Defense, Speed
    • Types: Fire, Water, Grass, Electric, and all 18 Pokémon types
    • Abilities: All Pokémon abilities with proper formatting
    • Moves Database: Available moves with power, accuracy, type, damage class, and detailed effect descriptions
    • Evolution Chains: Complete evolution sequences with proper ordering
    • Physical Data: Height, weight, and Pokédex ID

🔧 MCP Resource Implementation

  • Resource URI: pokemon://{name} (e.g., pokemon://charizard)
  • Response Format: Structured JSON with all Pokémon data
  • MCP Compliance: Follows MCP resource design patterns for seamless LLM integration
  • Caching: Efficient data retrieval with built-in retry mechanisms
  • Error Handling: Graceful handling of invalid Pokémon names and network issues

📦 Deliverables

  • ✅ Complete MCP server implementation with Pokémon data resource
  • ✅ Comprehensive documentation with setup and usage instructions
  • ✅ Robust test suite for validation (test_part1.py)
  • ✅ Interactive web demo for showcasing capabilities (streamlit_demo.py)

⚔️ Part 2: Battle Simulation Tool

🎯 Advanced Battle Mechanics

  • Tool Signature: simulate_battle(pokemon_a, pokemon_b, max_turns=100, seed=None)
  • Comprehensive Combat System:
    • 🔥 Type Effectiveness: Complete 18-type effectiveness chart with accurate multipliers
    • 💪 Damage Calculations: Pokémon-style damage formula using Attack, Defense, and move power
    • ⚡ Turn Order: Speed-based turn determination with proper sorting
    • 🎲 Randomization: Seed support for reproducible battles and testing

🌟 Status Effects System

  • 🔥 Burn: 10% HP damage per turn + visual indicators
  • ☠️ Poison: 12% HP damage per turn with escalating effects
  • ⚡ Paralysis: 25% chance to skip turn + movement restrictions
  • 🧠 Smart Status Inference: Automatic status application based on move names
  • 📊 Status Tracking: Persistent effects throughout battle duration

🎮 Battle Features

  • 📜 Detailed Battle Logs: Turn-by-turn action descriptions with outcome details
  • 🏆 Winner Determination: First to faint or highest HP after max turns
  • 💥 Effectiveness Messaging: "Super effective!", "Not very effective...", "No effect!"
  • 🎯 Move Filtering: Only damaging moves used in battle (no status-only moves)
  • ⚖️ Balanced Damage: Carefully tuned to prevent one-shot eliminations

🔧 MCP Tool Implementation

  • MCP Integration: Fully compliant MCP tool specification
  • JSON Response Format:
{
  "winner": "blastoise",
  "log": [
    "--- Turn 1 ---",
    "charizard used fire-punch → blastoise lost 14 HP!",
    "It's not very effective...",
    "blastoise is now affected by burn!",
    "--- Turn 2 ---",
    "blastoise is hurt by its burn (7 HP)!",
    "blastoise used hydro-pump → charizard lost 28 HP!",
    "It's super effective!",
    "charizard fainted!"
  ]
}

📦 Enhanced Deliverables

  • ✅ Production-ready battle simulation tool with MCP compliance
  • ✅ Comprehensive type effectiveness system (all 18 types)
  • ✅ Multiple status effects with realistic mechanics
  • ✅ Detailed battle logging with effectiveness indicators
  • ✅ Interactive web demo with visual battle representation
  • ✅ Example usage patterns and LLM integration guides

🎮 Part 3: Interactive Web Demo

🌟 Streamlit Web Interface Features

  • 🖼️ High-Quality Images: Official Pokémon artwork from PokéAPI sprites repository
  • 📊 Interactive Stats Display: Visual progress bars and detailed stat breakdowns
  • 🥊 Battle Arena: Real-time battle simulation with visual feedback
  • 📱 Responsive Design: Clean, modern interface with tabs and organized layout
  • 🎨 Rich UI Elements: Emojis, animations, and celebration effects

🎯 Demo Capabilities

  • 26 Popular Pokémon: Curated selection from multiple generations
  • Visual Battle Logs: Color-coded effectiveness indicators and status effects
  • Battle Analytics: Turn counts, effectiveness statistics, and performance metrics
  • Reproducible Battles: Seed control for consistent testing and demonstration

🚀 Available Pokémon

Generation 1: Pikachu, Charizard, Blastoise, Venusaur, Alakazam, Machamp, Gengar, Dragonite, Mewtwo, Mew Generation 2: Typhlosion, Feraligatr, Ampharos, Tyranitar
Generation 3: Blaziken, Swampert, Gardevoir, Metagross Generation 4: Garchomp, Lucario, Dialga, Palkia, Arceus Generation 5: Serperior, Emboar, Samurott

🛠️ Installation & Setup

📋 Requirements

  • Python 3.10+ (recommended: Python 3.12)
  • Internet connection (for PokéAPI access)
  • Virtual environment (strongly recommended)

⚙️ Setup Instructions

# Clone or navigate to project directory
cd pokemon-mcp-server

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install all dependencies
pip install -r requirements.txt

2. 🎮 Launch Interactive Web Demo

# Start the Streamlit web interface
streamlit run streamlit_demo.py

This will:

  • 🌐 Open your browser automatically to http://localhost:8501
  • 🖼️ Display beautiful Pokémon images with detailed stats
  • ⚔️ Enable interactive battles between any two Pokémon
  • 📊 Show real-time battle logs with effectiveness indicators
  • 🎯 Provide battle analytics and performance metrics

3. 🖥️ Run MCP Server

# Start the MCP server (stdio mode)
python -m pkmon_core.server

The server runs in stdio mode and waits for MCP client connections. Use Ctrl+C to stop.

4. 🔧 Manual Function Testing

# Test individual functions
python -c "
from pkmon_core.server import get_pokemon, simulate_battle
import json

# Test Pokémon resource
print('=== POKÉMON RESOURCE TEST ===')
data = get_pokemon('charizard')
pokemon = json.loads(data)
print(f'Name: {pokemon[\"name\"]}')
print(f'Types: {pokemon[\"types\"]}')
print(f'HP: {pokemon[\"stats\"][\"hp\"]}')

# Test battle simulation
print('\n=== BATTLE SIMULATION TEST ===')
result = simulate_battle('charizard', 'blastoise', seed=42, max_turns=10)
print(f'Winner: {result[\"winner\"]}')
print('Sample battle log:')
for line in result['log'][:5]:
    print(f'  {line}')
"

📚 Usage Examples

🔗 MCP Client Integration

Configure your MCP client (like Claude Desktop) to connect:

{
  "mcpServers": {
    "pokemon": {
      "command": "python",
      "args": ["-m", "pkmon_core.server"],
      "cwd": "/path/to/pokemon-mcp-server"
    }
  }
}

🐾 Resource Usage

Resource: pokemon://charizard
Resource: pokemon://pikachu
Resource: pokemon://mewtwo

⚔️ Tool Usage

{
  "tool": "simulate_battle",
  "parameters": {
    "pokemon_a": "charizard",
    "pokemon_b": "blastoise",
    "seed": 42,
    "max_turns": 20
  }
}

📖 Documentation

  • 📋 Complete Testing Guide: HOW_TO_TEST.md
  • 💡 LLM Examples: examples/llm_examples.md
  • 🔧 Implementation Details: See source code in pkmon_core/

🎯 Key Features Summary

  • Full MCP Compliance: Resources and tools following MCP specification
  • Comprehensive Pokémon Data: Stats, types, abilities, moves, evolution chains
  • Advanced Battle System: Type effectiveness, status effects, balanced combat
  • Beautiful Web Interface: High-quality images, interactive battles, analytics
  • Robust Testing: Comprehensive test suite with 100% pass rate
  • Production Ready: Error handling, retry logic, performance optimization
  • Extensible Design: Easy to add more Pokémon, moves, or battle mechanics

🏆 Assignment Compliance

This implementation fully meets and exceeds all assignment requirements:

  • Part 1: Pokémon Data Resource with comprehensive PokéAPI integration
  • Part 2: Battle Simulation Tool with advanced combat mechanics
  • MCP Compliance: Proper resource and tool implementations
  • Documentation: Complete setup, usage, and testing instructions
  • Testing: Robust validation of all functionality
  • Bonus Features: Interactive web demo with visual enhancements

🎉 Ready to battle! Your Pokémon MCP Server is production-ready and fully tested!