Skip to main content
Glama
jpbullalayao

Pokémon VGC Damage Calculator MCP Server

calculateDamage

Calculate battle damage between Pokémon by analyzing stats, abilities, items, moves, and field conditions for strategic planning.

Instructions

Calculates the battle damage between an attacking and a defending Pokémon, considering their stats, abilities, items, and field conditions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attackerYes
defenderYes
moveYes
fieldYes

Implementation Reference

  • Core handler function implementing the calculateDamage tool logic using the @smogon/calc library to compute damage ranges, KO chances, and descriptions.
    export function calculateDamage(request: CalculateDamageRequest): CalculateDamageResponse {
      try {
        // Validate required fields
        if (!request.attacker?.species) {
          throw new Error("Attacker species is required");
        }
        if (!request.defender?.species) {
          throw new Error("Defender species is required");
        }
        if (!request.move?.name) {
          throw new Error("Move name is required");
        }
    
        const attacker = createSmogonPokemon(request.attacker);
        const defender = createSmogonPokemon(request.defender);
        const move = createSmogonMove(request.move);
        const field = createSmogonField(request.field);
    
        const result = calculate(gen, attacker, defender, move, field);
        
        let damageRange: [number, number];
        if (result.damage) {
          if (Array.isArray(result.damage)) {
            const damageArray = result.damage as number[];
            damageRange = [damageArray[0], damageArray[damageArray.length - 1]];
          } else {
            const singleDamage = result.damage as number;
            damageRange = [singleDamage, singleDamage];
          }
        } else {
          damageRange = [0, 0];
        }
    
        return {
          description: result.fullDesc(),
          damage: damageRange,
          koChance: result.kochance().text,
          fullResult: result
        };
      } catch (error) {
        throw new Error(`Calculation failed: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/index.ts:168-178 (registration)
    MCP server registration of the calculateDamage tool in the listTools request handler, including name, description, and input schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'calculateDamage',
            description: 'Calculates the battle damage between an attacking and a defending Pokémon, considering their stats, abilities, items, and field conditions.',
            inputSchema: CALCULATE_DAMAGE_SCHEMA,
          },
        ],
      };
    });
  • Dispatch handler in the MCP callTool request that invokes the calculateDamage function with parsed arguments and formats the response.
    if (name === 'calculateDamage') {
      try {
        const result = calculateDamage(args as unknown as CalculateDamageRequest);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
  • TypeScript type definitions for the input (CalculateDamageRequest) and output (CalculateDamageResponse) of the calculateDamage tool.
    export interface CalculateDamageRequest {
      attacker: Pokemon;
      defender: Pokemon;
      field: Field;
      move: Move;
    }
    
    export interface CalculateDamageResponse {
      description: string;
      damage: [number, number];
      koChance: string;
      fullResult?: any;
    }
  • JSON schema definition for the calculateDamage tool input used in MCP tool registration. Note: excerpt abbreviated; full schema spans detailed properties for Pokemon stats, moves, and field conditions.
    const CALCULATE_DAMAGE_SCHEMA = {
      type: 'object',
      properties: {
        attacker: {
          type: 'object',
          properties: {
            species: { type: 'string', description: 'Name of the Pokémon species (e.g., \'Pikachu\').' },
            level: { type: 'number', default: 50 },
            ability: { type: 'string', description: 'The Pokémon\'s ability (e.g., \'Lightning Rod\').' },
            item: { type: 'string', description: 'The Pokémon\'s held item (e.g., \'Light Ball\').' },
            nature: { type: 'string', description: 'The Pokémon\'s nature (e.g., \'Timid\').' },
            status: { 
              type: 'string', 
              enum: ['', 'psn', 'brn', 'frz', 'par', 'slp'], 
              description: 'e.g., \'brn\' for Burned.' 
            },
            evs: {
              type: 'object',
              properties: {
                hp: { type: 'number' },
                atk: { type: 'number' },
                def: { type: 'number' },
                spa: { type: 'number' },
                spd: { type: 'number' },
                spe: { type: 'number' }
              }
            },
            ivs: {
              type: 'object',
              properties: {
                hp: { type: 'number' },
                atk: { type: 'number' },
                def: { type: 'number' },
                spa: { type: 'number' },
                spd: { type: 'number' },
                spe: { type: 'number' }
              }
            },
            boosts: {
              type: 'object',
              properties: {
                atk: { type: 'number' },
                def: { type: 'number' },
                spa: { type: 'number' },
                spd: { type: 'number' },
                spe: { type: 'number' }
              }
            }
          },
          required: ['species']
        },
        defender: {
          type: 'object',
          properties: {
            species: { type: 'string', description: 'Name of the Pokémon species (e.g., \'Pikachu\').' },
            level: { type: 'number', default: 50 },
            ability: { type: 'string', description: 'The Pokémon\'s ability (e.g., \'Lightning Rod\').' },
            item: { type: 'string', description: 'The Pokémon\'s held item (e.g., \'Light Ball\').' },
            nature: { type: 'string', description: 'The Pokémon\'s nature (e.g., \'Timid\').' },
            status: { 
              type: 'string', 
              enum: ['', 'psn', 'brn', 'frz', 'par', 'slp'], 
              description: 'e.g., \'brn\' for Burned.' 
            },
            evs: {
              type: 'object',
              properties: {
                hp: { type: 'number' },
                atk: { type: 'number' },
                def: { type: 'number' },
                spa: { type: 'number' },
                spd: { type: 'number' },
                spe: { type: 'number' }
              }
            },
            ivs: {
              type: 'object',
              properties: {
                hp: { type: 'number' },
                atk: { type: 'number' },
                def: { type: 'number' },
                spa: { type: 'number' },
                spd: { type: 'number' },
                spe: { type: 'number' }
              }
            },
            boosts: {
              type: 'object',
              properties: {
                atk: { type: 'number' },
                def: { type: 'number' },
                spa: { type: 'number' },
                spd: { type: 'number' },
                spe: { type: 'number' }
              }
            }
          },
          required: ['species']
        },
        move: {
          type: 'object',
          properties: {
            name: { type: 'string', description: 'Name of the move being used (e.g., \'Thunderbolt\').' },
            isCrit: { type: 'boolean', default: false, description: 'Whether the move is a guaranteed critical hit.' }
          },
          required: ['name']
        },
        field: {
          type: 'object',
          properties: {
            gameType: { type: 'string', enum: ['Singles', 'Doubles'], default: 'Singles' },
            weather: { type: 'string', enum: ['', 'Sun', 'Rain', 'Sand', 'Snow'] },
            terrain: { type: 'string', enum: ['', 'Electric', 'Grassy', 'Misty', 'Psychic'] },
            isBeadsOfRuin: { type: 'boolean', default: false },
            isTabletsOfRuin: { type: 'boolean', default: false },
            isSwordOfRuin: { type: 'boolean', default: false },
            isVesselOfRuin: { type: 'boolean', default: false },
            attackerSide: {
              type: 'object',
              properties: {
                isSR: { type: 'boolean', default: false, description: 'Stealth Rock is active.' },
                spikes: { type: 'number', enum: [0, 1, 2, 3], default: 0 },
                isLightScreen: { type: 'boolean', default: false },
                isReflect: { type: 'boolean', default: false }
              }
            },
            defenderSide: {
              type: 'object',
              properties: {
                isSR: { type: 'boolean', default: false, description: 'Stealth Rock is active.' },
                spikes: { type: 'number', enum: [0, 1, 2, 3], default: 0 },
                isLightScreen: { type: 'boolean', default: false },
                isReflect: { type: 'boolean', default: false }
              }
            }
          }
        }
      },
      required: ['attacker', 'defender', 'field', 'move']
    } as const;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions what factors are considered but doesn't explain computational complexity, accuracy limitations, whether it's deterministic, or what the output format looks like. This leaves significant gaps for a complex calculation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently communicates the core functionality without unnecessary words. It's appropriately sized for a tool with this complexity level.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex calculation tool with 4 nested parameters, 0% schema coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain the calculation methodology, output format, error conditions, or provide examples of proper usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and 4 complex parameters (attacker, defender, move, field), the description only vaguely mentions 'stats, abilities, items, and field conditions' without explaining parameter relationships, required data formats, or how these inputs map to the damage calculation. It fails to compensate for the complete lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('calculates') and resource ('battle damage'), and lists key factors considered (stats, abilities, items, field conditions). However, without sibling tools to differentiate from, it cannot achieve a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives, prerequisites, or specific battle scenarios where it's applicable. The description only states what it does, not when it should be invoked.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jpbullalayao/pokemon-vgc-calc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server