Test magic link login with an AI agent

· 5 min read · QuickInbox team

  • Magic links
  • AI agents
  • MCP

Passwordless login looks simple: type your email, click the link. But the link can expire too fast, point to the wrong domain or work only once by accident. An AI agent with a test inbox can check all of it in one run.

What can go wrong with magic links

  • The link points to production while you test staging, or to localhost in production.
  • The token expires before a normal person could open it.
  • Opening the link twice signs in twice, or the second click shows an error page with no way back.
  • Link scanners in mail clients "click" the link first and use it up.

Set up

Connect the QuickInbox MCP server to your agent (see Claude Code or Cursor) and give the agent a browser tool so it can open pages.

The prompt

Test our magic link login on http://localhost:3000/login:
1. Create a new QuickInbox address and request a login link for it.
2. Use quickinbox_get_verification to get the link from the email.
3. Check the link's domain matches the app, then open it.
4. Confirm I'm signed in, then open the same link again and tell me what happens.

quickinbox_get_verification returns the code or link from the newest matching email, so the agent doesn't have to parse HTML. If it needs the full email, it can call quickinbox_get_emails for the same tag.

Turn it into a regular test

When the agent has shown the flow works, ask it to write the same steps as code. Your test can read the inbox with the REST API:

// Read the newest email for one test address (Node 18+)
const ns = 'acme7x', tag = 'magic-1';
const res = await fetch(
  `https://business.quickinbox.net/api/business/mail?namespace=${ns}&limit=20`,
  { headers: { 'X-API-Key': process.env.QI_KEY } },
);
const { messages } = await res.json();
const email = messages.find((m) => m.to === `${ns}.${tag}`);
const link = email.html.match(/href="([^"]*\/auth\/[^"]+)"/)[1].replace(/&/g, '&');

More patterns in how to test magic link login.

Related guides

Try it: the QuickInbox MCP server is included on every plan, including the free plan with 5,000 emails a month. Create a free account, make an API key and connect your agent in two minutes.

← All articles