Skip to content

New SSH connection per command; multi-probe tools and nodeList run sequentially #102

Closed

Description

@TMHSDigital

Summary

Every execSSH call opens a new SSH connection: TCP, key exchange, and auth. The multi-check tools then run their probes one after another, so a single tool call costs many handshakes. When a host is offline, each probe also waits for the full connect timeout.

Where

  • mcp-server/src/utils/ssh-api.ts:105-106,166-173 (new Client() per call; the key is re-read on every call at :170)
  • mcp-server/src/tools/diagnostics.ts:29-45 (about 9 sequential calls)
  • mcp-server/src/tools/healthCheck.ts:35-44 (7 sequential calls)
  • mcp-server/src/tools/certList.ts:16-46 (4 calls)
  • mcp-server/src/tools/nodeList.ts:15-17 (for (const node of nodes) { await execSSH(...) })

Impact

  • A handshake to a Pi takes roughly 150-500 ms on the LAN, and more over Tailscale.
  • homelab_diagnostics takes 2-5 s where a single round trip would do. With an unreachable host it can take about 90 s, because each of the 9 probes waits 10 s for readyTimeout.
  • homelab_nodeList grows linearly with fleet size: 5 nodes with 2 offline takes more than 20 s.

Suggested fix

  • Collapse each multi-probe tool into one remote script with section markers, as diskUsage already does.
  • In nodeList, probe all nodes in parallel with Promise.allSettled, using a shorter probe timeout.
  • Optionally, keep a cached Client per node with idle expiry and reconnect on error, running several exec channels over it.
  • Read the private key once.

Acceptance criteria

  • diagnostics and healthCheck use at most 1-2 connections
  • nodeList total time is about the slowest node, not the sum of all nodes

Getting started

  • Relevant files: the files listed above
  • How to run tests: cd mcp-server && npm test

Filed by repo-audit/full-audit at 9cfe5e3. Severity: medium. Effort: M. audit-key: performance|mcp-server/src/utils/ssh-api.ts|execSSH connection-per-call

Activity

  1. added
    help wanted
    performance
    severity: medium
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedperformanceseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions