This example demonstrates how to build a minimal Model Context Protocol (MCP) server in Go
{
"mcpServers": {
"mcp-server-go-example": {
"command": "<see-readme>",
"args": []
}
}
}No install config available. Check the server's README for setup instructions.
Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
This example demonstrates how to build a minimal Model Context Protocol (MCP) server in Go, using the mcp-go SDK. MCP is a lightweight JSON‑RPC‑based protocol that lets language model clients discover and invoke external tools in a structured way.
Is it safe?
No package registry to scan.
No authentication — any process on your machine can connect.
License not specified.
Is it maintained?
Last commit 325 days ago.
Will it work with my client?
Transport: stdio. Works with Claude Desktop, Cursor, Claude Code, and most MCP clients.
No automated test available for this server. Check the GitHub README for setup instructions.
No known vulnerabilities.
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Dynamic problem-solving through sequential thought chains
A Model Context Protocol server for searching and analyzing arXiv papers
An open-source AI agent that brings the power of Gemini directly into your terminal.
The official Python SDK for Model Context Protocol servers and clients
MCP Security Weekly
Get CVE alerts and security updates for Mcp Server Go Example and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
This example demonstrates how to build a minimal Model Context Protocol (MCP) server in Go, using the mcp-go SDK. MCP is a lightweight JSON‑RPC‑based protocol that lets language model clients discover and invoke external tools in a structured way.
With just a few lines of Go code, you can:
Server Initialization
mcpServer := server.NewMCPServer(
"Hello World MCP Server",
"1.0.0",
server.WithToolCapabilities(false),
)
Tool Definition
helloWorldTool := mcp.NewTool("hello_world",
mcp.WithDescription("Greet someone"),
mcp.WithString("name",
mcp.Required(),
mcp.Description("Person’s name"),
),
)
hello_world tool that accepts a single required string parameter name.Handler Registration
mcpServer.AddTool(helloWorldTool, func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
name, ok := req.Params.Arguments["name"].(string)
if !ok {
return nil, errors.New("name must be a string")
}
return mcp.NewToolResultText(fmt.Sprintf("Hello, %s!", name)), nil
})
hello_world tool with a Go function.name argument, validates it, and returns a greeting.Serving Over Stdio
if err := server.ServeStdio(mcpServer); err != nil {
fmt.Printf("Server error: %v\n", err)
}
Install Dependencies
go mod tidy
Build the Server
go build -o hello-mcp ./src/main.go
Connect from an MCP Client
hello-mcp executable.hello_world tool schema and let you invoke it.Example:
{
"mcpServers": {
"demo-go-mcp": {
"command": "path-to-server/hello-mcp"
}
}
}
or, use my MCP client made in Go
Enjoy building more complex workflows by adding additional tools, parameters, and transports (e.g., HTTP/SSE) as needed!