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.
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)
- Clone the repository: git clone https://github.com/khuong02/kd-gen.git cd kd-gen
- Build the binary: go build -o ./build/kd-gen main.go
- (Optional) Move to a directory in your PATH: mv ./build/kd-gen /usr/local/bin/
Option B: Using Docker (recommended per README)
- Build the Docker image: docker build -t kd-gen .
- 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)
- 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)
- 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
weather
A lightweight Model Context Protocol (MCP) server that enables AI assistants like Claude to retrieve and interpret real-time weather data. Discuss on Hacker News:
sandbox
A Model Context Protocol (MCP) server that enables LLMs to run ANY code safely in isolated Docker containers.
github-brain
An experimental GitHub MCP server with local database.
mcp-tts
MCP Server for Text to Speech
tasker
An MCP server for Android's Tasker automation app.
kai
An MCP Server for Kubernetes