Skip to content

Fix/pos cli mcp server exit crash#728

Merged
Slashek merged 2 commits into
masterfrom
fix/pos-cli-mcp-server-exit-crash
Jul 24, 2026
Merged

Fix/pos cli mcp server exit crash#728
Slashek merged 2 commits into
masterfrom
fix/pos-cli-mcp-server-exit-crash

Conversation

@fklosowski

Copy link
Copy Markdown
Contributor

pos-cli-mcp: server-wide crash on any fatal tool error

Problem

The MCP server runs all its tools in a single process. Any tool that hit a fatal error path resolved through the CLI's logger.Error, which calls process.exit(1). Because the tools aren't isolated subprocesses, that exit terminated the entire server — one recoverable per-tool error took down every tool at once and forced a manual reconnect.

Why fix

A long-lived server must never be brought down by a single request's error. The failure should be returned to the caller as a normal error response while the server keeps serving all other tools. The server code even had a catchable-error path already written for this case, but it was unreachable because the shared helper exited before it could run.

What was fixed

Fatal errors under the MCP server now throw instead of exiting, so the server's per-request handler catches them and returns a clean error — and stays alive. Standalone CLI behavior is unchanged (it still exits as before).

How

  • Added a server-mode flag; when the MCP server starts it enables it.
  • In server mode, logger.Error throws instead of process.exit — this is the single choke point, so it covers every tool, not just one path.
  • The environment-resolution helper gained a non-exiting mode (returns instead of exiting) so the server's existing catchable error path is reachable.
  • Added unit tests: server mode throws and never exits; CLI mode still exits; the non-exiting path never throws or exits.

@Slashek
Slashek merged commit ba3e37d into master Jul 24, 2026
6 checks passed
@Slashek
Slashek deleted the fix/pos-cli-mcp-server-exit-crash branch July 24, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants