Stop Letting Every MCP Server Collect Its Own PAT: A Unified OAuth2 Front Door with Kong + AuthGate

cover

Once MCP (Model Context Protocol) exploded inside the company, almost every team ended up running an MCP server or two of their own: one fronting Gitea, one for Sentry, one for the internal Wiki, one for a database. They’re genuinely useful — but there’s a question everyone collectively ignored: how do these MCP servers actually authenticate?

The answer is usually unsettling: each one collects its own PAT (Personal Access Token). Every MCP server defines its own token, stuffs it into an environment variable, and validates it itself. So the company quietly accumulates a pile of static tokens — “long-lived, sitting in a file, equivalent to someone’s account” — scattered across dev machines, CI, even pasted into Slack messages. This post is about using Kong together with AuthGate to put a single OAuth2 front door in front of every MCP server and clean up that PAT sprawl in one move.

The full example code lives in go-authgate/kong-mcp-oauth2. This post walks through the motivation, the architecture, the security considerations, and the actual verification steps.

[Read More]

別再讓 MCP Server 各自收 PAT:用 Kong + AuthGate 做企業統一 OAuth2 入口

cover

MCP(Model Context Protocol) 在公司內部爆量之後,幾乎每個團隊都自己跑了一兩個 MCP Server:接 Gitea 的、接 Sentry 的、接內部 Wiki 的、接資料庫的。它們很好用,但有一個被集體忽略的問題——這些 MCP Server 到底是怎麼認證的?

答案多半令人不安:各自收各自的 PAT(Personal Access Token)。每個 MCP Server 自己定義一套 token、自己塞進環境變數、自己驗。於是公司內部出現了一堆「長期有效、放在檔案裡、等同某個帳號權限」的靜態 token,散落在開發機、CI、甚至貼在 Slack 訊息裡。這篇文章要談的,就是怎麼用 Kong 搭配 AuthGate,在所有 MCP Server 前面架起單一的 OAuth2 入口,把這堆 PAT 一次收掉。

完整的範例程式碼在 go-authgate/kong-mcp-oauth2,本文會帶你走過設計動機、架構、安全考量到實際驗證。

[Read More]

Introduction to OAuth Client ID Metadata Document

cover

In 2025, I introduced MCP (Model Context Protocol) at the iThome Taiwan Cloud Summit. At that time, I mentioned that the official team has been continuously revising the authentication protocol to address complex authentication flows. The previous design involved DCR (Dynamic Client Registration), so as expected, on 2025/11/25, a new Authorization mechanism was released. This authentication mechanism is called “Client ID Metadata Documents, abbreviated as CIMD”.

When installing a Model Context Protocol (MCP) server, the most challenging part is often not the protocol itself, but how to establish trust between the client and server. If you’ve ever tried to connect an MCP client to an MCP server it has never encountered before, you’ve probably run into what’s known as the “registration wall”.

Pre-registering with every possible authorization server is simply not scalable, and while Dynamic Client Registration (DCR) helps, it lacks reliable mechanisms to verify client identity, making it vulnerable to phishing attacks. Beyond security concerns, DCR also creates operational overhead by generating an ever-growing number of duplicate client identities that need to be managed.

[Read More]

OAuth Client ID Metadata Document 簡介

cover

2025 年在 iThome 臺灣雲端大會介紹過 MCP (Model Context Protocol),那時候就有提到在認證協議部分,官方其實一直都在改版解決複雜的認證流程,之前設計的 DCR (Dynamic Client Registration),所以沒意外去年 2025/11/25 又推出一版 Authorization 機制,此認證機制取名叫『Client ID Metadata Documents 簡稱 CIMD』。

安裝 Model Context Protocol(MCP)伺服器時,最棘手的部分往往不是協議本身,而是如何讓客戶端與伺服器彼此建立信任。如果你曾嘗試讓一個 MCP 客戶端連線到一個從未接觸過的 MCP 伺服器,你大概遇過所謂的「註冊高牆(registration wall)」。

要預先在每一個可能的授權伺服器完成註冊根本無法擴展,而 Dynamic Client Registration(DCR)雖然有所幫助,但因為缺乏可靠的機制來驗證客戶端身份,所以容易遭受網路釣魚攻擊。除了安全性問題之外,DCR 還會造成營運負擔,因為它會產生越來越多需要管理的重複客戶端身份。

[Read More]

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.

[Read More]

一步步學會用 Golang 開發 MCP 伺服器與客戶端 (Model Context Protocol)

blog logo

2025 年在台北 iThome 臺灣雲端大會 (CloudSummit) 給一場 Workshop,主題是「一步步學會用 Golang 開發 MCP 伺服器與客戶端 (Model Context Protocol)」。這次的工作坊旨在幫助開發者了解如何使用 Golang 實現 MCP 協議,並提供實際的程式碼範例和操作指南。我已經先將 Workshop 的內容整理成一個 GitHub Repo,您可以在 go-training/mcp-workshop 找到相關資源。詳細 Workshop 內容,請參考此連結

[Read More]