Skip to main content
Glama
simen

VICE C64 Emulator MCP Server

by simen

screenshot

Capture the current VICE C64 emulator display as image data with pixel information, dimensions, and palette values for visual debugging and analysis.

Instructions

Capture the current VICE display as image data.

Returns the raw display buffer with:

  • Pixel data (indexed 8-bit palette colors)

  • Display dimensions and visible area

  • Current palette RGB values

The data can be used to understand what's currently on screen visually. For text mode screens, readScreen provides a simpler text representation.

Options:

  • includePalette: Also return the color palette (default: true)

Related tools: readScreen, readVicState

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includePaletteNoInclude palette RGB values (default: true)

Implementation Reference

  • src/index.ts:1530-1583 (registration)
    Registration of the 'screenshot' MCP tool including description, input schema, and handler function.
    server.registerTool(
      "screenshot",
      {
        description: `Capture the current VICE display as image data.
    
    Returns the raw display buffer with:
    - Pixel data (indexed 8-bit palette colors)
    - Display dimensions and visible area
    - Current palette RGB values
    
    The data can be used to understand what's currently on screen visually.
    For text mode screens, readScreen provides a simpler text representation.
    
    Options:
    - includePalette: Also return the color palette (default: true)
    
    Related tools: readScreen, readVicState`,
        inputSchema: z.object({
          includePalette: z.boolean().optional().describe("Include palette RGB values (default: true)"),
        }),
      },
      async (args) => {
        try {
          const display = await client.getDisplay();
    
          const response: Record<string, unknown> = {
            width: display.width,
            height: display.height,
            bitsPerPixel: display.bitsPerPixel,
            visibleArea: {
              offsetX: display.offsetX,
              offsetY: display.offsetY,
              innerWidth: display.innerWidth,
              innerHeight: display.innerHeight,
            },
            pixelCount: display.pixels.length,
            // Return pixels as base64 for efficient transfer
            pixelsBase64: display.pixels.toString("base64"),
          };
    
          if (args.includePalette !== false) {
            const palette = await client.getPalette();
            response.palette = palette;
            response.paletteCount = palette.length;
          }
    
          response.hint = `Display is ${display.width}x${display.height} (visible: ${display.innerWidth}x${display.innerHeight}). Use readScreen() for text mode content.`;
    
          return formatResponse(response);
        } catch (error) {
          return formatError(error as ViceError);
        }
      }
    );
  • The main handler for the 'screenshot' tool. Captures display data via ViceClient.getDisplay(), optionally fetches palette, encodes pixels to base64, and returns formatted response.
    async (args) => {
      try {
        const display = await client.getDisplay();
    
        const response: Record<string, unknown> = {
          width: display.width,
          height: display.height,
          bitsPerPixel: display.bitsPerPixel,
          visibleArea: {
            offsetX: display.offsetX,
            offsetY: display.offsetY,
            innerWidth: display.innerWidth,
            innerHeight: display.innerHeight,
          },
          pixelCount: display.pixels.length,
          // Return pixels as base64 for efficient transfer
          pixelsBase64: display.pixels.toString("base64"),
        };
    
        if (args.includePalette !== false) {
          const palette = await client.getPalette();
          response.palette = palette;
          response.paletteCount = palette.length;
        }
    
        response.hint = `Display is ${display.width}x${display.height} (visible: ${display.innerWidth}x${display.innerHeight}). Use readScreen() for text mode content.`;
    
        return formatResponse(response);
      } catch (error) {
        return formatError(error as ViceError);
      }
    }
  • Input schema for the 'screenshot' tool using Zod, defining optional 'includePalette' boolean parameter.
    inputSchema: z.object({
      includePalette: z.boolean().optional().describe("Include palette RGB values (default: true)"),
    }),
  • ViceClient.getDisplay() method: sends DisplayGet command to VICE binary monitor, parses response to extract display buffer (screenshot pixels), dimensions, and metadata.
    async getDisplay(useVicii = true): Promise<{
      width: number;
      height: number;
      bitsPerPixel: number;
      offsetX: number;
      offsetY: number;
      innerWidth: number;
      innerHeight: number;
      pixels: Buffer;
    }> {
      // Ensure VICE is stopped before display capture
      await this.ensureStopped();
    
      // Body: useVicii(1) + format(1)
      // Format: 0 = indexed 8-bit
      const body = Buffer.alloc(2);
      body[0] = useVicii ? 1 : 0;
      body[1] = 0; // 8-bit indexed
    
      // Response type is 0x84 (same as command)
      const response = await this.sendCommand(Command.DisplayGet, body, ResponseType.DisplayGet);
    
      // Parse response per VICE docs:
      // FL(4) + DW(2) + DH(2) + XO(2) + YO(2) + IW(2) + IH(2) + BP(1) + BL(4) + BD(BL)
      // FL = length of fields before display buffer (should be 17)
      // const fieldsLength = response.body.readUInt32LE(0); // Not used but documented
      const width = response.body.readUInt16LE(4);          // DW - debug width
      const height = response.body.readUInt16LE(6);         // DH - debug height
      const offsetX = response.body.readUInt16LE(8);        // XO - x offset
      const offsetY = response.body.readUInt16LE(10);       // YO - y offset
      const innerWidth = response.body.readUInt16LE(12);    // IW - inner width
      const innerHeight = response.body.readUInt16LE(14);   // IH - inner height
      const bitsPerPixel = response.body[16];               // BP - bits per pixel
      const bufferLength = response.body.readUInt32LE(17);  // BL - buffer length
      const pixels = response.body.subarray(21, 21 + bufferLength); // BD - display buffer
    
      return {
        width,
        height,
        bitsPerPixel,
        offsetX,
        offsetY,
        innerWidth,
        innerHeight,
        pixels,
      };
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool returns ('raw display buffer' with pixel data, dimensions, visible area, palette values) and its purpose ('to understand what's currently on screen visually'). However, it doesn't mention potential side effects, performance characteristics, or error conditions, which would be helpful for a complete behavioral picture.

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 well-structured and front-loaded with the core purpose. Each sentence adds value: the first states what it does, the second details the return data, the third explains usage context, and the fourth covers the parameter. There's no wasted text, and information is presented in a logical flow.

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

Completeness4/5

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

Given no annotations and no output schema, the description does a good job explaining the tool's behavior and output. It covers the purpose, return data structure, usage context, and parameter semantics. However, it doesn't describe potential limitations (e.g., screen capture timing, memory usage) or error cases, leaving some gaps in completeness.

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

Parameters4/5

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

Schema description coverage is 100%, so the schema already documents the single parameter. The description adds value by explaining the parameter's purpose ('Also return the color palette') and providing the default value ('default: true'), which enhances understanding beyond the schema's basic documentation.

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 ('Capture'), target resource ('current VICE display'), and output format ('as image data'). It distinguishes from sibling readScreen by explaining that readScreen provides 'a simpler text representation' for text mode screens, making the differentiation explicit.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives: 'For text mode screens, readScreen provides a simpler text representation.' It also mentions 'Related tools: readScreen, readVicState' to indicate alternatives, giving clear context for tool selection.

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/simen/vice-mcp'

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