Heuristic:AI QL Tuui Per Server IPC Channel Naming
| Knowledge Sources | |
|---|---|
| Domains | IPC, MCP, Naming |
| Last Updated | 2026-10-24 20:38 GMT |
Overview
Name dynamically registered IPC channels as {serverName}-{type}/{action} to namespace per-server capability handlers and prevent channel collisions across multiple MCP servers.
Description
When registering IPC handlers for multiple MCP servers, each server may expose the same capabilities (tools/list, tools/call, prompts/list). Without namespacing, registering a handler for tools/list would collide with another server's tools/list. The per-server naming convention creates a unique channel name by combining the server name, capability type, and action: {serverName}-{type}/{action} (e.g., filesystem-tools/list, github-tools/call). All registered handlers are tracked in a handlerRegistry Map for clean removal during re-initialization.
Usage
Apply this heuristic when dynamically registering IPC handlers for multiple servers that share the same method names. The symptom is an ipcMain.handle error: "Attempted to register a second handler for 'tools/list'".
The Insight (Rule of Thumb)
- Action: Use
${name}-${type}/${action}as the IPC channel name. - Value: Examples:
filesystem-tools/list,filesystem-tools/call,github-prompts/list. - Trade-off: Channel names are longer; the renderer must know the server name to invoke the correct channel.
- Cleanup: All channels are stored in
handlerRegistryand removed viaipcMain.removeHandlerduringstopAllServers.
Reasoning
Electron's ipcMain.handle throws if a handler is already registered for the same channel. With multiple MCP servers each exposing the same MCP protocol methods, flat channel names cause collisions. The {serverName}-{type}/{action} scheme ensures uniqueness while remaining human-readable and parseable. The registry map enables clean teardown: when servers are re-initialized, all old handlers are removed before new ones are registered.
Code Evidence
Channel naming from `src/main/IPCs.ts:336-359`:
const registerHandler = (method: string, schema: any) => {
const eventName = `${name}-${method}`
console.log(`IPC Main ${eventName}`)
const handler = async (_event, request) => {
return await manageRequests(connection.client, `${method}`, schema, request?.params)
}
ipcMain.handle(eventName, handler)
handlerRegistry.set(eventName, handler)
return eventName
}
for (const [type, actions] of Object.entries(McpServerCapabilitySchemas)) {
const capabilities = connection.client.getServerCapabilities()
if (capabilities?.[type]) {
feature[type] = {}
for (const [action, schema] of Object.entries(actions)) {
feature[type][action] = registerHandler(`${type}/${action}`, schema)
}
}
}
Handler cleanup from `src/main/IPCs.ts:296-302`:
static removeAllHandlers() {
for (const [eventName] of handlerRegistry) {
ipcMain.removeHandler(eventName)
}
handlerRegistry.clear()
}