Skip to main content
Glama
simen
by simen

disconnect

Cleanly close the connection to the VICE C64 emulator instance. Safely terminates the debugging session and releases resources.

Instructions

Disconnect from the VICE emulator instance.

Cleanly closes the connection. Safe to call even if not connected.

Related tools: connect, status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:161-186 (registration)
    Registers the MCP 'disconnect' tool with no input schema and inline handler function.
    server.registerTool( "disconnect", { description: `Disconnect from the VICE emulator instance. Cleanly closes the connection. Safe to call even if not connected. Related tools: connect, status`, }, async () => { const wasConnected = client.getState().connected; try { await client.disconnect(); return formatResponse({ disconnected: true, wasConnected, message: wasConnected ? "Disconnected from VICE" : "Was not connected", }); } catch (error) { return formatError(error as ViceError); } } );
  • The main handler function for the 'disconnect' MCP tool. Checks connection state, calls underlying ViceClient.disconnect(), and returns formatted response.
    async () => { const wasConnected = client.getState().connected; try { await client.disconnect(); return formatResponse({ disconnected: true, wasConnected, message: wasConnected ? "Disconnected from VICE" : "Was not connected", }); } catch (error) { return formatError(error as ViceError); } }
  • Underlying ViceClient.disconnect() method implementation that closes the TCP socket connection to VICE emulator.
    async disconnect(): Promise<void> { if (!this.socket) { return; } return new Promise((resolve) => { this.socket!.once("close", () => { this.state.connected = false; resolve(); }); this.socket!.end(); }); }
  • Helper function used by all MCP tools to format responses with JSON data and connection metadata.
    function formatResponse(data: object) { const state = client.getState(); return { content: [ { type: "text" as const, text: JSON.stringify( { ...data, _meta: { connected: state.connected, running: state.running, ...(state.connected && { host: state.host, port: state.port }), }, }, null, 2 ), }, ], }; }
  • Helper function used by MCP tools to format error responses with connection metadata.
    function formatError(error: ViceError | Error) { const state = client.getState(); const errorData = "code" in error ? error : { error: true, code: "UNKNOWN_ERROR", message: error.message, }; return { content: [ { type: "text" as const, text: JSON.stringify( { ...errorData, _meta: { connected: state.connected, running: state.running, }, }, null, 2 ), }, ], }; }

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