MCP Server Documentation

Enable AI assistants like Cursor and Claude to integrate Turalogin authentication directly into your codebase.

What is the Turalogin MCP Server?

The Turalogin MCP (Model Context Protocol) server allows AI coding assistants to interact with Turalogin's authentication API directly. Instead of just suggesting code, the AI can actually send magic links, verify tokens, and test your authentication flow. all from within your IDE.

Real API Calls

AI sends actual emails and verifies tokens via Turalogin

Any Framework

Works with Express, Next.js, Django, Flask, Rails, and more

IDE Integration

Test authentication without leaving your editor

Quick Start

Step 1: Get Your API Key

Visit the Turalogin dashboard, create an app, and generate an API key.

Step 2: Configure Your MCP Client

Add the Turalogin MCP server to your AI assistant's configuration:

For Cursor:

Settings → MCP Servers → Add this configuration:

{
  "mcpServers": {
    "turalogin": {
      "command": "npx",
      "args": ["-y", "@turalogin/mcp-server"],
      "env": {
        "TURALOGIN_API_KEY": "your_api_key_here"
      }
    }
  }
}

For Claude Desktop:

Edit claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/
  • Windows: %APPDATA%\Claude\
  • Linux: ~/.config/Claude/

Step 3: Ask AI to Add Authentication

Restart your AI assistant and ask it to integrate Turalogin:

"Add Turalogin magic link authentication to my Express app"

Available Tools

turalogin_start_auth

Start passwordless authentication for an email address. Sends a magic link or OTP code.

Parameters:
  • email (required) - User's email address
  • method (optional) - "one_time_login_link" or "otp" (default: one_time_login_link)
  • validationUrl (required for one_time_login_link) - Callback URL
Returns:
  • sessionId - Use to verify authentication
  • expiresAt - When the link/code expires (15 minutes)

turalogin_verify_auth

Verify an authentication session and get a JWT token.

Parameters:
  • sessionId (required) - Session ID from start_auth
  • code (optional) - OTP code if using OTP method
Returns:
  • token - JWT token for authenticated user
  • user - User object with id and email
  • expiresIn - Token expiration (24 hours)

turalogin_get_config

Get current MCP server configuration (for debugging). Shows API URL and whether API key is configured.

Authentication Flow

Magic Link Flow

1
User enters email
2
Backend calls turalogin_start_auth
3
User receives email with link
4
User clicks link → lands on your callback URL
5
Backend calls turalogin_verify_auth
6
Receive JWT + user info
7
Create session → User logged in ✓

OTP Flow

1
User enters email
2
Backend calls turalogin_start_auth (method: otp)
3
User receives email with 6-digit code
4
User enters code in your app
5
Backend calls turalogin_verify_auth with code
6
Receive JWT + user info
7
Create session → User logged in ✓

Example: Express.js Integration

Here's what the AI assistant generates when you ask it to add Turalogin authentication:

// POST /auth/login - Start authentication
app.post('/auth/login', async (req, res) => {
  const { email } = req.body;
  
  const response = await fetch('https://turalogin.com/api/v1/auth/start', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email,
      method: 'one_time_login_link',
      validationUrl: 'https://yourapp.com/auth/verify'
    })
  });
  
  const data = await response.json();
  res.json({ success: true, message: 'Check your email' });
});

// GET /auth/verify - Handle magic link callback
app.get('/auth/verify', async (req, res) => {
  const { token } = req.query;
  
  const response = await fetch('https://turalogin.com/api/v1/auth/verify', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ sessionId: token })
  });
  
  const data = await response.json();
  req.session.jwt = data.token;
  req.session.user = data.user;
  
  res.redirect('/dashboard');
});

Supported MCP Clients

Cursor
Claude Desktop
Cline
Continue

Works with any MCP-compatible AI coding assistant

Testing Your Setup

Once configured, test the MCP server by asking your AI assistant:

Test Configuration:

"Use turalogin_get_config to verify Turalogin is set up correctly"

Test Authentication:

"Send a test one time auth to test@turalogin.com"

Build Something:

"Add Turalogin authentication to my [framework] app"

Ready to Get Started?

Get your API key and start using AI-powered authentication integration.