Model Context Protocol (MCP) server for go-zero framework - Generate APIs, RPC services, and models with AI assistance.
Go
47
13 commits
updated Jan 31, 2026
A Model Context Protocol (MCP) tool that helps developers quickly scaffold and generate go-zero projects with ease.
New to mcp-zero? Check out our Quick Start Guide for a step-by-step tutorial on getting started!
The quickstart covers:
Go (1.19 or later)
go-zero CLI (goctl): Install with go install github.com/zeromicro/go-zero/tools/goctl@latest
Claude Desktop (or other MCP-compatible client)
For detailed installation instructions, see the Quick Start Guide.
Create a new directory for your MCP tool:
mkdir go-zero-mcp && cd go-zero-mcp
Initialize Go module:
go mod init go-zero-mcp
Install dependencies:
go get github.com/modelcontextprotocol/go-sdk
go get gopkg.in/yaml.v3
Save the main tool code as main.go
Build the tool:
go build -o go-zero-mcp main.go
Add this configuration to your Claude Desktop MCP settings:
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"mcp-zero": {
"command": "/path/to/your/mcp-zero",
"env": {
"GOCTL_PATH": "/Users/yourname/go/bin/goctl"
}
}
}
}
Edit ~/.config/Claude/claude_desktop_config.json:
{
"mcpServers": {
"mcp-zero": {
"command": "/path/to/your/mcp-zero",
"env": {
"GOCTL_PATH": "/usr/local/bin/goctl"
}
}
}
}
Edit %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"mcp-zero": {
"command": "C:\\path\\to\\your\\mcp-zero.exe",
"env": {
"GOCTL_PATH": "C:\\Go\\bin\\goctl.exe"
}
}
}
}
Creates a new go-zero API service.
Parameters:
service_name (required): Name of the API serviceport (optional): Port number (default: 8888)style (optional): Code style - "go_zero" or "gozero" (default: "go_zero")output_dir (optional): Output directory (default: current directory)Creates a new go-zero RPC service from protobuf definition.
Parameters:
service_name (required): Name of the RPC serviceproto_content (required): Protobuf definition contentoutput_dir (optional): Output directory (default: current directory)Generates go-zero API code from an API specification file.
Parameters:
api_file (required): Path to the .api specification fileoutput_dir (optional): Output directory (default: current directory)style (optional): Code style - "go_zero" or "gozero" (default: "go_zero")Generates database model code from database schema.
Parameters:
source_type (required): Source type - "mysql", "postgresql", "mongo", or "ddl"source (required): Database connection string or DDL file pathtable (optional): Specific table name (for database sources)output_dir (optional): Output directory (default: "./model")Creates a sample API specification file.
Parameters:
service_name (required): Name of the API serviceendpoints (required): Array of endpoint objects with method, path, and handleroutput_file (optional): Output file path (default: service_name.api)Analyzes an existing go-zero project structure and dependencies.
Parameters:
project_dir (required): Path to the project directoryanalysis_type (optional): Type of analysis - "api", "rpc", "model", or "full" (default: "full")Generates configuration files for go-zero services.
Parameters:
service_name (required): Name of the serviceservice_type (required): Service type - "api" or "rpc"config_type (optional): Configuration type - "dev", "test", or "prod" (default: "dev")output_file (optional): Output file path (default: etc/{service_name}.yaml)Generates common code templates for go-zero services.
Parameters:
template_type (required): Template type - "middleware", "error_handler", "dockerfile", "docker_compose", or "kubernetes"service_name (required): Name of the serviceoutput_path (optional): Output file path (uses defaults based on template type)Queries go-zero documentation and migration guides.
Parameters:
query (required): Natural language query about go-zero concepts or migrationdoc_type (optional): Documentation type - "concept", "migration", or "both" (default: "both")Validates API specs, protobuf definitions, or configuration files.
Parameters:
input_type (required): Input type - "api_spec", "proto", or "config"content (required): Content to validatestrict (optional): Enable strict validation mode (default: false)Please create a new go-zero API service called "user-service" on port 8080
Create a new go-zero RPC service called "auth-service" with this protobuf definition:
syntax = "proto3";
package auth;
option go_package = "./auth";
service AuthService {
rpc Login(LoginRequest) returns (LoginResponse);
rpc Logout(LogoutRequest) returns (LogoutResponse);
}
message LoginRequest {
string username = 1;
string password = 2;
}
message LoginResponse {
string token = 1;
int64 expires_at = 2;
}
message LogoutRequest {
string token = 1;
}
message LogoutResponse {
bool success = 1;
}
Generate go-zero models from my MySQL database with connection string "user:password@tcp(localhost:3306)/mydb"
Create an API specification for a "blog-service" with these endpoints:
- GET /api/posts (handler: GetPostsHandler)
- POST /api/posts (handler: CreatePostHandler)
- GET /api/posts/:id (handler: GetPostHandler)
- PUT /api/posts/:id (handler: UpdatePostHandler)
- DELETE /api/posts/:id (handler: DeletePostHandler)
Analyze my go-zero project in /path/to/myproject to understand its structure
Generate a production configuration file for my "order-service" API service
Generate a middleware template for my "auth-service"
How do I implement JWT authentication in go-zero?
How do I migrate from Express.js to go-zero?
Validate this API spec file at /path/to/service.api with strict mode enabled
After building, your MCP server will have the following structure:
mcp-zero/
├── main.go # Entry point and tool registration
├── tools/ # Tool implementations
│ ├── create_api_service.go
│ ├── create_rpc_service.go
│ ├── generate_api.go
│ ├── generate_model.go
│ ├── create_api_spec.go
│ ├── analyze_project.go
│ ├── generate_config.go
│ ├── generate_template.go
│ ├── query_docs.go
│ └── validate_input.go
├── internal/ # Internal packages
│ ├── analyzer/ # Project analysis
│ ├── validation/ # Input validation
│ ├── security/ # Credential handling
│ ├── templates/ # Code templates
│ ├── docs/ # Documentation database
│ ├── logging/ # Structured logging
│ └── metrics/ # Performance metrics
└── tests/ # Test suites
├── integration/
└── unit/
The MCP server is built with:
To enable debug logging, set the environment variable:
export MCP_DEBUG=1
Feel free to extend this tool with additional go-zero features such as:
MIT License - see LICENSE file for details.
Copyright (c) 2025 go-zero team
Model Context Protocol (MCP) server for go-zero framework - Generate APIs, RPC services, and models with AI assistance.
Go
47
13 commits
updated Jan 31, 2026
A Model Context Protocol (MCP) tool that helps developers quickly scaffold and generate go-zero projects with ease.
New to mcp-zero? Check out our Quick Start Guide for a step-by-step tutorial on getting started!
The quickstart covers:
Go (1.19 or later)
go-zero CLI (goctl): Install with go install github.com/zeromicro/go-zero/tools/goctl@latest
Claude Desktop (or other MCP-compatible client)
For detailed installation instructions, see the Quick Start Guide.
Create a new directory for your MCP tool:
mkdir go-zero-mcp && cd go-zero-mcp
Initialize Go module:
go mod init go-zero-mcp
Install dependencies:
go get github.com/modelcontextprotocol/go-sdk
go get gopkg.in/yaml.v3
Save the main tool code as main.go
Build the tool:
go build -o go-zero-mcp main.go
Add this configuration to your Claude Desktop MCP settings:
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"mcp-zero": {
"command": "/path/to/your/mcp-zero",
"env": {
"GOCTL_PATH": "/Users/yourname/go/bin/goctl"
}
}
}
}
Edit ~/.config/Claude/claude_desktop_config.json:
{
"mcpServers": {
"mcp-zero": {
"command": "/path/to/your/mcp-zero",
"env": {
"GOCTL_PATH": "/usr/local/bin/goctl"
}
}
}
}
Edit %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"mcp-zero": {
"command": "C:\\path\\to\\your\\mcp-zero.exe",
"env": {
"GOCTL_PATH": "C:\\Go\\bin\\goctl.exe"
}
}
}
}
Creates a new go-zero API service.
Parameters:
service_name (required): Name of the API serviceport (optional): Port number (default: 8888)style (optional): Code style - "go_zero" or "gozero" (default: "go_zero")output_dir (optional): Output directory (default: current directory)Creates a new go-zero RPC service from protobuf definition.
Parameters:
service_name (required): Name of the RPC serviceproto_content (required): Protobuf definition contentoutput_dir (optional): Output directory (default: current directory)Generates go-zero API code from an API specification file.
Parameters:
api_file (required): Path to the .api specification fileoutput_dir (optional): Output directory (default: current directory)style (optional): Code style - "go_zero" or "gozero" (default: "go_zero")Generates database model code from database schema.
Parameters:
source_type (required): Source type - "mysql", "postgresql", "mongo", or "ddl"source (required): Database connection string or DDL file pathtable (optional): Specific table name (for database sources)output_dir (optional): Output directory (default: "./model")Creates a sample API specification file.
Parameters:
service_name (required): Name of the API serviceendpoints (required): Array of endpoint objects with method, path, and handleroutput_file (optional): Output file path (default: service_name.api)Analyzes an existing go-zero project structure and dependencies.
Parameters:
project_dir (required): Path to the project directoryanalysis_type (optional): Type of analysis - "api", "rpc", "model", or "full" (default: "full")Generates configuration files for go-zero services.
Parameters:
service_name (required): Name of the serviceservice_type (required): Service type - "api" or "rpc"config_type (optional): Configuration type - "dev", "test", or "prod" (default: "dev")output_file (optional): Output file path (default: etc/{service_name}.yaml)Generates common code templates for go-zero services.
Parameters:
template_type (required): Template type - "middleware", "error_handler", "dockerfile", "docker_compose", or "kubernetes"service_name (required): Name of the serviceoutput_path (optional): Output file path (uses defaults based on template type)Queries go-zero documentation and migration guides.
Parameters:
query (required): Natural language query about go-zero concepts or migrationdoc_type (optional): Documentation type - "concept", "migration", or "both" (default: "both")Validates API specs, protobuf definitions, or configuration files.
Parameters:
input_type (required): Input type - "api_spec", "proto", or "config"content (required): Content to validatestrict (optional): Enable strict validation mode (default: false)Please create a new go-zero API service called "user-service" on port 8080
Create a new go-zero RPC service called "auth-service" with this protobuf definition:
syntax = "proto3";
package auth;
option go_package = "./auth";
service AuthService {
rpc Login(LoginRequest) returns (LoginResponse);
rpc Logout(LogoutRequest) returns (LogoutResponse);
}
message LoginRequest {
string username = 1;
string password = 2;
}
message LoginResponse {
string token = 1;
int64 expires_at = 2;
}
message LogoutRequest {
string token = 1;
}
message LogoutResponse {
bool success = 1;
}
Generate go-zero models from my MySQL database with connection string "user:password@tcp(localhost:3306)/mydb"
Create an API specification for a "blog-service" with these endpoints:
- GET /api/posts (handler: GetPostsHandler)
- POST /api/posts (handler: CreatePostHandler)
- GET /api/posts/:id (handler: GetPostHandler)
- PUT /api/posts/:id (handler: UpdatePostHandler)
- DELETE /api/posts/:id (handler: DeletePostHandler)
Analyze my go-zero project in /path/to/myproject to understand its structure
Generate a production configuration file for my "order-service" API service
Generate a middleware template for my "auth-service"
How do I implement JWT authentication in go-zero?
How do I migrate from Express.js to go-zero?
Validate this API spec file at /path/to/service.api with strict mode enabled
After building, your MCP server will have the following structure:
mcp-zero/
├── main.go # Entry point and tool registration
├── tools/ # Tool implementations
│ ├── create_api_service.go
│ ├── create_rpc_service.go
│ ├── generate_api.go
│ ├── generate_model.go
│ ├── create_api_spec.go
│ ├── analyze_project.go
│ ├── generate_config.go
│ ├── generate_template.go
│ ├── query_docs.go
│ └── validate_input.go
├── internal/ # Internal packages
│ ├── analyzer/ # Project analysis
│ ├── validation/ # Input validation
│ ├── security/ # Credential handling
│ ├── templates/ # Code templates
│ ├── docs/ # Documentation database
│ ├── logging/ # Structured logging
│ └── metrics/ # Performance metrics
└── tests/ # Test suites
├── integration/
└── unit/
The MCP server is built with:
To enable debug logging, set the environment variable:
export MCP_DEBUG=1
Feel free to extend this tool with additional go-zero features such as:
MIT License - see LICENSE file for details.
Copyright (c) 2025 go-zero team