Skip to main content
Glama

check_cover

Calculate cover between attacker and target positions to determine Armor Class and Dexterity save bonuses for combat scenarios.

Instructions

Check cover between attacker and target, returning AC and Dex save bonuses

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attackerYes
targetYes
obstaclesNo
creaturesNo
creaturesProvideCoverNo

Implementation Reference

  • Main handler function for check_cover tool. Computes the highest level of cover between attacker and target positions by checking obstacles and creatures on the line of sight. Returns ASCII-formatted output with AC and Dex save bonuses based on D&D 5e rules (none: +0, half: +2, three-quarters: +5, total: blocked).
    export function checkCover(input: CheckCoverInput): string {
      const content: string[] = [];
    
      const attackerPos: Position = {
        x: input.attacker.x,
        y: input.attacker.y,
        z: input.attacker.z ?? 0,
      };
    
      const targetPos: Position = {
        x: input.target.x,
        y: input.target.y,
        z: input.target.z ?? 0,
      };
    
      // Calculate distance
      const dx = targetPos.x - attackerPos.x;
      const dy = targetPos.y - attackerPos.y;
      const dz = (targetPos.z ?? 0) - (attackerPos.z ?? 0);
      const distance = Math.sqrt(dx * dx + dy * dy + dz * dz) * 5; // Convert to feet
    
      // Build header
      content.push(centerText('COVER CHECK', COVER_DISPLAY_WIDTH));
      content.push('');
      content.push(`Attacker: (${attackerPos.x}, ${attackerPos.y}, ${attackerPos.z ?? 0})`);
      content.push(`Target: (${targetPos.x}, ${targetPos.y}, ${targetPos.z ?? 0})`);
      content.push(`Distance: ${Math.round(distance)} feet`);
      content.push('');
      content.push(BOX.LIGHT.H.repeat(COVER_DISPLAY_WIDTH));
      content.push('');
    
      // Find highest cover level from all obstacles
      let coverLevel: CoverLevel = 'none';
      const coverSources: Array<{ type: string; position: string }> = [];
    
      // Check static obstacles
      const obstacles = input.obstacles || [];
      for (const obstacle of obstacles) {
        // Skip obstacles at the attacker's position
        if (
          obstacle.x === attackerPos.x &&
          obstacle.y === attackerPos.y &&
          (obstacle.z ?? 0) === (attackerPos.z ?? 0)
        ) {
          continue;
        }
    
        const obstacleCover = calculateCoverFromObstacle(obstacle, attackerPos, targetPos);
        if (obstacleCover !== null) {
          coverLevel = determineCoverLevel(coverLevel, obstacleCover);
          if (obstacleCover !== 'none') {
            coverSources.push({
              type: obstacle.type,
              position: `(${obstacle.x}, ${obstacle.y}, ${obstacle.z ?? 0})`,
            });
          }
        }
      }
    
      // Check creature cover
      if (input.creaturesProvideCover && input.creatures) {
        for (const creature of input.creatures) {
          if (isOnLine(attackerPos, targetPos, creature)) {
            const creatureCover = getCreatureCover(creature.size);
            coverLevel = determineCoverLevel(coverLevel, creatureCover);
            if (creatureCover !== 'none') {
              coverSources.push({
                type: `${creature.size} creature`,
                position: `(${creature.x}, ${creature.y}, ${creature.z ?? 0})`,
              });
            }
          }
        }
      }
    
      // Display cover sources if any
      if (coverSources.length > 0) {
        content.push(centerText('COVER SOURCES', COVER_DISPLAY_WIDTH));
        content.push('');
        for (const source of coverSources) {
          content.push(`  ${source.type} at ${source.position}`);
        }
        content.push('');
        content.push(BOX.LIGHT.H.repeat(COVER_DISPLAY_WIDTH));
        content.push('');
      }
    
      // Display result
      content.push(centerText('RESULT', COVER_DISPLAY_WIDTH));
      content.push('');
    
      switch (coverLevel) {
        case 'total':
          content.push('TOTAL COVER');
          content.push('');
          content.push('Target cannot be directly targeted.');
          content.push('No line of effect for attacks or spells.');
          break;
    
        case 'three_quarters':
          content.push('THREE-QUARTERS COVER');
          content.push('');
          content.push(`AC Bonus: +${COVER_BONUSES.three_quarters}`);
          content.push(`Dex Save Bonus: +${COVER_BONUSES.three_quarters}`);
          break;
    
        case 'half':
          content.push('HALF COVER');
          content.push('');
          content.push(`AC Bonus: +${COVER_BONUSES.half}`);
          content.push(`Dex Save Bonus: +${COVER_BONUSES.half}`);
          break;
    
        default:
          content.push('NO COVER');
          content.push('');
          content.push('AC Bonus: +0');
          content.push('Dex Save Bonus: +0');
          break;
      }
    
      return createBox('COVER CHECK', content);
    }
  • Zod input schema for validating check_cover tool arguments, defining attacker/target positions and optional obstacles/creatures.
    export const checkCoverSchema = z.object({
      attacker: CoverPositionSchema,
      target: CoverPositionSchema,
      obstacles: z.array(ObstacleSchema).optional(),
      creatures: z.array(CreatureBlockSchema).optional(),
      creaturesProvideCover: z.boolean().default(false),
    });
  • Registration of check_cover tool in the MCP registry, including name, description, input schema conversion, and wrapper handler that validates input and calls the spatial checkCover function.
    check_cover: {
      name: 'check_cover',
      description: 'Check cover between attacker and target, returning AC and Dex save bonuses',
      inputSchema: toJsonSchema(checkCoverSchema),
      handler: async (args) => {
        try {
          const validated = checkCoverSchema.parse(args);
          const result = checkCover(validated);
          return success(result);
        } catch (err) {
          if (err instanceof z.ZodError) {
            const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ');
            return error(`Validation failed: ${messages}`);
          }
          const message = err instanceof Error ? err.message : String(err);
          return error(message);
        }
      },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns 'AC and Dex save bonuses,' which hints at read-only behavior, but doesn't clarify if it modifies data, requires specific permissions, or has side effects. For a tool with complex inputs and no annotations, this lack of detail on safety, error handling, or output format is a significant gap.

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, efficient sentence: 'Check cover between attacker and target, returning AC and Dex save bonuses.' It is front-loaded with the core purpose and output, with no wasted words. Every part of the sentence contributes essential information, making it highly concise and well-structured.

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?

Given the tool's complexity (5 parameters with nested objects, no output schema, and 0% schema coverage), the description is incomplete. It doesn't explain the return format beyond mentioning 'AC and Dex save bonuses,' nor does it detail how cover is calculated or what the inputs entail. For a spatial analysis tool in a combat system, more context on behavior and parameters is needed for effective use.

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?

Schema description coverage is 0%, meaning parameters like 'attacker,' 'target,' 'obstacles,' 'creatures,' and 'creaturesProvideCover' are undocumented in the schema. The description adds no meaning beyond the tool's purpose, failing to explain what these parameters represent (e.g., coordinate systems, obstacle types, or creature sizes) or how they affect the cover calculation. This leaves key semantics unclear.

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: 'Check cover between attacker and target, returning AC and Dex save bonuses.' It specifies the verb ('check'), resource ('cover'), and output ('AC and Dex save bonuses'), making the function evident. However, it doesn't differentiate from sibling tools like 'check_line_of_sight' or 'calculate_aoe', which might involve similar spatial calculations.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing an existing encounter or character data, or compare it to siblings like 'check_line_of_sight' for different combat calculations. Usage is implied only by the tool's name and description, with no explicit context or exclusions provided.

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/Mnehmos/mnehmos.chatrpg.game'

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