Explore real-world examples of MCP servers with different authentication providers. Each example demonstrates how to integrate popular auth services with your MCP applications.
A comprehensive example showing how to integrate Clerk's authentication system with your MCP server. Includes user management, session handling, and secure API endpoints.
// 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}`
}]
};
}
);
Enterprise-focused example demonstrating WorkOS integration for organizations requiring SSO, SCIM provisioning, and advanced user management capabilities.
// 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}`
}]
};
}
);
Modern authentication example using Stytch's passwordless solutions including magic links, SMS OTP, and biometric authentication for a seamless user experience.
// 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}`
}]
};
}
);
Have an example to share? Submit a pull request or open an issue.