Skip to content

NPM tools open a separate SSH connection just to log in #162

Closed

Description

@TMHSDigital

Summary

getNpmToken makes its own execSSH call to fetch a token, then each NPM tool makes a second call with it. certList makes three connections in sequence.

Where

  • mcp-server/src/utils/service-http.ts:185-196
  • mcp-server/src/tools/npmProxyHosts.ts:22-27
  • mcp-server/src/tools/npmCerts.ts:22-27
  • mcp-server/src/tools/certList.ts:25-29, :46-52

Details

execSSH opens a new ssh2 connection (TCP, key exchange, auth) per call, and no token is cached.

Impact

On a LAN Pi the handshake (about 150-400 ms) dominates a localhost curl, so npmProxyHosts and npmCerts take about twice as long as needed and certList about three times.

Suggested fix

Build one remote script that logs in and queries in the same session, exposed as npmGet(path, port, node) in service-http.ts, and use it from all three tools.

Acceptance criteria

  • Each NPM tool uses a single SSH round trip (certList: two at most)
  • Handler tests updated

Getting started

  • Relevant files: mcp-server/src/utils/service-http.ts, mcp-server/src/tools/npmProxyHosts.ts, mcp-server/src/tools/npmCerts.ts, mcp-server/src/tools/certList.ts
  • How to run tests: cd mcp-server && npm install && npm test (and npm run typecheck); structure tests: pip install -r requirements-test.txt && pytest tests/ -v
  • Conventions: see CLAUDE.md and CONTRIBUTING.md

Filed by repo-audit/full-audit at 636fefb. Severity: low. Effort: S. audit-key: performance|mcp-server/src/utils/service-http.ts|getNpmToken

Activity

  1. TMHSDigital commented on Nov 19, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 4d82568: new npmGet()/npmGetCommand() in service-http.ts logs in and queries in one remote script; npmProxyHosts and npmCerts use one SSH round trip, certList two; getNpmToken removed. Missing token -> exit 65 with a message naming the credentials; curl exit codes still map through curlErrorResponse. Verified with handler tests pinning the call counts and service-http tests that run the script in sh with a stubbed curl; build, typecheck, Vitest and structure tests pass.

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

    performanceseverity: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions