Skip to content

CLI mode builds an unused stdio server and installs server exit handlers #289

Closed

Description

@TMHSDigital

Summary

src/index.ts creates the MCP server at module load before the CLI branch, and its stdout/exception/signal handlers also run in CLI mode.

Where

  • src/index.ts:22 (createServer() at module load)
  • src/index.ts:73-87, 128-135 (handlers)
  • src/cli.ts:337 (CLI creates its own server)

Details

An unknown SCREENCAST_TOOLSETS warning prints twice. The process.stdout.on("error") handler calls the server shutdown()/process.exit in CLI mode too (e.g. screencast-mcp record ... | head), bypassing the CLI's exit code.

Impact

Duplicate warnings and a wrong exit code when CLI stdout closes early.

Suggested fix

Create the server inside main() and register the stdout/uncaughtException/signal handlers only on the server path.

Acceptance criteria

  • CLI invocations never construct the stdio server
  • Toolset warning prints once
  • CLI exit code preserved on EPIPE

Getting started

  • Relevant files: src/index.ts, src/cli.ts
  • How to run tests: npm run build && npm test (also npm run typecheck and npm run lint)
  • Related docs: CONTRIBUTING.md, AGENTS.md

Filed by repo-audit/full-audit at f2fda28. Severity: low. Effort: S. audit-key: quality|src/index.ts|createServer-toplevel

Activity

  1. added
    good first issue
    priority: low
    tech-debt
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 10, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 1f72479: the stdio server and its process handlers are created in main() only; the CLI path just ignores EPIPE on stdout so it keeps its own exit code. Verified with a new test that runs the built entry with --help and an unknown SCREENCAST_TOOLSETS (exit 0, no warning) plus build/typecheck/lint.

  3. added a commit that references this issue on Nov 10, 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

    good first issuepriority: lowtech-debt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions