Skip to main content
Glama
simen

VICE C64 Emulator MCP Server

by simen

connect

Establish a connection to a running VICE C64 emulator instance for debugging operations using the binary monitor protocol.

Instructions

Connect to a running VICE emulator instance via the binary monitor protocol.

VICE must be started with the binary monitor enabled: x64sc -binarymonitor -binarymonitoraddress ip4://127.0.0.1:6502

Default connection: 127.0.0.1:6502

Use this first before any debugging operations. Connection persists until disconnect() is called or VICE closes.

Related tools: status, disconnect

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostNoVICE host address (default: 127.0.0.1)
portNoVICE binary monitor port (default: 6502)

Implementation Reference

  • src/index.ts:127-170 (registration)
    MCP tool registration for 'connect', including schema, description, and inline handler function that invokes ViceClient.connect(host, port) and formats response with connection state.
    server.registerTool(
      "connect",
      {
        description: `Connect to a running VICE emulator instance via the binary monitor protocol.
    
    VICE must be started with the binary monitor enabled:
      x64sc -binarymonitor -binarymonitoraddress ip4://127.0.0.1:6502
    
    Default connection: 127.0.0.1:6502
    
    Use this first before any debugging operations. Connection persists until disconnect() is called or VICE closes.
    
    Related tools: status, disconnect`,
        inputSchema: z.object({
          host: z
            .string()
            .optional()
            .describe("VICE host address (default: 127.0.0.1)"),
          port: z
            .number()
            .min(1)
            .max(65535)
            .optional()
            .describe("VICE binary monitor port (default: 6502)"),
        }),
      },
      async (args) => {
        const host = args.host || "127.0.0.1";
        const port = args.port || 6502;
    
        try {
          await client.connect(host, port);
          return formatResponse({
            connected: true,
            host,
            port,
            message: `Successfully connected to VICE at ${host}:${port}`,
            hint: "Connection established. You can now use readMemory, getRegisters, and other debugging tools.",
          });
        } catch (error) {
          return formatError(error as ViceError);
        }
      }
    );
  • The handler function for the 'connect' tool. Parses args for host/port, calls the underlying ViceClient.connect(), formats success/error response with _meta state.
    async (args) => {
      const host = args.host || "127.0.0.1";
      const port = args.port || 6502;
    
      try {
        await client.connect(host, port);
        return formatResponse({
          connected: true,
          host,
          port,
          message: `Successfully connected to VICE at ${host}:${port}`,
          hint: "Connection established. You can now use readMemory, getRegisters, and other debugging tools.",
        });
      } catch (error) {
        return formatError(error as ViceError);
      }
    }
  • Zod schema defining optional 'host' (string) and 'port' (number 1-65535) inputs for the connect tool.
    inputSchema: z.object({
      host: z
        .string()
        .optional()
        .describe("VICE host address (default: 127.0.0.1)"),
      port: z
        .number()
        .min(1)
        .max(65535)
        .optional()
        .describe("VICE binary monitor port (default: 6502)"),
    }),
  • ViceClient.connect() method: Establishes TCP socket connection to VICE binary monitor server on given host/port, sets up event handlers for data/error/close/connect, updates connection state, rejects pending requests on close.
    async connect(host = "127.0.0.1", port = 6502): Promise<void> {
      if (this.socket) {
        throw this.makeError(
          "ALREADY_CONNECTED",
          "Already connected to VICE",
          "Use disconnect() first if you want to reconnect"
        );
      }
    
      return new Promise((resolve, reject) => {
        this.socket = new Socket();
    
        const timeout = setTimeout(() => {
          this.socket?.destroy();
          this.socket = null;
          reject(
            this.makeError(
              "CONNECTION_TIMEOUT",
              `Connection to ${host}:${port} timed out after 5 seconds`,
              "Ensure VICE is running with -binarymonitor flag: x64sc -binarymonitor -binarymonitoraddress ip4://127.0.0.1:6502"
            )
          );
        }, 5000);
    
        this.socket.on("connect", () => {
          clearTimeout(timeout);
          this.state = { connected: true, host, port, running: true };
          resolve();
        });
    
        this.socket.on("error", (err) => {
          clearTimeout(timeout);
          this.socket?.destroy();
          this.socket = null;
          this.state.connected = false;
          reject(
            this.makeError(
              "CONNECTION_FAILED",
              `Failed to connect to ${host}:${port}: ${err.message}`,
              "Ensure VICE is running with -binarymonitor flag: x64sc -binarymonitor -binarymonitoraddress ip4://127.0.0.1:6502"
            )
          );
        });
    
        this.socket.on("close", () => {
          this.state.connected = false;
          this.socket = null;
          // Reject all pending requests
          for (const [, { reject: rejectFn }] of this.pendingRequests) {
            rejectFn(
              this.makeError(
                "CONNECTION_CLOSED",
                "Connection to VICE closed unexpectedly",
                "VICE may have been closed or crashed. Try reconnecting."
              )
            );
          }
          this.pendingRequests.clear();
        });
    
        this.socket.on("data", (data) => this.handleData(data));
    
        this.socket.connect(port, host);
      });
    }
Behavior4/5

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

With no annotations provided, the description carries full burden and discloses key behavioral traits: it explains connection persistence ('Connection persists until disconnect() is called or VICE closes'), default settings, and prerequisites for VICE configuration. It doesn't cover error handling or rate limits, but adds substantial context beyond basic function.

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?

Front-loaded with the core purpose in the first sentence, followed by essential details in bullet-like clarity. Every sentence earns its place: prerequisites, defaults, usage timing, persistence, and related tools. No wasted words, well-structured for quick comprehension.

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 provides good context for a connection tool: purpose, prerequisites, defaults, persistence, and related tools. It doesn't explain return values or error cases, but covers enough for basic usage in this debugging context, leaving some gaps for a complex operation.

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?

Schema description coverage is 100%, so the schema already documents both parameters with descriptions and constraints. The description adds minimal value beyond the schema by mentioning default connection ('Default connection: 127.0.0.1:6502'), which aligns with schema defaults. Baseline 3 is appropriate as the schema does most of the work.

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 ('Connect to a running VICE emulator instance') and resource ('via the binary monitor protocol'), distinguishing it from siblings like 'disconnect' or 'status' by explicitly mentioning it's the first step before debugging operations. It avoids tautology by explaining what connection means in this context.

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?

Explicitly states when to use ('Use this first before any debugging operations') and when not to use (implies after connection is established, use other tools). It names related tools ('status, disconnect') and specifies prerequisites ('VICE must be started with the binary monitor enabled'), providing clear alternatives and context.

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