Get the FREE Ultimate OpenClaw Setup Guide →

kd-gen

The kd-gen is a Go code generation tool designed to create type-safe enums from YAML configuration files. This tool automates the generation of Go enum types along with their associated helper methods, enhancing code safety and reducing boilerplate.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio khuong02-kd-gen docker run --rm -v $(pwd):/app -w /app kd-gen enum gen --package core --output ./example/enum/enum_gen.go --config ./example/enum/enum.yaml \
  --env DOCKER_DEFAULT_PLATFORM="linux/amd64"

How to use

KD Gen is a Go-based code generation tool that creates type-safe Go enums from YAML configuration files. It supports various enum types (string, int, uint64, etc.), automatic JSON marshaling/unmarshaling, and database/sql integration helpers. The CLI exposes multiple utilities under the Tools table, such as generating enum code from YAML, listing supported methods, validating configurations, and explaining enum mappings. To use it, define your enums in YAML, then run the generate command to produce Go code that includes the enum type, constants, and helper methods like String(), Parse(), and Normalize(). The MCP integration allows Claude Desktop to call these tools directly via an MCP server, enabling automated, model-driven code generation within your workflow.

How to install

Prerequisites:

  • Docker installed and running (for the Docker-based setup shown here) or Go installed if building locally.
  • Git (for cloning the repository if you choose to build from source).

Option A: Build from source (Go)

  1. Clone the repository: git clone https://github.com/khuong02/kd-gen.git cd kd-gen
  2. Build the binary: go build -o ./build/kd-gen main.go
  3. (Optional) Move to a directory in your PATH: mv ./build/kd-gen /usr/local/bin/

Option B: Using Docker (recommended per README)

  1. Build the Docker image: docker build -t kd-gen .
  2. Run the container with your config to generate code: docker run --rm -v $(pwd):/app -w /app kd-gen enum gen --package core --output ./example/enum/enum_gen.go --config ./example/enum/enum.yaml

Option C: Install via Homebrew (macOS)

  1. Add the custom tap and install kd-gen: brew tap khuong02/tap https://github.com/khuong02/homebrew-tap brew install kd-gen

Option D: Using Go's module proxy (for direct module-based installation)

  1. Install the latest version: go install github.com/khuong02/kd-gen@latest

Additional notes

Tips and notes:

  • The MCP integration allows tools to be invoked remotely; ensure your MCP client is configured to communicate with this server as described in MCP_GUIDE.md.
  • The YAML configuration format supports defining enums with names, types (string, int, etc.), and optional display/code mappings. Generated code includes String(), Parse(), Normalize(), and JSON/SQL integration helpers where applicable.
  • If you run into path or permission issues inside Docker, verify volume mounts and the working directory (-w) alignment with where you keep your YAML config and output paths.
  • The Docker approach builds a self-contained binary environment, ensuring consistent tool behavior across platforms.
  • The npm_package field is not applicable since this server is a Go-based CLI tool, so it is set to null.

Related MCP Servers

Sponsor this space

Reach thousands of developers