| summary | Reference for mcporter generate-cli outputs, runtimes, schema-aware UX, and artifact regeneration. | |
|---|---|---|
| read_when |
|
Default behavior: generating <server>.ts in the working directory if no output path is provided. Bundling is opt-in via --bundle and produces a single JS file with shebang; otherwise we emit TypeScript targeting Node.js. Rolldown handles bundling by default unless the runtime resolves to Bun—in that case Bun’s native bundler is selected automatically (still requires --runtime bun or Bun auto-detection); --bundler lets you override either choice.
mcporter generate-cli produces a standalone CLI for a single MCP server. The generated CLI feels like a Unix tool: subcommands map to MCP tools, arguments translate to schema fields, and output can be piped or redirected.
- Input: Identify the target server either by shorthand name or by providing an explicit MCP server definition.
- Output: Emit a TypeScript file (ESM) targeting Node.js by default (
<server>.tsunless--outputoverrides). Bundling to a standalone JS file happens only when--bundleis passed. - Runtime Selection: Prefer Bun when it is available (
bun --versionsucceeds); otherwise fall back to Node.js. Callers can force either runtime via--runtime bun|node. - Schema-Aware CLI: Leverage
createServerProxyto map positional/flag arguments to MCP tool schemas, including defaults and required validation. - Unix-Friendly Output: Provide
--output text|json|markdown|rawflags so results can be piped; default to human-readable text. Include--timeout(default 30s) to cap call duration.
- Generated CLI depends on the latest
commanderfor argument parsing. - Default timeout for tool calls is 30 seconds, overridable via
--timeout. - Runtime flag remains (
--runtime bun) to tailor shebang/usage instructions, but Node.js is the default. - Generated CLI embeds the resolved server definition and always targets that snapshot (no external
--configor--serveroverrides at runtime).
# Minimal: infer the name from the command URL and emit TypeScript (optionally bundle)
npx mcporter generate-cli \
--command https://mcp.context7.com/mcp \
--minify
# Provide explicit name/description and compile a Bun binary (falls back to Node if Bun missing)
npx mcporter generate-cli \
--name context7 \
--command https://mcp.context7.com/mcp \
--description "Context7 docs MCP" \
--runtime bun \
--compile
chmod +x context7
./context7
# show the embedded help + tool list
# Shareable "one weird trick" for chrome-devtools (no config required)
npx mcporter generate-cli --command "npx -y chrome-devtools-mcp@latest"--minifyshrinks the bundled output via the selected bundler (output defaults to<server>.js).--compile [path]implies bundling and invokesbun build --compileto create the native executable (Bun only). When you omit the path, the compiled binary inherits the server name.- Use
--server '{...}'when you need advanced configuration (headers, env vars, stdio commands, OAuth metadata). - Omit
--nameto let mcporter infer it from the command URL (for example,https://mcp.context7.com/mcpbecomescontext7). - When targeting an existing config entry, you can skip
--serverand pass the name as a positional argument:npx mcporter generate-cli linear --bundle dist/linear.js. - When the MCP server is a stdio command, you can also skip
--commandby quoting the inline command as the first positional argument (e.g.,npx mcporter generate-cli "npx -y chrome-devtools-mcp@latest"). - Generated CLIs preserve
lifecycle: "keep-alive"for embedded stdio servers. At runtime they create a stable generated config under~/.mcporter/generated/(or$XDG_STATE_HOME/mcporter/generated/when set), auto-start the daemon as needed, and keep the server process alive across separate generated-CLI invocations. - Narrow the CLI to a specific subset of tools with
--include-tools:npx mcporter generate-cli linear --include-tools issues_list,issues_create. - Hide debug or admin tools with
--exclude-tools:npx mcporter generate-cli linear --exclude-tools debug_tool,admin_reset.
- Every generated artifact embeds its metadata (generator version, resolved server definition, invocation flags). A hidden
__mcporter_inspectsubcommand prints the payload without contacting the MCP server, so binaries remain self-describing even after being copied to another machine. mcporter inspect-cli <artifact>shells out to that embedded command and prints a human summary (pass--jsonfor raw output). The summary includes a ready-to-rungenerate-clicommand you can reuse directly.mcporter generate-cli --from <artifact>replays the stored invocation against the latest mcporter build.--server,--runtime,--timeout,--minify/--no-minify,--bundle,--compile,--output, and--dry-runlet you override specific pieces of the stored metadata when necessary.- Because the metadata lives inside the artifact, any template, bundle, or compiled binary can be refreshed after a generator upgrade without juggling sidecar files.