MCPcopy
hub / github.com/claude-code-best/claude-code / start

Method start

src/utils/pipeTransport.ts:216–258  ·  view source on GitHub ↗

* Start listening for incoming connections. * @param options - Optional TCP configuration for LAN mode.

(options?: PipeServerOptions)

Source from the content-addressed store, hash-verified

214 * @param options - Optional TCP configuration for LAN mode.
215 */
216 async start(options?: PipeServerOptions): Promise<void> {
217 await ensurePipesDir()
218
219 // Clean up stale socket file (Unix only)
220 if (process.platform !== 'win32') {
221 try {
222 await unlink(this.socketPath)
223 } catch {
224 // File doesn't exist — fine
225 }
226 }
227
228 // Start UDS/Named Pipe server
229 await new Promise<void>((resolve, reject) => {
230 this.server = createServer(socket => this.setupSocket(socket))
231
232 this.server.on('error', reject)
233
234 this.server.listen(this.socketPath, () => {
235 // On Windows, Named Pipes don't exist in the filesystem.
236 // Write a registry file so listPipes() can discover this server.
237 if (process.platform === 'win32') {
238 const regFile = join(getPipesDir(), `${this.name}.pipe`)
239 const { hostname } = require('os') as typeof import('os')
240 void writeFile(
241 regFile,
242 JSON.stringify({
243 pid: process.pid,
244 ts: Date.now(),
245 ip: getLocalIp(),
246 hostname: hostname(),
247 }),
248 ).catch(() => {})
249 }
250 resolve()
251 })
252 })
253
254 // Optionally start TCP server for LAN connectivity
255 if (options?.enableTcp) {
256 await this.startTcpServer(options.tcpPort ?? 0)
257 }
258 }
259
260 /**
261 * Start TCP listener for LAN peers.

Callers 1

createPipeServerFunction · 0.95

Calls 9

setupSocketMethod · 0.95
startTcpServerMethod · 0.95
ensurePipesDirFunction · 0.85
unlinkFunction · 0.85
getPipesDirFunction · 0.85
getLocalIpFunction · 0.85
nowMethod · 0.80
resolveFunction · 0.70
onMethod · 0.65

Tested by

no test coverage detected