MCP Auth 1.0 for Node.js is here, built for the MCP TypeScript SDK v2!
Plug-and-play MCP 伺服器認證
MCP Auth 為您的 MCP 伺服器提供所有必需的生產級認證功能。無需花費數週時間閱讀規範和連接設定。
為什麼選擇 MCP Auth?
跳過規範。跳過樣板程式碼。專注認證。
MCP 規範需要 OAuth 2.1 和其他 RFC,為認證提供堅實基礎。使用 MCP Auth,您只需幾行程式碼即可連接到可信任的供應商。
連接任何供應商。這是供應商無關的。
MCP Auth 可與任何相容 OAuth 2.1 或 OpenID Connect 的供應商配合使用。從我們的已驗證清單中選擇,或使用工具檢查您的供應商是否合規。
快速部署,安全可靠。
準備投入生產?我們為您提供支援。MCP Auth 遵循規範和最佳實務,讓您可以自信地啟動服務。
確實只需幾行程式碼
// 1. Declare this MCP server and the authorization server it trusts
const mcpAuth = new MCPAuth({
protectedResourceMetadata: {
resource: 'https://api.example.com/mcp',
authorizationServer: { issuer: 'https://auth.example.com/oidc', type: 'oidc' },
scopesSupported: ['read', 'write'],
},
});
// 2. Gate your MCP endpoint with the MCP SDK's `requireBearerAuth`:
// signature, issuer, audience, expiration, and scopes all enforced
const gate = requireBearerAuth(mcpAuth.getBearerAuthOptions({ requiredScopes: ['read'] }));
// 3. Serve the OAuth discovery documents with the MCP SDK's metadata helpers
const metadata = oauthMetadataResponse(request, await mcpAuth.getAuthMetadataOptions());
// 4. Read the verified identity in your tools
server.registerTool(
'whoami',
{
description: 'Returns the current user info',
},
(context) => {
const { subject, claims } = getAuthInfo(context);
return { content: [{ type: 'text', text: JSON.stringify({ subject, claims }) }] };
}
);MCP SDK 如何?
The official MCP SDKs now ship the HTTP layer of MCP authorization themselves: bearer auth middleware, metadata endpoints, and framework adapters. What they ask you to bring is provider integration: a token verifier and your auth metadata.
MCP Auth gives you both, for any OAuth 2.0 / OpenID Connect provider.
You could write the verifier yourself; a correct one is about a hundred lines with a JWT library. These are the parts that tend to go wrong silently:
- Audience binding (RFC 8707): required by the MCP spec, left to the verifier by the SDK. MCP Auth always validates the
audclaim against your resource identifier, with no opt-out. - Expiration mapping: miss the
exp→expiresAtmapping and the SDK rejects every token. MCP Auth maps it automatically. - Error mapping: raw JWT-library errors surface as 500s with no challenge, so clients never re-authorize. MCP Auth turns verification failures into proper 401 challenges.
- Claim quirks across providers:
scopestrings vs.scopesarrays,client_idvs.azp: all handled. - Discovery hygiene: issuer validation, cached metadata and JWKS fetches, and cache reset on transient failures, all built in.
Or: all of the above is one MCPAuth instance, tested and kept up to date as the MCP spec and SDKs evolve.
What stays in your hands: provider-side configuration (audience, scopes, client registration), permission design, and your app-level authorization. That is exactly what the tutorials and provider guides walk you through.