MCPcopy
hub / github.com/codeaashu/claude-code / checkIdeConnection

Function checkIdeConnection

src/utils/ide.ts:402–433  ·  view source on GitHub ↗

* Checks if the IDE connection is responding by testing if the port is open * @param host Host to connect to * @param port Port to connect to * @param timeout Optional timeout in milliseconds (defaults to 500ms) * @returns true if the port is open, false otherwise

(
  host: string,
  port: number,
  timeout = 500,
)

Source from the content-addressed store, hash-verified

400 * @returns true if the port is open, false otherwise
401 */
402async function checkIdeConnection(
403 host: string,
404 port: number,
405 timeout = 500,
406): Promise<boolean> {
407 try {
408 return new Promise(resolve => {
409 const socket = createConnection({
410 host: host,
411 port: port,
412 timeout: timeout,
413 })
414
415 socket.on('connect', () => {
416 socket.destroy()
417 void resolve(true)
418 })
419
420 socket.on('error', () => {
421 void resolve(false)
422 })
423
424 socket.on('timeout', () => {
425 socket.destroy()
426 void resolve(false)
427 })
428 })
429 } catch (_) {
430 // Invalid URL or other errors
431 return false
432 }
433}
434
435/**
436 * Resolve the Windows USERPROFILE path. WSL often doesn't pass USERPROFILE

Callers 2

cleanupStaleIdeLockfilesFunction · 0.85
ide.tsFile · 0.85

Calls 3

onMethod · 0.80
resolveFunction · 0.70
destroyMethod · 0.45

Tested by

no test coverage detected