Skip to content

[Bug]: mcp add/remove commands hang indefinitely when stdin is not a TTY and target client is running #680

@devadathanmb

Description

@devadathanmb

Description

When smithery mcp add or smithery mcp remove is run non-interactively (piped stdin — e.g. from CI, a script, or any tool that spawns the CLI via execFile/spawn), the process hangs forever if the target client app is currently open.

Steps to Reproduce

  1. Have the target client app open (e.g. Opencode).
  2. Run:
# Run smithery with stdin as a pipe (not a TTY) to simulate CI / automation.
# Because there is no interactive terminal, the restart prompt hangs forever.
node -e "const {spawn}=require('child_process'); spawn('smithery',['mcp','add','brightdata','--client','opencode'],{stdio:['pipe','inherit','inherit']}); setInterval(()=>console.error('still running...'),2000);"

Expected Behaviour

CLI detects non-TTY stdin and skips the prompt, exits cleanly.

Actual Behaviour

Process hangs indefinitely.

Image

Additional Information

Root Cause

In src/utils/client.tspromptForRestart() calls inquirer.prompt unconditionally when the client is running:

const isRunning = await isClientRunning(client)
if (!isRunning) return false

const { shouldRestart } = await inquirer.prompt([
  { type: "confirm", name: "shouldRestart", default: true, ... }
])

promptForRestart is called at the end of both install.ts and uninstall.ts with no TTY check. When stdin is a pipe, inquirer blocks forever waiting for input that never comes.

Environment

smithery CLI version: 4.4.0
Platform: macOS (darwin)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions