When a new AI agent connects to a company’s tool, someone must decide whether to allow it.
With standard MCP authorization, employees must access the consent screen separately for every connection, which is cumbersome: if your project has a dozen or more MCPs, you’ll end up having to click multiple times for each of them. Additionally, organizations have little visibility into this process.
The aim of EMA and XAA is to solve this issue at an organization level using a couple of OAuth extensions:
- ID-JAG to grant access to federated, or cross-domain, scenarios.
- Token exchange to obtain ID-JAG tokens.
- JWT bearer grant to exchange that ID-JAG token for access tokens.
This enables EMA and XAA implementations to enforce policy-based access and provide visibility into who is accessing what.
In this article, we will:
- Review the differences between ID-JAG, XAA, and EMA.
- Build an example of token exchange in EMA.
- Understand the limitations of EMA and cross-app access.
Differences Between XAA, ID-JAG, and EMA
When talking about cross-app access, ID-JAG and EMA, it’s easy to get these terms confused. They all relate to granting access to an application or agent through an Identity Provider (IdP), but they differ in specific ways.
Identity Assertion JWT Authorization Grant (ID-JAG) is an OAuth 2.0 extension proposal that allows you to reuse the SSO trust from your IdP to broker access to resources.
ID-JAG relies primarily on two OAuth extensions: Token exchange (RFC 8693) to obtain the ID-JAG token and the JWT bearer grant (RFC 7523) to exchange it for an access token.
Cross-App Access (XAA) is Okta’s implementation of the ID-JAG protocol. In this flow, Okta acts as the IdP and applies the organization’s access policies.
If you want to understand XAA in depth, the official website offers a sandbox exercise.
Enterprise-managed authorization (EMA) extends ID-JAG with some quality-of-life changes for MCPs. i.e., it specifies how MCP servers and clients should declare that they support ID-JAG. It’s being positioned as the standard mechanism to access MCP Servers through an IdP.
In summary, both XAA and EMA implement ID-JAG and are compatible with each other. They allow a company’s IdP (Okta, EntraID, …) to control which MCP servers an AI client can connect to. XAA is a general protocol, while EMA is meant for MCP.
The Cross-App EMA Access Flow
Enterprise-Managed Authorization (EMA) is designed to grant an MCP client access to multiple MCP servers, with one IdP as the authorization broker.
In this flow, we have four entities:
- The client, which represents the employee or an agent on the employee’s behalf.
- The IdP (like Okta or EntraID), which will act as a broker for access.
- The MCP authorization server, which grants access tokens as in OAuth 2.1 + PKCE.
- The MCP resource server, which is the element that the client wants to access.
These are the steps followed in an EMA access flow:
Step 1: Login request: The client sends the user to the IdP login page. The user signs in with their corporate credentials.
Step 2: If the sign-in was successful, the IdP returns a short-lived, single-use Auth Code.
Step 3: ID token request: the client sends the authorization code to the IdP’s token endpoint. It includes the PKCE code verifier sent as the challenge in step 1 to prove it’s the same client that started the login.
Step 4: If the code, verifier, and credentials are valid, the IdP returns an ID Token (a JWT signed by the IdP)
Step 5: ID-JAG token exchange: The client asks the IdP for an ID-JAG token, using the token exchange (RFC 8693). It sends the ID Token as proof of who signed in, and includes the audience and the scope it wants.
Step 6: If the policy allows it, the IdP returns an ID-JAG JWT token.
Step 7: Access token request: The client presents the ID-JAG to the MCP Authorization Server, using the JWT bearer grant (RFC 7523), and authenticates with the credentials at that server. No browser or consent screen is required.
Step 8: The MCP Authorization Server checks if the ID-JAG is correct and that the client_id matches the client_id presenting it. It issues an access token for the MCP server, normally short-lived and without a refresh token.
Step 9 – Accessing the resource: The client calls the MCP resource, presenting the access token as a bearer token.
Building our XAA/EMA Example
To understand XAA and EMA, we’ll create a small notepad service and MCP client that will connect to it using access via XAA/EMA granted by Okta.
In our example, you’ll first need to configure several entities in Okta, the IdP:
- A notes-requesting-app, which acts as the client’s registration in Okta.
- A notes-resource-app, as the notes authorization server registration in Okta.
- An AI Agent defining the approved connections.
Then, the code is split into three files, one for each actor:
- An MCP Client that will run locally (
client/run.py). A Python program that plays the role of an AI assistant. Signs the user in and asks Okta for an ID-JAG token. Then it exchanges it for an access token and calls the tools on the MCP server. - An MCP Authorization Server (
resource_as/server.py) for the notepad service. It validates ID-JAG and issues access tokens to the resource. - An MCP Resource Server (
mcp_server/server.py) with the notes tools. Validates the access tokens and scopes for each call.
You’ll need to edit the .env config file that contains shared configuration.
Requirements:
- You will need an Okta account for the exercise. You can try their seven-day trial.
- Python 3.10 or later (3.12 recommended).
- These Python libraries: mcp, uvicorn, fastapi, httpx, pyjwt, and python-dotenv.
0. Making the Authentication Server Public
Okta requires that authentication servers are publicly accessible via HTTPS. Our example runs the authentication server in localhost:9000, so you’ll need a way to expose this port to the internet. If you are doing this on a local computer, you can use options like:
- localtunnel, used as:
lt --port 9000 - cloudflared, used as:
cloudflared tunnel --url http://localhost:9000
1. Register the Client App in Okta
Let’s start by registering our client app in Okta. In XAA nomenclature, client apps are called “requesting apps”, as they are the ones requesting ID-JAGs.
In Okta, create a new application called notes-requesting-app:
- Go to Applications and Resources → Applications → Create App Integration
- Select OIDC – OpenID Connect → Web Application.
- Name it
notes-requesting-appand select “Use Okta-generated client ID”. - Check the fields “Authorization code” and “Refresh token”.
- In the field called “Sign-in redirect URI”, enter http://localhost:8080/callback.
- In Assignments, choose “Skip group assignment for now” and save.
- Once created, copy the “Client ID” and “Client secret” from the “General” tab.
- In the “Assignments” tab, assign the application to your user:
- In Sign-on → User Authentication, select “Okta browser plugin”.
2A. Register the Resource app
Let’s register the resource app, which will hold the records for the authentication server.
In Okta, create a second app integration called notes-resource-app:
- Go to Applications and Resources → Applications → Create App Integration.
- Select OIDC – OpenID Connect → Web Application.
- Name it
notes-resource-appand select “Use Okta-generated client ID”. - In “Sign-in redirect URI”, enter any placeholder, as users won’t need to sign in for this example.
- In Assignments, choose “Skip group assignment for now” and save.
- Then, on the app’s “Assignment” tab, assign the application to your user, as in the previous application.
2B. Enable Cross-App Access for the Resource app
Next, tell Okta what information to include in the ID-JAG tokens so the resource authorization server accepts them. This includes:
- The authorization server’s URL as the audience.
- The access token scopes.
To enable “Cross-App Access’ for this application:
- Open the “Machine Assignments” tab, select the Callers tile, and click “Edit” next to Cross-App Access (XAA)
- Enable it.
- In the “issuer URL field”, write the public URL for the authorization server, the one we discussed in step 0.
- Audience/tenant ID: leave empty.
- Scopes: add two values:
notes.readandnotes.write. - Save.
3. Creating an AI Agent as the approved connection
Finally, we need to register our client as an AI Agent, which is Okta’s abstraction to link the client (notes-requesting-app) with the resource’s authorization server (notes-resource-app).
In Okta, create a new AI Agent called notes-app:
- Go to
Directory → AI Agents → Register AI Agent → Register manually - In User access and Authentication, select an existing app:
notes-requesting-app. - In “Profile and Owners”: fill in with your test user as owner.
The resource connection is what enables Cross-App Access: It records that this client may obtain ID-JAGs for the notes resource on behalf of its users, with those scopes.
In the list of agents, click on the one you just created. Then, in the section called Resource Connections, click on Add Resource Connection. There:
- Choose Application -> App configured for AI Agent access.
- On Application instance, select
notes-resource-app. - On “client ID registered in notes-resource-app”: write demo-agent.
- Allow specific scopes: you can select which scopes this application is allowed to use. Select only
notes.read.
4. Write the .env file:
We go back to our code.
Our example uses an .env file with all the environment variables needed by the different programs to run the exercise. You have an environment file placeholder available at .env.example that you can copy:
cp .env.example .env
Then, fill in the appropriate fields directly.
# ── Okta (the enterprise IdP) ───
# Your Integrator Free org,(org authorization server)
OKTA_ISSUER=https://integrator-1234567.okta.com
# The "Requesting App" OIDC integration (Authorization Code + Refresh Token)
# OKTA_CLIENT_ID and OKTA_CLIENT_SECRET are the ones defined in Step 1.7
OKTA_CLIENT_ID='0oa195ndjdv7sdFEM698'
OKTA_CLIENT_SECRET='KR3a5rFdNLAWmD3DtDnHqMaJaYaUTGu3snInKsRjRw3OBYLgdcrU--a5u3RvMIjq'
CLIENT_REDIRECT_URI=http://localhost:8080/callback
# ── Resource authorization server (this repo) ───
# Must match EXACTLY the Issuer URL on the resource app's "Resource Server" tab in Okta.
# Okta won't accept an http, so run a tunnel (localtunnel, cloudflared) to port 9000
# and put the https tunnel URL here and in Okta.
# RESOURCE_AS_ISSUER is created in Step 0
RESOURCE_AS_ISSUER=https://great-hammer.loca.lt
# The client the agent uses at THIS AS. Put the same client ID in Okta's resource connection
# ("AI agent's client ID registered in this app") so Okta writes it into the ID-JAG.
# RESOURCE_AS_CLIENT_ID was added in step 3.3
RESOURCE_AS_CLIENT_ID=demo-agent
RESOURCE_AS_CLIENT_SECRET=change-me-to-a-long-random-string
ACCESS_TOKEN_TTL=300
AUTO_PROVISION_USERS=true
# Set to false only if your IdP's ID-JAG header doesn't carry typ=oauth-id-jag+jwt
STRICT_ID_JAG_TYP=true
# ── MCP server (this repo) ────
MCP_RESOURCE=http://localhost:8001/mcp
RESOURCE_SCOPES=notes.read
WRITES_PER_MINUTE=5
Running the Example
In our example, the client will request an ID-JAG from the IdP and use it to get an access token for a notepad application MCP. The demo flow will demonstrate both the use of ID-JAGs and how the authorization server enforces permissions with tokens’ scopes:
- The client will try to list notes, add a note, and delete all notes.
- It will be able to list notes, but will lack write permissions to add or delete.
- We’ll change the permissions in Okta and in the
.envfile. - We’ll run the client again, and we’ll see how it’s able to perform all actions.
Create a Python virtual environment with the required libraries:
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
In a first terminal run the Authorization Server:
source .venv/bin/activate
python -m uvicorn resource_as.server:app --port 9000
In a second terminal run the MCP Server:
source .venv/bin/activate
python -m mcp_server.server
And in a third one run the client:
source .venv/bin/activate
python -m client.run
Obtaining an ID Token
First, you will notice a browser tab opens for Okta sign-in. This represents steps 1-4 from the EMA flow:
Step 1: Login request
The client builds the authorization URL and opens a new browser tab with it, displaying the Okta login page. It generates a random PKCE and sends its SHA-256 as a challenge. The state field protects against forged callbacks.
def sign_in(okta: dict) -> dict:
verifier = secrets.token_urlsafe(48)
challenge = base64.urlsafe_b64encode(hashlib.sha256(verifier.encode()).digest()).rstrip(b"=").decode()
state = secrets.token_urlsafe(16)
params = {
"client_id": OKTA_CLIENT_ID,
"response_type": "code",
"scope": "openid profile email offline_access",
"redirect_uri": REDIRECT_URI,
"state": state,
"code_challenge": challenge,
"code_challenge_method": "S256",
}
...
Step 2: Receiving the auth code on the callback
After the user signs in, Okta redirects the browser to CLIENT_REDIRECT_URI (http://localhost:8080/callback), sending a one-time authorization code. The client receives it and checks that the state matches the one sent in the previous step.
server = http.server.HTTPServer((redirect.hostname, redirect.port or 80), Handler)
...
if result.get("state") != expected_state:
raise SystemExit("state mismatch")
return result["code"]
Step 3-4: Requesting and receiving the ID Token
The client sends the authorization code to Okta’s endpoint, with no browser involved. It includes the PKCE verifier, which Okta validates and compares with the one sent in Step 1.
Okta responds with an ID Token, which says who signed in.
r = httpx.post(
okta["token_endpoint"],
data={
"grant_type": "authorization_code",
"code": code,
"redirect_uri": REDIRECT_URI,
"code_verifier": verifier,
"client_id": OKTA_CLIENT_ID,
"client_secret": OKTA_CLIENT_SECRET,
},
)
tokens = r.json() # id_token, access_token, refresh_token
In the console, you will see the format of the ID token received:
header: {
"kid": "Emsi_vfXs68ACT31HOwmTRMlmZvr8ceChwg63K9V4Go",
"alg": "RS256"
}
payload: {
"sub": "00u18d927x2LLfOvk498",
"name": "John Doe",
"email": "johndoe@company.com",
"ver": 1,
"iss": "https://integrator-6705972.okta.com",
"aud": "0oa195ncjsv7sdFEM698",
"iat": 1793743085,
"exp": 1793746685,
"jti": "ID.VpVX47kL_BhamOSzKIVxoGja-oWg3549iMkl0a8eVFM",
"amr": [
"mfa",
"otp",
"pwd",
"okta_verify"
],
"idp": "00o18d927sv0esXtE698",
"preferred_username": "johndoe@company.com",
"auth_time": 1793743084,
"at_hash": "W8cjrdmOKcfr3whiO01v6Q"
}
Where its fields indicate:
iss:the issuer, who vouched for this token.sub:your user ID in Okta.aud:The ID fornotes-requesting-app. This prevents this token from being used in other places.iatandexp: the time the token was issued and the expiration date. These values indicate it’s valid for 1 hour.amr: the methods you used to authenticate (multi-factor, password, etc.).name, email, andpreferred_username: profile data that identify you.
Obtaining and Exchanging an ID-JAG
Once the client has the ID Token, it will request an ID-JAG from Okta, in order to exchange it for an access token for the MCP Server.
Steps 5–6: Exchanging the token for an ID-JAG
The client asks Okta for an ID-JAG token using OAuth Token Exchange. Okta will check the authorization server that will redeem the grant, the resource (MCP server), and the scope it wants. It will query the notes-app AI agent to validate if the client + scope + resource + user is allowed to access this resource.
If so, it will return an ID-JAG signed by Okta, addressed to the resource authorization server.
r = httpx.post(
okta["token_endpoint"],
data={
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
"requested_token_type": "urn:ietf:params:oauth:token-type:id-jag",
"subject_token": tokens["refresh_token"],
"subject_token_type": "urn:ietf:params:oauth:token-type:refresh_token",
"audience": RESOURCE_AS_ISSUER, # who will redeem it
"resource": MCP_RESOURCE, # what it is for
"scope": SCOPES,
"client_id": OKTA_CLIENT_ID,
"client_secret": OKTA_CLIENT_SECRET,
},
)
id_jag = r.json()["access_token"] # the ID-JAG is returned in this field
In the console, you will see the format of the ID-JAG token:
header: {
"kid": "Emsi_vfXs68ACT31HOwmTRMlmZvr8ceChwg63K9V4Go",
"typ": "oauth-id-jag+jwt",
"alg": "RS256"
}
payload: {
"jti": "IDAAG.Dlgpch6MgDjrMNganSsVPs2jGNz2Nh6laQOKX2laGl8",
"iss": "https://integrator-6705972.okta.com",
"aud": "https://fresh-flowers-dress.loca.lt",
"iat": 1793743387,
"exp": 1793743687,
"sub": "00u18d927x2LLfOvk698",
"email": "johndoe@company.com",
"client_id": "demo-agent",
"sub_profile": "user",
"scope": "notes.read",
"act": {
"sub": "0oa195ncjsv7sdFEM698",
"sub_profile": "ai_agent web_app"
}
}
These are the most important fields:
aud: your resource authorization server.iatandexp: the time the token was issued and the expiration date. These values indicate it’s valid for 5 minutes.sub: same user as the ID Token.scope: what the IdP approved this token for (notes.read).client_id: same as the IA agent’s resource connection.
Steps 7-8: Getting the access token
The client presents the ID-JAG token to the authorization server, using the JWT bearer grant. The authorization server checks that the ID-JAG was signed by Okta and addressed to itself. If all is correct, it will issue a short-lived access token.
r = httpx.post(
resource_as["token_endpoint"],
auth=(RESOURCE_AS_CLIENT_ID, RESOURCE_AS_CLIENT_SECRET),
data={
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
"assertion": id_jag,
"scope": SCOPES,
},
)
access_token = r.json()["access_token"]
Adjusting Scopes on the Authorization Server
Step 9: Accessing the MCP server with an access token.
The client will try to:
- Read all the notes.
- Add a note.
- Read all the notes again.
- Delete the created note.
The client successfully read the notes in our notepad. But adding and deleting failed because we lacked the notes.write scope.
list_notes({}) ->
add_note({"text": "XAA flow worked"}) -> DENIED: missing scope notes.write
list_notes({}) ->
delete_all_notes({"confirm": true}) -> DENIED: missing scope notes.write
Go to the Okta Agent configured in Step 3 at Directory → AI Agents, and include the notes.write scope in the permissions allowed to notes-requesting-app:
In the .env file, modify RESOURCE_SCOPES to include notes.write:
RESOURCE_SCOPES=notes.read notes.write
Try running the client again:
list_notes({}) ->
add_note({"text": "XAA flow worked"}) -> added (1 notes)
list_notes({}) -> XAA flow worked
delete_all_notes({"confirm": true}) -> deleted 1 notes
This confirms that the scope change allowed these operations.
What is Outside of EMA and Cross-App Access
While EMA has an important mission in enterprise authorization for MCPs, it does not cover certain aspects.
Limited Policies
You are limited to the IDP’s policies. The standard does not specify which policies to use. When the IdP issues the ID-JAG token, it can be exchanged for an access token, which allows any call within its scopes, and nothing in EMA checks whether a specific tool call should be allowed.
No Required Agentic Identity
ID-JAG includes the user (sub) and the client registration (client_id). Nothing in that protocol verifies which agent inside that client is making the request. If one application runs several agents under one client ID, they all get identical tokens, and the resource can’t tell them apart.
In our notepad application example, imagine that we have a desktop agent running two agents that connect to our notepad: a summarizer that only reads notes and an organizer that also adds them. Since they are bound to the same application, they share the same permissions and client ID. Companies that require accountability will need to know explicitly which agent was acting here.
Can’t Revoke Tokens Already Issued
IDP revocation doesn’t reach tokens already issued. If the user already claimed the access token, there’s nothing we can do from the IdP side to cancel its validity. Imagine in our notepad application, at 9:58 the client redeems an ID-JAG and gets an access token for five minutes. At 10:00, an admin deactivates that user in the IdP. Until 10:03, the agent can still call the add_note and delete_all_notes tools.
Conclusion
Enterprise-managed authorization serves a real purpose: it moves the decision about which AI clients may connect to which MCP servers into the Identity Provider, which already governs your company’s access.
But EMA makes that decision once, when it issues the ID-JAG. It doesn’t say which agent is acting; it doesn’t tie an action to what the user actually asked. And it can’t revoke tokens already issued.
Approving a connection is not the same as authorizing an action, and agents need both.
XAA, ID-JAG and EMA FAQ
What is XAA?
What is ID-JAG?
What is EMA in MCP?
Does EMA control which MCP tools an agent can call?
list_notes with notes.read and requires notes.write for adding or deleting notes.