Make LocalStack lifecycle CLI-agnostic (support lstk; Docker-API stop)#50
Open
maximkasy wants to merge 1 commit into
Open
Make LocalStack lifecycle CLI-agnostic (support lstk; Docker-API stop)#50maximkasy wants to merge 1 commit into
maximkasy wants to merge 1 commit into
Conversation
… stop) Follow-up to #49 (gap #3). start/stop/restart hardcoded the Python `localstack` binary and the management preflight hard-required it, so an `lstk`-only host (no Python CLI) couldn't start/stop/restart through the MCP even though its LocalStack was running. - stop: stop the already-detected container via the Docker API — provenance- agnostic and CLI-free (works for localstack / lstk / compose / raw `docker run`). - start: detect whichever lifecycle CLI is present (`localstack`, else `lstk`) rather than hardcoding `localstack`; clear error if neither is installed. - restart: Docker-API stop + start (still applies new envVars). - drop `requireLocalStackCli` from the management preflight (status/stop/restart no longer need it; start detects a CLI itself). Snowflake start still requires `localstack` — `--stack snowflake` is localstack-only. Also (gap #6, for the lifecycle spawn): set PYTHONIOENCODING=utf-8 / PYTHONUTF8=1 on the start subprocess so the Python CLI's emoji output doesn't crash under the Windows cp1252 code page. Adds DockerApiClient.stopContainer and detectLifecycleCli with unit tests, plus lifecycle tool-boundary tests. Also restores the management status tests that were dropped from main during the #49 squash merge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make LocalStack lifecycle CLI-agnostic (support lstk; Docker-API stop)
Follow-up to #49. After #49, detection and status are provenance-agnostic (gateway-based), but lifecycle still hardcoded the Python
localstackbinary and the management tool's preflight hard-required it. So a host that started LocalStack withlstk(the newer Go CLI) and doesn't have the PythonlocalstackCLI installed couldn'tstart/stop/restartthrough the MCP — even though its LocalStack was up and reachable.Changes
stop→ Docker API. Stop the already-detected container (findLocalStackContainer) via the Docker API. Provenance-agnostic and CLI-free — works whether LocalStack was started bylocalstack,lstk, docker-compose, ordocker run. It also fixes a mixed-CLI mismatch:localstack stoponly targetslocalstack-main, so it silently misses anlstk-startedlocalstack-aws. (LocalStack containers run with--rm, so stopping also removes them, matchinglocalstack stop.)start→ detect the CLI. Use whichever lifecycle CLI is present —localstack, elselstk(which also forwardsLOCALSTACK_*env). Clear error when neither is installed, instead of an opaquespawn localstack ENOENT.restart→ Docker-API stop + start (still applies newenvVars).requireLocalStackClifrom the management tool —status/stop/restartdon't need a CLI, andstartdetects one itself. Snowflakestartstill requireslocalstack(--stack snowflakeis localstack-only).PYTHONIOENCODING=utf-8/PYTHONUTF8=1on thestartsubprocess so the Python CLI's emoji output can't throwUnicodeEncodeErrorunder the Windows cp1252 code page.Why it's better
Previously the only supported lifecycle path was the Python
localstackCLI, and the preflight rejected anything else — which broke the documentedlstkquickstart and gave confusing errors on mixed-CLI machines. Now lifecycle is driven by the Docker API + gateway and shells out to a CLI only forstart(detecting whichever is installed), so it works forlocalstack,lstk, and externally-managed containers alike.Tests
DockerApiClient.stopContainer+detectLifecycleCliunit tests.npx jest→ 19 suites / 120 tests;tsc --noEmitclean;xmcp buildregisters 14 tools and the server starts clean.start → status → aws-client → restart → stopcycle on Windows against a real Pro/Enterprise token; the CI smoke job covers the same on Linux.Notes
startspawn UTF-8-safe.logs/extensions/ephemeraland the optionalstatusCLI-enrichment still shell out tolocalstackwithout forcing UTF-8 — a centralized UTF-8 fix for alllocalstacksubprocess calls would be a sensible follow-up.mainduring the squash merge.🤖 Generated with Claude Code