Skip to content

feat: MCP inline email auth — frictionless onboarding without a pre-existing Trinity account #848

Closed

Description

@vybe

Summary

Add two unauthenticated MCP tools (request_login and verify_login) that let a user authenticate to Trinity directly from their MCP client — no web UI visit, no pre-created API key required. After a successful inline login, the MCP session is credentialed and the user gains access to a scoped subset of tools (e.g. exposed agents they are authorized for).

Context

Today, using the Trinity MCP server requires a user to: (1) log into the web UI, (2) navigate to Settings → MCP Keys, (3) generate a trinity_mcp_* key, and (4) paste it into their .mcp.json. This is a significant barrier for sharing agents with external users or light collaborators.

The goal is a zero-friction path analogous to Telegram's inline /login flow: the user drops in a default MCP config (no key needed), calls request_login with their email, receives a 6-digit verification code, calls verify_login with the code, and is done. The MCP server issues a session credential and they immediately have access to whatever agents they are authorized for.

⚠️ Design confirmation required with Eugene before implementation. The auth flow, session credential lifecycle, and tool-visibility rules after inline login need explicit sign-off.

Design Questions (to resolve before implementation)

  • After inline login, does the MCP server return a trinity_mcp_* key for the user to persist in their config, or manage the session transiently?
  • Which tools are visible to an inline-authenticated session vs. a full API-key session? (Proposal: only tools for mcp_exposed agents the user is authorized for)
  • How is the inline session credential stored and expired server-side? (Redis with TTL, same as Telegram pending-login pattern?)
  • Should inline auth also work for users who do not yet have a Trinity account, or only for users already in the email whitelist?

Acceptance Criteria

  • Design confirmed with Eugene
  • request_login MCP tool: accepts email, calls existing POST /api/auth/email/request, returns confirmation; no auth required to call
  • verify_login MCP tool: accepts email + code, calls existing POST /api/auth/email/verify, returns a session token or minted MCP API key; no auth required to call
  • Unauthenticated MCP sessions see only request_login and verify_login (and optionally public agent info); all other tools require auth
  • After successful inline login, the session has access to a defined subset of tools (scope TBD in design)
  • The default .mcp.json snippet in docs / UI works without a pre-filled API key
  • Inline auth flow is audit-logged (same as web email auth)
  • Existing API-key auth path is unaffected

Technical Notes

  • Existing email auth endpoints: POST /api/auth/email/request and POST /api/auth/email/verify in routers/auth.py
  • Telegram's inline login state machine in adapters/telegram_adapter.py is the reference implementation (Redis-backed pending login with TTL)
  • FastMCP supports unauthenticated tool calls when authenticate callback returns undefined — gate the tool list on session presence
  • Minted MCP key (if that's the chosen credential model) follows the existing trinity_mcp_* format in routers/mcp_keys.py
  • Related: feat: per-agent MCP exposure flag — dynamic dedicated tool per exposed agent #846 (per-agent MCP exposure flag) — the tool-visibility subset after inline login likely ties directly to mcp_exposed agents

Activity

  1. added
    priority-p2
    type-feature
    on May 15, 2026
  2. added
    complexity-medium
    status-incubating
    on Jun 12, 2026
  3. vybe commented on Jun 28, 2026

    @vybe
    ContributorAuthor

    Design decision (Eugene, 2026-06-28) — gate resolved, promoting to status-ready.

    Inline MCP login reuses the existing public-channel auth contract rather than a bespoke flow:

    Net: MCP becomes a client-sharing channel that authenticates exactly like the existing public channels. Tool visibility after login = the mcp_exposed agents the email is authorized for.

  4. added
    status-ready
    and removed
    status-incubating
    on Jun 28, 2026
  5. vybe commented on Jul 9, 2026

    @vybe
    ContributorAuthor

    Scope note: the per-agent MCP connector (playbook tools for shared consumers) is now the primary consumer of this inline login flow — tracked in trinity-enterprise#118, which also moves the connector to OSS core. When resolving the design questions above (session credential lifecycle, post-login tool visibility, whitelist-only), answer them connector-first: an email-authenticated session should see only the exposed playbooks of agents shared with that email.

  6. removed
    status-ready
    on Jul 20, 2026
  7. obasilakis commented on Jul 20, 2026

    @obasilakis
    Contributor

    /claim

  8. 26 remaining items

  9. removed
    status-in-dev
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-highpriority-p2theme-devextype-feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions