{"id":51481633,"url":"https://github.com/thebtf/mcp-launcher","last_synced_at":"2026-07-07T02:01:49.465Z","repository":{"id":365090453,"uuid":"1270517402","full_name":"thebtf/mcp-launcher","owner":"thebtf","description":"MCP stdio launcher for restart, reconnect, resource, tool, and upgrade smoke tests.","archived":false,"fork":false,"pushed_at":"2026-06-15T19:50:12.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-15T21:24:53.151Z","etag":null,"topics":["cli","devtools","go","graceful-restart","json-rpc","mcp","model-context-protocol","smoke-testing","stdio","testing"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thebtf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-15T19:42:39.000Z","updated_at":"2026-06-15T19:50:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/thebtf/mcp-launcher","commit_stats":null,"previous_names":["thebtf/mcp-launcher"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/thebtf/mcp-launcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebtf%2Fmcp-launcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebtf%2Fmcp-launcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebtf%2Fmcp-launcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebtf%2Fmcp-launcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thebtf","download_url":"https://codeload.github.com/thebtf/mcp-launcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebtf%2Fmcp-launcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35211553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-07T02:00:07.222Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","devtools","go","graceful-restart","json-rpc","mcp","model-context-protocol","smoke-testing","stdio","testing"],"created_at":"2026-07-07T02:01:46.022Z","updated_at":"2026-07-07T02:01:48.410Z","avatar_url":"https://github.com/thebtf.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mcp-launcher\n\n[![CI](https://github.com/thebtf/mcp-launcher/actions/workflows/ci.yml/badge.svg)](https://github.com/thebtf/mcp-launcher/actions/workflows/ci.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/thebtf/mcp-launcher.svg)](https://pkg.go.dev/github.com/thebtf/mcp-launcher)\n[![Go Report Card](https://goreportcard.com/badge/github.com/thebtf/mcp-launcher)](https://goreportcard.com/report/github.com/thebtf/mcp-launcher)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](LICENSE)\n[![Platform](https://img.shields.io/badge/platform-windows%20%7C%20macos%20%7C%20linux-lightgrey?style=flat-square)](#requirements)\n\n`mcp-launcher` is a zero-dependency Go CLI for exercising stdio MCP servers\nwithout opening a full AI client. It starts a target server as a subprocess,\nperforms the MCP initialize flow, keeps a real stdio owner alive, and can probe\ntools, resources, daemon restarts, reconnects, and binary upgrade paths from the\ncommand line.\n\nUse it when a server behaves differently under a real stdio client than it does\nunder a hand-written unit test.\n\n## Quick Start\n\nInstall with Go:\n\n```bash\ngo install github.com/thebtf/mcp-launcher@latest\n```\n\nOr build from source:\n\n```bash\ngit clone https://github.com/thebtf/mcp-launcher.git\ncd mcp-launcher\ngo test ./...\ngo build .\n```\n\nStart a live MCP stdio session against your server:\n\n```bash\nmcp-launcher -binary ./my-mcp-server -mode hold -hold 600\n```\n\nCall a tool and print both the raw MCP response and decoded text payload:\n\n```bash\nmcp-launcher \\\n  -binary ./my-mcp-server \\\n  -mode tool \\\n  -tool sessions \\\n  -args '{\"action\":\"health\"}'\n```\n\nRead an MCP resource:\n\n```bash\nmcp-launcher \\\n  -binary ./my-mcp-server \\\n  -mode resource \\\n  -uri my-server://health\n```\n\n## Why This Exists\n\nManual server launches hide client lifecycle bugs. A real stdio MCP client owns\nstdin, reads stdout line-by-line, handles notifications while waiting for\nresponses, sends `notifications/initialized`, and may disconnect or reconnect at\nawkward times.\n\n`mcp-launcher` gives you that pressure without the rest of an AI application:\n\n- Reproduce restart handoff failures with an actual subprocess owner.\n- Verify that `tools/list`, `tools/call`, and `resources/read` work after the\n  initialize handshake.\n- Exercise daemon control sockets while the stdio client is still connected.\n- Check that deferred binary installs become visible before reconnect\n  verification starts.\n- Switch between full inherited environment and a clean allow-list environment\n  that still preserves lifecycle-critical EOF policy when set.\n- Run a profile-aware compatibility audit that separates generic MCP behavior\n  from Claude Code-style and Codex-style launch envelopes.\n\n## Requirements\n\n- Go 1.22 or newer.\n- A target MCP stdio server binary.\n- No runtime dependencies beyond the Go standard library.\n- A daemon control socket only for `test`, `phase2`, `persist`, and\n  `kill-reconnect` modes.\n\nWindows, macOS, and Linux are supported for stdio launch flows. The\n`-cleanup-binary-processes` helper is Windows-only.\n\n## Commands\n\n```text\nmcp-launcher -binary \u003cserver\u003e [options] [-- extra server args...]\n```\n\n### Modes\n\n| Mode | What it does |\n| --- | --- |\n| `hold` | Starts the server, completes MCP initialization, and keeps the session open for external testing. |\n| `call` | Calls any JSON-RPC method after initialization. |\n| `tool` | Calls an MCP tool through `tools/call`. |\n| `resource` | Reads an MCP resource through `resources/read`. |\n| `install` | Calls the server's `upgrade` tool with a local source binary, closes stdio, reconnects, and verifies health. |\n| `test` | Starts a daemon, connects one owner session, sends one graceful restart over the control socket, and checks the successor daemon. |\n| `phase2` | Runs two graceful restarts: original daemon, then successor daemon. Useful for handoff deadlock repros. |\n| `persist` | Verifies that a daemon survives stdio disconnect and that the next session reuses the same daemon PID. |\n| `kill-reconnect` | Hard-kills the daemon, closes stdio, then measures new-session recovery time. |\n| `compat` | Runs a profile-aware MCP stdio compatibility audit and optionally writes a JSON report. |\n\n### Flags\n\n| Flag | Default | Description |\n| --- | --- | --- |\n| `-binary` | required | MCP server executable path. |\n| `-cwd` | `.` | Working directory for the subprocess. |\n| `-mode` | `hold` | One of `hold`, `call`, `tool`, `resource`, `install`, `test`, `phase2`, `persist`, `kill-reconnect`, or `compat`. |\n| `-hold` | `300` | Seconds to keep the session open in `hold` mode. |\n| `-watch` | `60` | Seconds to watch daemon liveness after disconnect in `persist` mode. |\n| `-ctl` | empty | Daemon control socket path. Required for `test`, `phase2`, `persist`, and `kill-reconnect`. |\n| `-daemon-flag` | `--muxcore-daemon` | Flag used to start the target server in daemon mode. |\n| `-env-mode` | `full` | `full` passes the parent environment; `clean` forwards a platform allow-list and preserves aimux/muxcore smoke contract variables when set. |\n| `-timeout` | `120` | MCP request timeout in seconds, including initialize and `tools/list`. |\n| `-compat-level` | `standard` | Compatibility audit breadth: `smoke`, `standard`, `lifecycle`, or `maximum`. |\n| `-compat-profiles` | `generic,claude-code,codex` | Comma-separated profiles for `compat`: `generic`, `claude-code`, `codex`, `fixture`, `openclaw-registry`, or `hermes`. Reserved profiles return evidence-needed results until backed by docs or traces. |\n| `-compat-report` | empty | Writes the compatibility audit JSON report to the provided path. |\n| `-expect-tools` | `0` | Expected `tools/list` count after session init. `0` disables the check. |\n| `-expect-version` | empty | Expected MCP `serverInfo.version` after session init. |\n| `-method` | empty | JSON-RPC method for `call` mode. |\n| `-params` | `{}` | JSON params for `call` mode. |\n| `-tool` | empty | MCP tool name for `tool` mode. |\n| `-args` | `{}` | JSON object arguments for `tool` mode. |\n| `-uri` | empty | MCP resource URI for `resource` mode. |\n| `-source` | empty | Local source binary for `install` mode. |\n| `-force` | `false` | Sends `force=true` to `upgrade(action=apply)` in `install` mode. |\n| `-upgrade-mode` | `auto` | Upgrade mode passed to the server: `auto`, `hot_swap`, or `deferred`. |\n| `-install-validation` | `replacement` | Install proof strategy: `replacement` waits for `-binary` to change when a post-exit install is scheduled; `active-pointer` waits for an active pointer file to change and then verifies reconnect health/version. |\n| `-active-engine-file` | empty | Active pointer file for `-install-validation active-pointer`; defaults to `MCPMUX_ACTIVE_ENGINE_FILE`. |\n| `-reconnect-delay` | `2` | Initial/retry delay for install reconnect verification. Explicit values override the automatic post-exit reconnect delay, not replacement detection. |\n| `-cleanup-binary-processes` | `false` | After a one-shot mode, kill remaining Windows processes with the same image name as `-binary`. Use only with unique smoke-test binary names. |\n\nEverything after `--` is forwarded to the target server:\n\n```bash\nmcp-launcher -binary ./my-mcp-server -mode hold -- --config ./dev.json\n```\n\n## Common Workflows\n\n### Keep a real owner session alive\n\n```bash\nmcp-launcher -binary ./my-mcp-server -mode hold -hold 600\n```\n\nThis is the simplest way to keep stdin/stdout ownership active while another\ntool triggers a restart or inspects daemon state.\n\n### Probe a tool\n\n```bash\nmcp-launcher \\\n  -binary ./my-mcp-server \\\n  -mode tool \\\n  -tool sessions \\\n  -args '{\"action\":\"health\"}' \\\n  -expect-tools 27\n```\n\n`-expect-tools` turns the post-initialize `tools/list` count into an assertion.\n\n### Probe a resource\n\n```bash\nmcp-launcher \\\n  -binary ./my-mcp-server \\\n  -mode resource \\\n  -uri my-server://health\n```\n\n### Run a compatibility audit\n\n```bash\nmcp-launcher \\\n  -binary ./my-mcp-server \\\n  -mode compat \\\n  -compat-level standard \\\n  -compat-report compat-report.json\n```\n\nThe default audit runs `generic`, `claude-code`, and `codex` profiles. Results\nstay separated so a server can pass generic MCP checks while a named host\nenvelope reports `FAIL`, `BLOCKED`, or `UNSUPPORTED`.\n\nCompatibility levels are cumulative:\n\n| Level | Use when |\n| --- | --- |\n| `smoke` | You only need startup and MCP initialize proof. |\n| `standard` | You want the default local compatibility matrix. |\n| `lifecycle` | You also want lifecycle checks that need `-ctl`. Missing inputs are `BLOCKED`. |\n| `maximum` | You want all currently known checks, including install-source prerequisites. Missing inputs are `BLOCKED`. |\n\nReserved profiles such as `fixture`, `openclaw-registry`, and `hermes` do not\nguess behavior. They return an evidence-needed result until primary docs or a\ncaptured fixture trace exists.\n\n### Verify a deferred binary install\n\n```bash\nmcp-launcher \\\n  -binary ./my-server-current.exe \\\n  -cwd /path/to/server/project \\\n  -mode install \\\n  -source ./my-server-next.exe \\\n  -force \\\n  -upgrade-mode auto \\\n  -expect-version 1.2.3\n```\n\nBy default, `install` mode fingerprints the installed binary, calls `upgrade`,\ncloses the install session, waits for post-exit replacement when the payload or\ndisconnect indicates one is scheduled, reconnects, calls\n`sessions(action=\"health\")`, and tries to read `aimux://health` when that\nresource exists.\n\nFor muxcore active-pointer/successor installs where the stable `-binary` path is\nintentionally not replaced, use active-pointer validation:\n\n```bash\nmcp-launcher \\\n  -binary ./my-server-current.exe \\\n  -cwd /path/to/server/project \\\n  -mode install \\\n  -source ./my-server-next.exe \\\n  -force \\\n  -install-validation active-pointer \\\n  -active-engine-file ./active.txt \\\n  -expect-version 1.2.3\n```\n\nActive-pointer validation reads the pointer before `upgrade`, waits for it to\nchange after handoff, then treats reconnect health, tool count, and expected\nversion as the install proof. With `-env-mode clean`, the launcher still\npreserves aimux/muxcore smoke contract variables from the parent environment,\nincluding `AIMUX_STDIN_EOF_POLICY` and `MCPMUX_ACTIVE_ENGINE_FILE`.\n\n### Verify daemon persistence across stdio disconnect\n\n```bash\nmcp-launcher \\\n  -binary ./my-server \\\n  -mode persist \\\n  -ctl /tmp/my-server.ctl.sock \\\n  -watch 60\n```\n\n`PASS` means the daemon PID stayed alive for the full watch window and the\nsecond session reattached to the same PID.\n\n## Architecture Overview\n\n```mermaid\nflowchart LR\n    CLI[\"mcp-launcher CLI\"]\n    Client[\"mcpClient\"]\n    Server[\"Target MCP stdio server\"]\n    Control[\"Daemon control socket\"]\n    Modes[\"Mode runner\"]\n\n    CLI --\u003e Modes\n    Modes --\u003e Client\n    Client -- stdin JSON-RPC --\u003e Server\n    Server -- stdout JSON-RPC --\u003e Client\n    Modes -- status / graceful-restart --\u003e Control\n    Control --\u003e Server\n```\n\nThe project is intentionally small:\n\n- `main.go` contains the CLI, stdio JSON-RPC client, daemon control socket\n  client, mode runners, install reconnect logic, and cleanup helpers.\n- `mcpClient` starts the target subprocess, writes JSON-RPC requests to stdin,\n  reads newline-delimited JSON-RPC from stdout, routes responses by request ID,\n  and collects notifications separately.\n- `controlSend` talks to a raw Unix domain control socket for daemon status and\n  graceful restart commands.\n- `main_test.go`, `install_reconnect_test.go`, and `env_test.go` cover client\n  cleanup on tool errors, Windows PID fallback cleanup, clean environment\n  preservation, install reconnect delay decisions, post-exit install detection,\n  replacement waiting, and binary fingerprinting.\n\n## MCP Session Flow\n\nEach session follows this sequence before the selected mode does its work:\n\n```text\nlauncher -\u003e server: initialize\nserver   -\u003e launcher: initialize result with serverInfo\nlauncher -\u003e server: notifications/initialized\nlauncher -\u003e server: tools/list\nserver   -\u003e launcher: tools/list result\n```\n\nAfter that, mode-specific work runs against the same live subprocess session.\n\n## Troubleshooting\n\n### `error: -binary is required`\n\n**Symptom:** The launcher exits immediately with usage text.\n\n**Cause:** `-binary` is the only required flag for every mode.\n\n**Fix:** Pass the target MCP stdio server executable:\n\n```bash\nmcp-launcher -binary ./my-mcp-server -mode hold\n```\n\n**Verify:** The output includes `spawn`, `pid=`, `initialize`, and `tools`.\n\n### `error: -ctl is required`\n\n**Symptom:** `test`, `phase2`, `persist`, or `kill-reconnect` exits before\nstarting.\n\n**Cause:** Those modes need the daemon control socket.\n\n**Fix:** Pass the socket path used by your daemon:\n\n```bash\nmcp-launcher -binary ./my-mcp-server -mode phase2 -ctl /tmp/my-server.ctl.sock\n```\n\n**Verify:** The mode can print daemon status or restart results.\n\n### `timeout waiting for initialize` or `timeout waiting for tools/list`\n\n**Symptom:** The subprocess starts, but the launcher times out during bootstrap.\n\n**Cause:** The target server did not emit a JSON-RPC response on stdout before\nthe timeout.\n\n**Fix:** Run the target binary directly and check that stdout is reserved for\nMCP JSON-RPC. Logs should go to stderr. Increase `-timeout` only after checking\nthat the server is actually starting.\n\n**Verify:** `mcp-launcher -binary ./my-mcp-server -mode hold -timeout 120`\nprints an initialize result and a tools count.\n\n### Install mode reconnects too early\n\n**Symptom:** `install` mode reports that reconnect verification failed after an\nupgrade that schedules replacement after process exit.\n\n**Cause:** The old process may need time to exit and replace the installed\nbinary.\n\n**Fix:** Let the automatic post-exit wait run, or choose an explicit delay:\n\n```bash\nmcp-launcher \\\n  -binary ./my-server-current.exe \\\n  -mode install \\\n  -source ./my-server-next.exe \\\n  -reconnect-delay 15\n```\n\n**Verify:** The output shows either `installed binary changed` or a successful\n`sessions health` payload.\n\n### `cleanup-binary-processes` removed the wrong process\n\n**Symptom:** A process with the same executable name as the smoke binary was\nterminated.\n\n**Cause:** Cleanup matches by image name on Windows.\n\n**Fix:** Use `-cleanup-binary-processes` only with unique disposable binary\ncopies, such as `my-server-smoke-current.exe`.\n\n**Verify:** No unrelated process shares the same image name before enabling the\nflag.\n\n## Development\n\n```bash\ngo test ./...\ngo vet .\ngo build .\n```\n\nThe module has no third-party dependencies. See [CONTRIBUTING.md](CONTRIBUTING.md)\nfor the contributor workflow.\n\n## Repository Setup Notes\n\nSuggested GitHub description:\n\n```text\nMCP stdio launcher for restart, reconnect, resource, tool, and upgrade smoke tests.\n```\n\nSuggested topics:\n\n```text\nmcp, model-context-protocol, go, cli, devtools, testing, stdio, json-rpc, graceful-restart, smoke-testing\n```\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebtf%2Fmcp-launcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthebtf%2Fmcp-launcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebtf%2Fmcp-launcher/lists"}