Python 和 Node.js SDK 現已可用!
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 遵循規範和最佳實務,讓您可以自信地啟動服務。
確實只需幾行程式碼
- Python
- Node.js
mcp = FastMCP("MyMCPServer")
resource_identifier = "https://api.example.com"
mcp_auth = MCPAuth(
protected_resources=ResourceServerConfig(
metadata=ResourceServerMetadata(
resource=resource_identifier,
authorization_servers=[fetch_server_config('<auth-server-url>', AuthServerType.OIDC)],
scopes_supported=["read", "write"],
)
)
)
app = Starlette(
routes=[
*mcp_auth.resource_metadata_router().routes,
Mount('/', app=mcp.sse_app(), middleware=[Middleware(
mcp_auth.bearer_auth_middleware("jwt",
resource=resource_identifier,
audience=resource_identifier,
required_scopes=["read", "write"]
)
)])
]
)
@mcp.tool()
def whoami():
return mcp_auth.auth_info.claims
const server = new McpServer(/* ... */);
const resourceIdentifier = 'https://api.example.com';
const mcpAuth = new MCPAuth({
protectedResources: {
metadata: {
resource: resourceIdentifier,
authorizationServers: [await fetchServerConfig('<auth-server-url>', { type: 'oidc' })],
scopesSupported: ['read', 'write'],
}
}
});
const app = express();
app.use(mcpAuth.protectedResourceMetadataRouter());
app.use(mcpAuth.bearerAuth('jwt', {
resource: resourceIdentifier,
audience: resourceIdentifier,
requiredScopes: ['read', 'write']
}));
server.tool('whoami', ({ authInfo }) => {
return authInfo.claims;
});
MCP SDK 如何?
官方 MCP SDK(Python、Node.js 等)是很好的起點。MCP Auth 在所有教學中都使用它們,可以完美補充您現有的設定。
MCP Auth 彌補了認證和授權從「能用」到「安全、可擴展、可維護」之間的差距。
專為配合 SDK 工作而設計,提供:
- 一流的 JWT 支援
- 供應商無關的工具
- 各種身分供應商的逐步指南
此外,我們會跟進 MCP 規範和 SDK 的變更,讓您無需操心。