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 的变更,让您无需操心。