Skip to main content
Glama

press_down

Simulate pressing the DOWN button on a GameBoy via the MCP GameBoy Server, allowing precise control with customizable duration in frames for accurate emulation interactions.

Instructions

Press the DOWN button on the GameBoy

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
duration_framesNoNumber of frames to hold the button

Implementation Reference

  • src/tools.ts:21-37 (registration)
    Dynamic registration of all press_XXX tools including 'press_down' (for GameBoyButton.DOWN). Defines input schema for duration_frames and the execution handler function that calls emulatorService.pressButton(button, duration_frames) and returns the screen image.
    Object.values(GameBoyButton).forEach(button => {
      server.tool(
        `press_${button.toLowerCase()}`,
        `Press the ${button} button on the GameBoy`,
        {
          duration_frames: z.number().int().positive().optional().default(1).describe('Number of frames to hold the button').default(25)
        },
        async ({ duration_frames }): Promise<CallToolResult> => {
          // Press the button using the service (advances one frame)
          emulatorService.pressButton(button, duration_frames);
    
          // Return the current screen using the service
          const screen = emulatorService.getScreen();
          return { content: [screen] };
        }
      );
    });
  • EmulatorService.pressButton - delegate method called directly from the tool handler. Delegates to GameBoyEmulator.pressButton and returns screen.
    pressButton(button: GameBoyButton, durationFrames: number): ImageContent {
      log.debug(`Pressing button: ${button}`);
      if (!this.isRomLoaded()) {
        log.warn('Attempted to press button with no ROM loaded');
        throw new Error('No ROM loaded');
      }
      this.emulator.pressButton(button, durationFrames); // This advances one frame
      return this.getScreen();
    }
  • Core implementation in GameBoyEmulator.pressButton: maps DOWN to Gameboy.KEYMAP.DOWN, presses the key for durationFrames frames via serverboy library, advances extra frame.
    public pressButton(button: GameBoyButton, durationFrames: number = 1): void {
      if (!this.romLoaded) {
        throw new Error('No ROM loaded');
      }
    
      // Map our button enum to serverboy's keymap
      const buttonMap: Record<GameBoyButton, number> = {
        [GameBoyButton.UP]: Gameboy.KEYMAP.UP,
        [GameBoyButton.DOWN]: Gameboy.KEYMAP.DOWN,
        [GameBoyButton.LEFT]: Gameboy.KEYMAP.LEFT,
        [GameBoyButton.RIGHT]: Gameboy.KEYMAP.RIGHT,
        [GameBoyButton.A]: Gameboy.KEYMAP.A,
        [GameBoyButton.B]: Gameboy.KEYMAP.B,
        [GameBoyButton.START]: Gameboy.KEYMAP.START,
        [GameBoyButton.SELECT]: Gameboy.KEYMAP.SELECT
      };
    
      for (let i=0; i < durationFrames; i++) {
        this.gameboy.pressKeys([buttonMap[button]]);
        this.gameboy.doFrame();
      }
    
      // for now: advance one frame so we dont "hold" the button all the time.
      this.gameboy.doFrame();
    }
  • Invocation of registerGameBoyTools in createGameBoyServer, which registers the press_down tool.
    // Register GameBoy tools
    registerGameBoyTools(server, emulatorService); // Pass emulatorService
  • Input schema for press_down tool: optional duration_frames (number of frames to hold button down).
    {
      duration_frames: z.number().int().positive().optional().default(1).describe('Number of frames to hold the button').default(25)
    },
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 action but does not explain what 'Press' entails (e.g., is it a tap, hold, or toggle?), potential side effects on the GameBoy state, or any constraints like rate limits or prerequisites. This leaves significant gaps in understanding the tool's behavior.

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 that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, with zero waste, making it easy to understand at a glance.

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

Completeness3/5

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

Given the tool's low complexity (one optional parameter) and no output schema, the description is minimally complete but lacks depth. It covers the basic action but does not address behavioral aspects like how the press interacts with the GameBoy or what to expect after invocation, leaving room for improvement in context.

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

Parameters3/5

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

The input schema has 100% description coverage, with the parameter 'duration_frames' clearly documented in the schema. The description does not add any meaning beyond what the schema provides, as it mentions no parameters. With high schema coverage, the baseline score of 3 is appropriate.

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

Purpose5/5

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

The description clearly states the specific action ('Press') and target resource ('DOWN button on the GameBoy'), distinguishing it from sibling tools like press_a, press_b, press_left, press_right, press_up, press_select, and press_start. It precisely identifies what the tool does without ambiguity.

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

Usage Guidelines3/5

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

The description implies usage in the context of GameBoy button pressing, but does not explicitly state when to use this tool versus alternatives like press_up or press_left. It provides basic context but lacks guidance on exclusions or specific scenarios for choosing this tool over others.

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

Related 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/mario-andreschak/mcp-gameboy'

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