Examples
Explore real-world examples of MCP servers with different authentication providers. Each example demonstrates how to integrate popular auth services with your MCP applications.
AuthenticationProduction ReadyOpen Source
Clerk Authentication
Complete user management with Clerk's authentication platform
Next.jsOAuth
A comprehensive example showing how to integrate Clerk's authentication system with your MCP server. Includes user management, session handling, and secure API endpoints.
Features
- • User sign-up and sign-in
- • Session management
- • Protected MCP endpoints
- • User profile integration
Tech Stack
- • Next.js 14
- • Clerk SDK
- • TypeScript
- • MCP Handler
// Example: Protected MCP tool with Clerk
server.tool(
"get_user_data",
"Get authenticated user data",
{ userId: z.string() },
async ({ userId }, extra) => {
const user = await clerkClient.users.getUser(userId);
return {
content: [{
type: "text",
text: `User: ${user.firstName} ${user.lastName}`
}]
};
}
);WorkOS Enterprise Auth
Enterprise-grade authentication with SSO and directory sync
EnterpriseSSO
Enterprise-focused example demonstrating WorkOS integration for organizations requiring SSO, SCIM provisioning, and advanced user management capabilities.
Features
- • Single Sign-On (SSO)
- • Directory sync (SCIM)
- • Multi-tenant support
- • Audit logs
Tech Stack
- • Next.js 14
- • WorkOS SDK
- • TypeScript
- • MCP Handler
// Example: SSO-protected MCP endpoint
server.tool(
"get_organization_data",
"Get organization data via SSO",
{ orgId: z.string() },
async ({ orgId }, extra) => {
const org = await workos.organizations.getOrganization(orgId);
return {
content: [{
type: "text",
text: `Organization: ${org.name}`
}]
};
}
);Stytch Passwordless Auth
Modern passwordless authentication with magic links and OTP
PasswordlessMagic Links
Modern authentication example using Stytch's passwordless solutions including magic links, SMS OTP, and biometric authentication for a seamless user experience.
Features
- • Magic link authentication
- • SMS and email OTP
- • Biometric authentication
- • Session management
Tech Stack
- • Next.js 14
- • Stytch SDK
- • TypeScript
- • MCP Handler
// Example: Magic link protected endpoint
server.tool(
"send_magic_link",
"Send magic link for authentication",
{ email: z.string().email() },
async ({ email }, extra) => {
const response = await stytch.magicLinks.email.send({
email,
login_magic_link_url: "https://app.com/authenticate",
});
return {
content: [{
type: "text",
text: `Magic link sent to ${email}`
}]
};
}
);Ready to Build Your Own?
Choose an authentication provider that fits your needs and start building secure MCP applications.
Have an example to share? Submit a pull request or open an issue.