Step-by-Step Guide to Building MCP Server and Client with Golang (Model Context Protocol)

blog logo

In 2025, I delivered a workshop at the iThome Taiwan Cloud Summit in Taipei, titled “Step-by-Step Guide to Building MCP Server and Client with Golang (Model Context Protocol)”. The goal of this workshop was to help developers understand how to implement the MCP protocol using Golang, providing practical code examples and hands-on guidance. I have organized all workshop materials into a GitHub repository, which you can find at go-training/mcp-workshop. For detailed workshop content, please refer to this link.

Workshop Content

This workshop is composed of a series of practical modules, each demonstrating how to build an MCP (Model Context Protocol) server and its foundational infrastructure in Go.

  • 01. Basic MCP Server:

    • Provides a minimal MCP server implementation supporting both stdio and HTTP, using Gin. Demonstrates server setup, tool registration, and best practices for logging and error handling.
    • Key features: Dual stdio/HTTP channels, Gin integration, extensible tool registration
  • 02. Basic Token Passthrough:

    • Supports transparent authentication token passthrough for HTTP and stdio, explaining context injection and tool development for authenticated requests.
    • Key features: Token passthrough, context injection, authentication tool examples
  • 03. OAuth MCP Server:

    • An MCP server protected by OAuth 2.0, demonstrating authorization, token, and resource metadata endpoints, including context token handling and tools for API authentication.
    • Key features: OAuth 2.0 flow, protected endpoints, context token propagation, demo tools
  • 04. Observability:

    • Observability and tracing for MCP servers, integrating OpenTelemetry and structured logging, including metrics, detailed tracing, and error reporting.
    • Key features: Tracing, structured logging, observability middleware, error reporting
  • 05. MCP Proxy:

    • A proxy server that aggregates multiple MCP servers into a single endpoint. Supports real-time streaming, centralized configuration, and enhanced security.
    • Key features: Unified entry point, SSE/HTTP streaming, flexible configuration, improved security

Slides

The slides for this workshop have been uploaded to Speaker Deck and can be viewed here. In the 90-minute workshop, there was no time for everyone to practice because the OAuth flow in MCP is more complex, so a lot of time was spent explaining this part. I will write another article to introduce how to implement the OAuth flow in Golang.

oauth flow

For the complete OAuth token flow, see the MCP specification. The detailed process can be seen in the simplified diagram below:

oauth flow

I will explain in detail how to implement this flow in Golang in a future article.

On-site Photos

The event was attended by approximately 40 people. The venue was very spacious and lunch was provided. Thanks to the iThome team for the arrangements.

workshop01

workshop02