disconnect
Close the connection to the VICE C64 emulator instance to end debugging sessions and free 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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:173-198 (registration)Registration of the 'disconnect' MCP tool, including its inline handler function that calls ViceClient.disconnect() and formats the response.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); } } );
- src/protocol/client.ts:144-156 (handler)The ViceClient.disconnect() method implementation, which closes the TCP socket connection to VICE and updates the connection state. This is called by the MCP tool handler.async disconnect(): Promise<void> { if (!this.socket) { return; } return new Promise((resolve) => { this.socket!.once("close", () => { this.state.connected = false; resolve(); }); this.socket!.end(); }); }
- src/index.ts:38-59 (helper)formatResponse helper function used by the disconnect tool handler to format the successful response with 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 ), }, ], }; }
- src/index.ts:62-91 (helper)formatError helper function used by the disconnect tool handler 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 ), }, ], }; }