Generate a complete Go Model Context Protocol server project using github.com/modelcontextprotocol/go-sdk with module layout, typed tools, resources, config, graceful shutdown, tests, and README. Use when the user asks for a Go MCP server project generator, Go MCP tools, stdio transport, or a production-ready MCP server scaffold.
Generate a complete Go MCP server project from a product/tool description by creating the module structure, typed handlers, configuration, documentation, and tests needed to run an official Go SDK server.
When to invoke
"Generate a Go MCP server project."
"Create a production-ready MCP server in Go."
"Scaffold Go tools using github.com/modelcontextprotocol/go-sdk."
"Build a stdio MCP server with typed inputs and outputs."
"Add config, tests, and README for a Go MCP server."
Inputs
Use $ARGUMENTS when direct invocation supplies a project name, module path, tool list, resource list, or project description. If $ARGUMENTS is empty, infer the smallest useful server from the user's request and ask no follow-up unless required values cannot be safely inferred.
Project skeleton
Create this directory tree, replacing {{PROJECT_NAME}} and github.com/yourusername/{{PROJECT_NAME}} with the actual project name and module path:
module github.com/yourusername/{{PROJECT_NAME}}, go 1.23, and github.com/modelcontextprotocol/go-sdk v1.0.0.
main.go
context.WithCancel, signal handling for os.Interrupt and syscall.SIGTERM, mcp.NewServer, mcp.Implementation, mcp.Options, mcp.ServerCapabilities, mcp.ToolsCapability, mcp.ResourcesCapability, mcp.PromptsCapability, mcp.StdioTransport, and server.Run.
tools/tool1.go
Tool1Input, Tool1Output, Tool1Handler, RegisterTool1, JSON and jsonschema tags, validation, context cancellation, and mcp.AddTool.
tools/registry.go
RegisterTools(server *mcp.Server) that calls RegisterTool1(server), RegisterTool2(server), and future registrations.
config/config.go
Config, Load, getEnv, SERVER_NAME, VERSION, and LOG_LEVEL defaults.
main_test.go
TestTool1Handler using context.Background, tools.Tool1Input, assertions for Status, nil result, and error handling.
README.md
Description, installation, usage, configuration, available tools, development commands, and license.
Core templates
Use these exact API names and placeholders when generating code: {{PROJECT_NAME}}, {{PROJECT_DESCRIPTION}}, {{TOOL1_DESCRIPTION}}, SERVER_NAME, VERSION, and LOG_LEVEL.
module github.com/yourusername/{{PROJECT_NAME}}
go 1.23
require (
github.com/modelcontextprotocol/go-sdk v1.0.0
)
Server Setup: keep main.go minimal; load config, create cancellation context, handle graceful shutdown, build mcp.NewServer, register tools, and run stdio transport.
Tools: create at least 2-3 useful tools with typed input/output structs, JSON schema documentation, focused names, single-purpose handlers, and descriptive errors.
Error Handling: validate inputs, check ctx.Err(), wrap or return useful errors, and avoid panics in handlers.
Documentation: document installation with go mod download and go build -o {{PROJECT_NAME}}, usage with ./{{PROJECT_NAME}}, available tools, inputs, outputs, and configuration.
Testing: include at least one test per tool and run go test ./...; build with go build -o {{PROJECT_NAME}}.
Generation rules
Area
Rule
Type Safety
Use structs with JSON schema tags for every tool input and output.
Configuration
Use environment variables through getEnv; document SERVER_NAME, VERSION, and LOG_LEVEL.
Logging
Prefer structured logging with log/slog; basic log is acceptable in minimal scaffolds.
Transport
Default to stdio and document alternatives instead of adding unrequested network listeners.
Resources
Add resources/resource1.go only when the generated server exposes MCP resources.
Tests
Test tool handlers directly without starting an external client.
Exports
Document all exported functions and keep package names descriptive.
README
Include {{PROJECT_DESCRIPTION}}, {{TOOL1_DESCRIPTION}}, install, usage, config, development, and MIT license sections.
SDK import and field names
Generated files import github.com/modelcontextprotocol/go-sdk/mcp where code references mcp. Keep package examples explicit about os/signal, handler inputs/outputs, JSON fields param1, param2, and status, and config struct field LogLevel.
go.mod uses the actual module path, go 1.23, and github.com/modelcontextprotocol/go-sdk v1.0.0.
main.go creates an mcp.NewServer, registers tools, uses mcp.StdioTransport, and handles os.Interrupt plus syscall.SIGTERM.
At least 2-3 useful tools exist and each has typed structs, JSON schema tags, validation, context cancellation, and tests.
config.Load reads SERVER_NAME, VERSION, and LOG_LEVEL with defaults.
README.md includes installation, usage, configuration, available tools, development commands, and license.
go test ./... and go build -o {{PROJECT_NAME}} were run or the blocker is reported.
1---2name: go-mcp-server-generator3description: Generate a complete Go Model Context Protocol server project using github.com/modelcontextprotocol/go-sdk with module layout, typed tools, resources, config, graceful shutdown, tests, and README. Use when the user asks for a Go MCP server project generator, Go MCP tools, stdio transport, or a production-ready MCP server scaffold.4---56<!-- Generated from harness/github-copilot/skills/go-mcp-server-generator/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# Go MCP server generator910Generate a complete Go MCP server project from a product/tool description by creating the module structure, typed handlers, configuration, documentation, and tests needed to run an official Go SDK server.1112## When to invoke1314- "Generate a Go MCP server project."15- "Create a production-ready MCP server in Go."16- "Scaffold Go tools using github.com/modelcontextprotocol/go-sdk."17- "Build a stdio MCP server with typed inputs and outputs."18- "Add config, tests, and README for a Go MCP server."1920## Inputs2122Use `$ARGUMENTS` when direct invocation supplies a project name, module path, tool list, resource list, or project description. If `$ARGUMENTS` is empty, infer the smallest useful server from the user's request and ask no follow-up unless required values cannot be safely inferred.2324## Project skeleton2526Create this directory tree, replacing `{{PROJECT_NAME}}` and `github.com/yourusername/{{PROJECT_NAME}}` with the actual project name and module path:2728```text29myserver/30├── go.mod31├── go.sum32├── main.go33├── tools/34│ ├── registry.go35│ ├── tool1.go36│ └── tool2.go37├── resources/38│ └── resource1.go39├── config/40│ └── config.go41├── README.md42└── main_test.go43```4445| File | Required content |46| --- | --- |47| `go.mod` | `module github.com/yourusername/{{PROJECT_NAME}}`, `go 1.23`, and `github.com/modelcontextprotocol/go-sdk v1.0.0`. |48| `main.go` | `context.WithCancel`, signal handling for `os.Interrupt` and `syscall.SIGTERM`, `mcp.NewServer`, `mcp.Implementation`, `mcp.Options`, `mcp.ServerCapabilities`, `mcp.ToolsCapability`, `mcp.ResourcesCapability`, `mcp.PromptsCapability`, `mcp.StdioTransport`, and `server.Run`. |49| `tools/tool1.go` | `Tool1Input`, `Tool1Output`, `Tool1Handler`, `RegisterTool1`, JSON and `jsonschema` tags, validation, context cancellation, and `mcp.AddTool`. |50| `tools/registry.go` | `RegisterTools(server *mcp.Server)` that calls `RegisterTool1(server)`, `RegisterTool2(server)`, and future registrations. |51| `config/config.go` | `Config`, `Load`, `getEnv`, `SERVER_NAME`, `VERSION`, and `LOG_LEVEL` defaults. |52| `main_test.go` | `TestTool1Handler` using `context.Background`, `tools.Tool1Input`, assertions for `Status`, nil `result`, and error handling. |53| `README.md` | Description, installation, usage, configuration, available tools, development commands, and license. |5455## Core templates5657Use these exact API names and placeholders when generating code: `{{PROJECT_NAME}}`, `{{PROJECT_DESCRIPTION}}`, `{{TOOL1_DESCRIPTION}}`, `SERVER_NAME`, `VERSION`, and `LOG_LEVEL`.5859```go60module github.com/yourusername/{{PROJECT_NAME}}6162go 1.236364require (65 github.com/modelcontextprotocol/go-sdk v1.0.066)67```6869```go70server := mcp.NewServer(71 &mcp.Implementation{Name: cfg.ServerName, Version: cfg.Version},72 &mcp.Options{Capabilities: &mcp.ServerCapabilities{73 Tools: &mcp.ToolsCapability{}, Resources: &mcp.ResourcesCapability{}, Prompts: &mcp.PromptsCapability{},74 }},75)76tools.RegisterTools(server)77transport := &mcp.StdioTransport{}78if err := server.Run(ctx, transport); err != nil { log.Fatalf("Server error: %v", err) }79```8081```go82type Tool1Input struct {83 Param1 string `json:"param1" jsonschema:"required,description=First parameter"`84 Param2 int `json:"param2,omitempty" jsonschema:"description=Optional second parameter"`85}8687type Tool1Output struct {88 Result string `json:"result" jsonschema:"description=The result of the operation"`89 Status string `json:"status" jsonschema:"description=Operation status"`90}9192func Tool1Handler(ctx context.Context, req *mcp.CallToolRequest, input Tool1Input) (*mcp.CallToolResult, Tool1Output, error) {93 if input.Param1 == "" { return nil, Tool1Output{}, fmt.Errorf("param1 is required") }94 if ctx.Err() != nil { return nil, Tool1Output{}, ctx.Err() }95 return nil, Tool1Output{Result: fmt.Sprintf("Processed: %s", input.Param1), Status: "success"}, nil96}97```9899## Procedure1001011. Initialize Module: create `go.mod` with the module path, `go 1.23`, and the official SDK dependency.1022. Structure: create `main.go`, `tools/`, `resources/`, `config/`, `README.md`, and `main_test.go` exactly once.1033. Server Setup: keep `main.go` minimal; load config, create cancellation context, handle graceful shutdown, build `mcp.NewServer`, register tools, and run stdio transport.1044. Tools: create at least 2-3 useful tools with typed input/output structs, JSON schema documentation, focused names, single-purpose handlers, and descriptive errors.1055. Error Handling: validate inputs, check `ctx.Err()`, wrap or return useful errors, and avoid panics in handlers.1066. Documentation: document installation with `go mod download` and `go build -o {{PROJECT_NAME}}`, usage with `./{{PROJECT_NAME}}`, available tools, inputs, outputs, and configuration.1077. Testing: include at least one test per tool and run `go test ./...`; build with `go build -o {{PROJECT_NAME}}`.108109## Generation rules110111| Area | Rule |112| --- | --- |113| Type Safety | Use structs with JSON schema tags for every tool input and output. |114| Configuration | Use environment variables through `getEnv`; document `SERVER_NAME`, `VERSION`, and `LOG_LEVEL`. |115| Logging | Prefer structured logging with `log/slog`; basic `log` is acceptable in minimal scaffolds. |116| Transport | Default to stdio and document alternatives instead of adding unrequested network listeners. |117| Resources | Add `resources/resource1.go` only when the generated server exposes MCP resources. |118| Tests | Test tool handlers directly without starting an external client. |119| Exports | Document all exported functions and keep package names descriptive. |120| README | Include `{{PROJECT_DESCRIPTION}}`, `{{TOOL1_DESCRIPTION}}`, install, usage, config, development, and MIT license sections. |121122## SDK import and field names123124Generated files import `github.com/modelcontextprotocol/go-sdk/mcp` where code references `mcp`. Keep package examples explicit about `os/signal`, handler inputs/outputs, JSON fields `param1`, `param2`, and `status`, and config struct field `LogLevel`.125126## Output template127128```markdown129## Go MCP server scaffold - <project name>130131**Status:** generated | needs input | blocked132**Module:** `github.com/<owner>/<project>`133**SDK:** `github.com/modelcontextprotocol/go-sdk`134135| File | Purpose | Notes |136| --- | --- | --- |137| `go.mod` | Module and dependencies | `go 1.23`, SDK pinned |138| `main.go` | Server bootstrap | stdio transport and graceful shutdown |139| `tools/<tool>.go` | Tool handlers | typed input/output and validation |140| `config/config.go` | Environment config | `SERVER_NAME`, `VERSION`, `LOG_LEVEL` |141| `main_test.go` | Handler tests | `go test ./...` |142| `README.md` | Usage documentation | install, run, config, tools |143144### Commands145- `go mod download`146- `go test ./...`147- `go build -o <project>`148149### Validation150- `go test ./...`: pass | fail151- `go build -o <project>`: pass | fail152```153154## Quality gate155156- [ ] `go.mod` uses the actual module path, `go 1.23`, and `github.com/modelcontextprotocol/go-sdk v1.0.0`.157- [ ] `main.go` creates an `mcp.NewServer`, registers tools, uses `mcp.StdioTransport`, and handles `os.Interrupt` plus `syscall.SIGTERM`.158- [ ] At least 2-3 useful tools exist and each has typed structs, JSON schema tags, validation, context cancellation, and tests.159- [ ] `config.Load` reads `SERVER_NAME`, `VERSION`, and `LOG_LEVEL` with defaults.160- [ ] `README.md` includes installation, usage, configuration, available tools, development commands, and license.161- [ ] `go test ./...` and `go build -o {{PROJECT_NAME}}` were run or the blocker is reported.
Run npx skillmds@latest add paulasilvatech/go-mcp-server-generator in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Generate a complete Go Model Context Protocol server project using github.com/modelcontextprotocol/go-sdk with module layout, typed tools, resources, config, graceful shutdown, tests, and README. Use when the user asks for a Go MCP server project generator, Go MCP tools, stdio transport, or a production-ready MCP server scaffold. It is listed under AI & ML on SkillMD.
SkillMD's automated safety review verdict for this skill is PASS. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
paulasilvatech (@paulasilvatech) published this skill. Their other Agent Skills are listed on their SkillMD profile.