`serve` executes your local code when a tool is called, so it stays on loopback until you pass `--host`. Before you do, set keys: any non-empty value in `MCP_GEN_API_KEYS` turns bearer auth on, and a bad token is rejected with `401` before the transport, so no tool code runs. Use the environment variable rather than `--api-key` in production — a flag is visible to anyone who can list processes.
A generator that reads your exported TypeScript functions and derives MCP tool, resource and prompt definitions from them. The type checker produces the JSON Schema and the JSDoc produces the descriptions, so nothing is added to your code.
- `mcp-gen <file.ts>` emits the tool schemas as JSON on stdout, with parameter names, types, required-ness and descriptions all taken from the code
- `mcp-gen dev` opens a live playground that watches the file, renders an input form per tool, runs it in the browser and shows the result, the generated `inputSchema` and the raw JSON-RPC
- `mcp-gen serve` runs a real MCP server; `mcp-gen check` snapshots the tool surface and fails a build on breaking changes
- Resources and prompts from the same exports — a `@resource` tag with a URI (templated when the placeholders match parameter names), a `@prompt` tag for reusable templates, and an untagged function stays a tool
- Fail-loud handling: a function that cannot be converted to valid schema is excluded and reported rather than emitted broken, and the exit code tells you which case you hit
The npm package @zodromon/mcp-gen, version 1.2.0, installed globally or run through `npx`; the command is `mcp-gen` either way. Requires Node.js, and depends on the MCP SDK, ts-morph, typescript and jiti. `serve` binds `127.0.0.1` and port `3000` by default, and `dev` uses port `4000`.
One command — npm install -g @zodromon/mcp-gen
