Authentication Architecture Overview
The Gateway provides a three-part authentication and authorization system:| Component | Description |
|---|---|
| Inbound Authentication | How clients (AI agents, developers, end users) authenticate to the Gateway |
| Access Control | Role-based policies determine which users can access which MCP servers and tools |
| Outbound Authentication | How the Gateway authenticates to downstream MCP servers |

Inbound Authentication
Inbound authentication controls how clients authenticate to the Gateway. Any user or application requires valid credentials to talk to the Gateway, which allows the Gateway to identify the caller and apply authorization rules. TrueFoundry supports the following inbound authentication methods:TrueFoundry API Key (Personal Access Token)
TrueFoundry API Key (Personal Access Token)
Virtual Account Token
Virtual Account Token
External IdP Token
External IdP Token
- B2B SaaS applications where your customers don’t have TrueFoundry accounts
- Applications that want to use their existing identity infrastructure
- Customer Identity and Access Management (CIAM) scenarios
Configure SSO Integration
- Navigate to Settings > SSO
- Create a new SSO configuration pointing to your IdP
- Important: Set login enabled to
false(this SSO is only for external identity, not platform login) - Note the SSO FQN for the next step
Create External Identity
- Navigate to Access > External Identities
- Click Add External Identity
- Select the SSO FQN from step 1
- Optionally add claims to match specific users/tenants
Grant MCP server access
- Navigate to the MCP server’s settings
- Go to Collaborators
- Add the External Identity with appropriate permissions
TrueFoundry OAuth
TrueFoundry OAuth
- Connecting to MCP servers from Cursor, VS Code, or other MCP-compatible IDEs
- Enabling team members to access MCP tools without sharing or managing API keys
- Leveraging existing TrueFoundry user authentication for MCP access
- The IDE prompts you to authenticate with TrueFoundry
- You sign in using your TrueFoundry credentials (or SSO if configured)
- TrueFoundry issues an OAuth token that the IDE uses for subsequent requests
- No manual token configuration is required
Access Control
Once authenticated, the Gateway verifies whether the user has permission to access the requested MCP server and tools.
- Which MCP servers a user can access
- Which tools within an MCP server a user can invoke
Outbound Authentication
Outbound authentication controls how the Gateway authenticates to downstream MCP servers. TrueFoundry supports multiple authentication models to handle different MCP server requirements.No Auth / API Key (Static Headers)
No Auth / API Key (Static Headers)
- Demo or sandbox APIs
- Public tools like a Calculator MCP Server or DeepWiki MCP server
- Datasets meant for broad team or department access
- Read-only access to shared resources (knowledge bases, analytics)
- Legacy systems without per-user OAuth support
- Internal tools where a service account is easier to audit
OAuth 2.1 (Per-User Credentials)
OAuth 2.1 (Per-User Credentials)
- Personal productivity tools (email, calendar, documents)
- Systems where permissions differ per user
- Actions that must be attributed to an individual
- End user authenticates with the Gateway (using TrueFoundry token or External Identity)
- End user attempts to call an MCP tool → Gateway returns auth error with authorization URL
- End user visits URL and completes OAuth consent on the third-party service (e.g., GitHub)
- TrueFoundry stores the OAuth token for that end user
- Future requests automatically include the end user’s OAuth token
Token Passthrough
Token Passthrough
- Your MCP server trusts the same IdP that authenticated the user to the Gateway
- The MCP server is configured to validate TrueFoundry tokens or your IdP’s JWTs
- You want the MCP server to make authorization decisions based on the user’s identity
- User authenticates to the Gateway with their token (TrueFoundry or IdP)
- Gateway validates the token and checks access control
- Gateway forwards the same token to the MCP server
- MCP server validates the token and processes the request
Token Forwarding (Custom Headers)
Token Forwarding (Custom Headers)
x-tfy-mcp-headers header. This is useful when the MCP server requires specific authentication tokens or metadata that are different from the Gateway authentication.When to use Token Forwarding:- The MCP server requires a specific token format that differs from Gateway authentication
- You need to pass additional metadata or authentication headers
- The client has direct credentials for the MCP server
- Client authenticates to the Gateway with TrueFoundry token or IdP token (inbound auth)
- Client includes
x-tfy-mcp-headerswith additional headers for the MCP server - Gateway validates the inbound token and checks access control
- Gateway forwards the custom headers to the MCP server
server-1). Copy the identifier from the UI since virtual MCP servers contain multiple remote MCP servers.Outbound Authentication Summary
TrueFoundry MCP Gateway supports registering MCP servers with different outbound authentication models. The Gateway keeps the user-facing experience consistent even when different MCP servers use different authentication models.| MCP Server | Outbound Auth | Reason |
|---|---|---|
| Gmail, Slack, GitHub | OAuth 2.1 | Personal data, user-specific permissions |
| Hugging Face, DeepWiki | No Auth / API Key | Public or shared access |
| Internal MCP Server with IdP auth | Token Passthrough | MCP server validates user’s IdP token |
| Internal MCP Server from OpenAPI | Token Forwarding | Client provides MCP server credentials |
Authentication Scenarios
The following scenarios show how different combinations of inbound and outbound authentication work in practice. Each scenario includes a sequence diagram and a detailed step-by-step breakdown.Scenario 1: TrueFoundry API Key + OAuth 2.1 Outbound
Inbound: TrueFoundry API Key | Outbound: OAuth 2.1 Use case: Internal developers with TrueFoundry accounts accessing OAuth-protected services like Slack, GitHub, or Atlassian. This is the most common enterprise scenario where your developers authenticate to TrueFoundry and the Gateway handles OAuth token management for downstream MCP servers.
One-Time Setup (Steps 1-8)
One-Time Setup (Steps 1-8)
| Step | Action | Description |
|---|---|---|
| 1 | User → Control Plane | User logs into TrueFoundry |
| 2 | Control Plane → IdP | TrueFoundry redirects to your identity provider (Okta, Azure AD, etc.) |
| 3 | IdP → User | User authenticates and receives IdP access token |
| 4 | User → Control Plane | User initiates OAuth flow for the MCP server (e.g., “Connect to Atlassian”) |
| 5 | Control Plane | Verifies user has permission to access this MCP server |
| 6 | Control Plane → External Provider | User is redirected to the external service (e.g., Atlassian) to authorize access |
| 7 | External Provider → Control Plane | External service returns OAuth tokens after user approval |
| 8 | Control Plane | Securely stores access and refresh tokens, linked to the user’s identity |
Runtime Flow (Every Request)
Runtime Flow (Every Request)
| Step | Action | Description |
|---|---|---|
| 1 | Agent → Gateway | AI Agent sends request with TrueFoundry token (inbound auth) |
| 2 | Gateway | Validates the TrueFoundry token |
| 3 | Gateway | Checks if the token has access to the requested MCP server/tool |
| 4 | Gateway → Control Plane | (If not cached) Retrieves user’s OAuth token for this MCP server |
| 5 | Gateway | Caches the OAuth token for subsequent requests |
| 6 | Gateway → MCP Server | Forwards request with the user’s OAuth token (outbound auth) |
| 7 | MCP Server → External Provider | Validates token and fetches user-specific data |
| 8 | MCP Server → Agent | Returns response through the Gateway |
- Users authenticate once to TrueFoundry and access multiple OAuth-protected services
- Tokens are automatically refreshed when they expire
- Each user’s actions are attributed to their individual identity
- Users can revoke access to specific services at any time
Scenario 2: External IdP Token + OAuth 2.1 Outbound (CIAM)
Inbound: External IdP Token | Outbound: OAuth 2.1 Use case: Your end customers (who don’t have TrueFoundry accounts) accessing OAuth-protected services through your application. This scenario is common for Customer Identity and Access Management (CIAM) where you want your customers to connect their own accounts (e.g., their Gmail, Slack, or CRM) to your AI-powered application.
One-Time Setup (Steps 1-7)
One-Time Setup (Steps 1-7)
| Step | Action | Description |
|---|---|---|
| 1 | User → IdP | User logs into your identity provider directly (not TrueFoundry) |
| 2 | IdP → User | User receives IdP access token |
| 3 | User → Control Plane | User initiates OAuth flow for the MCP server |
| 4 | Control Plane | Validates the IdP token and extracts user identity (inbound auth) |
| 5 | Control Plane | Checks if the user/role has access to this MCP server |
| 6 | Control Plane → External Provider | Redirects user to authorize access (3-legged OAuth) |
| 7 | External Provider → Control Plane | Returns OAuth tokens; Control Plane stores them securely |
Runtime Flow (Every Request)
Runtime Flow (Every Request)
| Step | Action | Description |
|---|---|---|
| 1 | Agent → Gateway | AI Agent sends request with IdP token (inbound auth) |
| 2 | Gateway | Validates the IdP token using your SSO configuration |
| 3 | Gateway | Checks if the extracted user identity has access to the MCP server/tool |
| 4 | Gateway → Control Plane | (If not cached) Retrieves the user’s OAuth token using their IdP identity |
| 5 | Gateway | Caches the OAuth token for performance |
| 6 | Gateway → MCP Server | Forwards request with user’s OAuth token (outbound auth) |
| 7 | MCP Server → External Provider | Validates and processes the request |
| 8 | MCP Server → Agent | Returns response through the Gateway |
- Users authenticate with your IdP, not TrueFoundry (different inbound auth)
- The Gateway validates your IdP tokens directly
- Useful for B2B SaaS applications with end-customer integrations
Scenario 3: TrueFoundry/IdP Token + API Key Outbound
Inbound: TrueFoundry API Key or External IdP Token | Outbound: No Auth / API Key Use case: Accessing MCP servers with shared credentials where individual user identity at the downstream service is not required. This scenario is ideal for read-only access to shared resources, internal tools, or services that don’t support per-user OAuth.
Administrator Setup (One-Time)
Administrator Setup (One-Time)
| Step | Action | Description |
|---|---|---|
| 1 | Admin → Control Plane | Administrator registers the MCP server with static header authentication (outbound) |
| 2 | Admin | Configures the shared API key or bearer token in the MCP server settings |
| 3 | Admin | Defines which users/roles have access to this MCP server through RBAC policies |
Runtime Flow (Every Request)
Runtime Flow (Every Request)
| Step | Action | Description |
|---|---|---|
| 1 | Agent → Gateway | AI Agent sends request with user’s TrueFoundry or IdP token (inbound auth) |
| 2 | Gateway | Validates the user token |
| 3 | Gateway | Checks if the user has access to this MCP server (RBAC) |
| 4 | Gateway | Injects the shared credentials (static headers) into the request (outbound auth) |
| 5 | Gateway → MCP Server | Forwards request with shared service account credentials |
| 6 | MCP Server | Processes request using the shared credentials |
| 7 | MCP Server → Agent | Returns response through the Gateway |
- All users share the same level of access to the downstream service
- Actions cannot be attributed to individual users at the downstream service level
- TrueFoundry’s audit logs still track which user made each request at the Gateway level
Scenario 4: Token Passthrough (Inbound Token Forwarded to MCP Server)
Inbound: TrueFoundry API Key or External IdP Token | Outbound: Token Passthrough Use case: Accessing MCP servers that validate the same token used for Gateway authentication. This scenario is for organizations where the MCP server itself can validate the user’s TrueFoundry token or IdP JWT.Setup Requirements
Setup Requirements
| Step | Action | Description |
|---|---|---|
| 1 | Configure Inbound Auth | Set up TrueFoundry API Key or External Identity |
| 2 | Register MCP Server | Register the MCP server with Token Passthrough as outbound authentication |
| 3 | Configure MCP Server | Ensure the MCP server is configured to validate TrueFoundry tokens or your IdP’s JWTs |
Runtime Flow (Every Request)
Runtime Flow (Every Request)
| Step | Action | Description |
|---|---|---|
| 1 | User → IdP/TrueFoundry | User authenticates and receives a token |
| 2 | Agent → Gateway | AI Agent sends request with user’s token (inbound auth) |
| 3 | Gateway | Validates the token |
| 4 | Gateway | Checks if the user has access to this MCP server (RBAC) |
| 5 | Gateway → MCP Server | Forwards request with user’s token unchanged (outbound: token passthrough) |
| 6 | MCP Server | Validates the token and processes the request |
| 7 | MCP Server → Agent | Returns response through the Gateway |
- Your MCP server can validate TrueFoundry tokens or your IdP’s JWTs
- You want the MCP server to know the user’s identity
- The MCP server makes authorization decisions based on token claims
Scenario 5: Token Forwarding (Custom MCP Server Headers)
Inbound: TrueFoundry API Key or External IdP Token | Outbound: Token Forwarding Use case: The client has specific credentials for the MCP server that are different from the Gateway authentication token. This scenario is useful when the MCP server requires its own authentication that cannot be managed by the Gateway (e.g., internal APIs with their own token systems).Setup Requirements
Setup Requirements
| Step | Action | Description |
|---|---|---|
| 1 | Configure Inbound Auth | Set up TrueFoundry API Key or External Identity |
| 2 | Register MCP Server | Register the MCP server (no outbound auth configured, or Token Forwarding mode) |
| 3 | Client Configuration | Client must include x-tfy-mcp-headers with MCP server credentials |
Runtime Flow (Every Request)
Runtime Flow (Every Request)
| Step | Action | Description |
|---|---|---|
| 1 | Agent → Gateway | AI Agent sends request with TrueFoundry/IdP token + x-tfy-mcp-headers |
| 2 | Gateway | Validates the inbound token |
| 3 | Gateway | Checks if the user has access to this MCP server (RBAC) |
| 4 | Gateway | Extracts headers from x-tfy-mcp-headers |
| 5 | Gateway → MCP Server | Forwards request with extracted headers (outbound auth) |
| 6 | MCP Server | Validates the custom headers and processes the request |
| 7 | MCP Server → Agent | Returns response through the Gateway |
- The MCP server has its own authentication system separate from Gateway authentication
- You need to pass user-specific tokens that the client manages
- The MCP server requires additional metadata alongside authentication
Choosing the Right Authentication Model
Quick Reference
Inbound Authentication (client → Gateway):- TrueFoundry API Key: Internal developers with TrueFoundry accounts
- External IdP Token: End customers authenticating via your IdP (B2B SaaS, CIAM)
- TrueFoundry OAuth: Third-party apps needing delegated user access
- OAuth 2.1: Per-user access to third-party services (Gmail, Slack, GitHub)
- API Key / No Auth: Shared resources or public APIs (Hugging Face, DeepWiki)
- Token Passthrough: Internal MCP servers that validate your IdP tokens
- Token Forwarding: MCP servers with separate auth systems (client provides credentials via
x-tfy-mcp-headers)
FAQ
What's the difference between Inbound and Outbound Authentication?
What's the difference between Inbound and Outbound Authentication?
- Inbound Authentication: How clients (AI agents, developers, end users) prove their identity to the Gateway. This determines who is making the request.
- Outbound Authentication: How the Gateway authenticates to downstream MCP servers. This determines how the MCP server trusts and processes the request.
OAuth 2.1 vs Token Passthrough: Which outbound auth should I choose?
OAuth 2.1 vs Token Passthrough: Which outbound auth should I choose?
| Question | If Yes → |
|---|---|
| Does the MCP server connect to third-party services (GitHub, Slack, Google, etc.)? | OAuth 2.1 |
| Does the MCP server validate the same token used for inbound auth? | Token Passthrough |
Token Passthrough vs Token Forwarding: What's the difference?
Token Passthrough vs Token Forwarding: What's the difference?
- Token Passthrough: The Gateway forwards the same token used for inbound authentication to the MCP server. The MCP server must be able to validate TrueFoundry tokens or your IdP tokens.
-
Token Forwarding: The client provides separate credentials for the MCP server via
x-tfy-mcp-headers. These are different from the inbound auth token and are forwarded as-is to the MCP server.
Can I use multiple inbound auth methods for the same MCP server?
Can I use multiple inbound auth methods for the same MCP server?