TL;DR
To secure Microsoft Copilot Studio agents using MCP tools, route all tool calls through Okta Agent Gateway rather than connecting directly to Microsoft MCP servers. This architecture isolates backend OAuth tokens from the agent runtime, enforces granular tool-level least privilege, centralizes audit logging, and enables automated kill switches through Okta Workflows.
Executive summary
Building a Microsoft Copilot Studio agent that reads mail, checks calendars, and searches your directory using Model Context Protocol (MCP) tools takes an afternoon. The hard part starts once you put it into operation. The moment an agent can call tools, it begins acting outside traditional access controls. Nobody signs in to approve each action, nobody reviews its access next quarter, and if it misbehaves, there may be no clear way to stop it.
For security and identity teams, this comes down to one question: When an agent reads a mailbox, whose authority is it using, and who would notice if it shouldn't?
Okta for AI Agents solves this by placing identity governance directly into the MCP execution path:
- Token isolation and policy enforcement: Okta Agent Gateway sits between the agent and its tools to broker user consent, hold backend tokens so the agent never sees them, and log every call.
- Continuous lifecycle governance: Okta Identity Governance (OIG) conducts periodic reviews of agent access.
- Real-time threat response: An automated kill switch built on Okta Workflows can shut down a risky agent in seconds.
In this post, we answer that question for Copilot Studio agents that use Microsoft MCP tools. We’ll start with the architecture, move on to the setup, and finish by showing how a second client, Claude Code, can use the same gateway.
The governance gap: Why direct MCP connections are a security risk for Copilot Studio agents
When a Copilot Studio agent connects directly to Microsoft's MCP servers, it becomes the single place where credentials, permissions, and decisions all reside. That works in a prototype, but it rarely survives a security review.
Why direct connections fall short
- Credential exposure: If the agent holds the backend token, anything that compromises the agent, including a well-crafted prompt injection, can reach that token.
- Broad, standing access: Direct connections typically expose every tool a server offers, not just the handful an agent actually needs.
- Orphaned permissions (no owner, no review): Agents don't change roles or leave the company, so their access quietly outlives its purpose unless someone is accountable for it.
- No emergency brake: Without a central control point, there is no fast, reliable way to cut off a misbehaving agent.
Each one of these is an identity problem, which is why the fix belongs in the identity layer.
How Okta Agent Gateway secures Microsoft MCP tool calls
The core idea is simple: Never let the agent talk to tools directly. Instead, route every tool call through Okta Agent Gateway, which acts as an identity and policy proxy.
How Okta Agent Gateway brokers Copilot Studio tool calls to Microsoft MCP servers
When a user sends a prompt that triggers an MCP tool call, the gateway executes a three-step Zero Trust sequence:
- Interception: The Copilot Studio agent routes its tool call to Okta Agent Gateway, never directly to the MCP server.
- Brokered consent: The gateway initiates an OAuth flow with Microsoft Entra ID, prompting the user to grant consent if they haven't already done so.
- Token isolation: The gateway attaches the backend resource token to the request and forwards it to the target MCP server (such as Mail or Calendar). The agent never touches the raw credential.
Meanwhile, Okta Identity Governance (OIG) keeps that access under periodic review, and automated kill switch policies stand ready to revoke tokens or deactivate the agent if risk spikes.
The architectural difference matters. An agent holding its own tokens is a single point of failure. A brokered agent can only request a tool call, and the gateway decides whether to allow it. And because every call passes through a single control point, the layer that enforces policy also produces your audit trail.
Direct MCP connection vs. Okta Agent Gateway
| Governance dimension | Direct MCP connection | Okta Agent Gateway |
|---|---|---|
| Backend token storage | Stored inside the agent runtime | Isolated inside Okta Agent Gateway |
| User consent | Handled ad hoc per tool | Brokered centrally |
| Tool access scope | All tools exposed by the MCP server | Only the tools you select |
| Audit trail | Scattered across multiple service logs | Unified in the Agent Gateway Activity Log |
| Access reviews | None by default | Automated OIG certification campaigns |
| Incident response and emergency shutoff | Manual, if possible at all | Automated kill switch |
How Okta manages AI agents as first-class identities
Before you can govern an agent, it has to exist in Okta as a managed identity. Okta imports Copilot Studio agents through the Microsoft Office 365 integration in the Okta Integration Network. Once registered, each agent gets:
- An owner: A named human accountable for what the agent does.
- Dedicated authentication credentials: A client secret that Copilot Studio uses to authenticate the agent.
- Custom risk attributes: Profile fields such as
RiskScoreorBusinessUnitthat you can reference in policy, including theRiskScoreattribute that drives the kill switch described later in this post. - A full lifecycle: The ability to activate, review, and deactivate the agent just like a human user.
Step-by-step implementation: Connecting Copilot Studio to Okta Agent Gateway
You'll need Super Admin access to your Okta tenant and Global Admin access to your Microsoft tenant. This post focuses on the integration process, so refer to the product documentation for building agents or MCP servers from scratch.
Step 1: Create the agent in Copilot Studio
In Copilot Studio, go to Agents, select New agent, give it a name, and publish it. This example uses an agent named MSFTDemoAgentusingOktaGateway.
The published agent in Copilot Studio
Step 2: Create a service app in Azure
Okta discovers Copilot Studio agents through a Microsoft Entra app registration. The same app later supplies the credentials that Okta uses to authenticate against the Microsoft MCP servers.
- Register the app: In the Azure portal, open App registrations, select New registration, choose Web as the application type, and register it.
- Create a client secret: Under Certificates & secrets, generate a secret and save the value for configuration in Okta.
Certificates and secrets in the Azure portal
- Grant the import permission: Under API permissions, add the Microsoft Graph application permission
CopilotPackages.Read.All, then grant admin consent for the tenant.
Adding the CopilotPackages.Read.All permission
- Add the Okta redirect URI: Under Authentication, add
https://.okta.com/oauth2/v1/sts/callbackand enable ID tokens and access tokens. - Enable the MCP permissions: Back under API permissions, search for Agent Tools, select the MCP permissions you need (for example, Calendar, Mail, and Teams), and grant admin consent again.
Requesting Agent Tools MCP permissions
Admin consent granted for the MCP permissions
Step 3: Import and register the agent in Okta
Add the integration: In the Okta Admin Console, go to Applications and Resources, search the catalog, and select Microsoft Office 365.
Searching the Okta app catalog for Microsoft Office 365
- Enable agent import: Enter a label and your tenant name. On the Agent import tab, enable AI agent import and enter the client ID and secret from the Azure app.
Enabling AI agent import and entering the Azure client credentials
- Register the agent: Start the import to pull in all discovered Copilot agents. Select the target agent, choose Action > Register AI agent, and click View Agent.
Imported Copilot Studio agents, with the Register AI agent action
- Generate credentials and activate: Under Client registration > Client secret, generate a secret for Copilot Studio to use, then activate the agent.
- Allow user access: Under User access, click Allow user access and choose Create a new OIDC app.
The User access tab for a registered AI agent
- Assign users: Activate the new OpenID Connect (OIDC) app and assign the users or groups who can access the agent.
Assigning users to the agent's OIDC app
Step 4: Extend agent profile to add custom profile attributes
Extend the agent profile to create a custom attribute that tracks the risk score. A Copilot workflow action can then update the attribute in Okta, triggering automated agent deactivation.
Extended agent profile with custom attributes
Step 5: Add the Microsoft MCP servers in Okta
Each Microsoft MCP server is registered in Okta as a custom MCP server that uses Microsoft Entra ID as its external authorization server.
- Add the server: Go to Applications and Resources > MCP Servers, select Add custom MCP, and enter a name and the resource identifier URL from the table below.
- Point to Entra ID: For the authorization server, select External authorization server and copy the details from the Azure app's Endpoints page.
| MCP server | Resource identifier URL |
|---|---|
| Calendar | https://agent365.svc.cloud.microsoft/agents/tenants//servers/mcp_CalendarTools |
| https://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_MailTools | |
| Teams | https://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_TeamsTools |
| OneDrive | https://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_OneDriveTools |
| SharePoint | https://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_SharePointTools |
| User directory | https://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_UserDirectoryTools |
| Tasks | https://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_TasksTools |
| Enterprise | https://mcp.svc.cloud.microsoft/enterprise |
Adding an external authorization server to a Microsoft MCP server in Okta
- Add credentials: Enter the client ID and client secret from the Azure app, then select All available scopes. Don't customize the scopes.
- Discover tools: Choose Test credentials and discover tools. Okta lists all the tools the server exposes.
Okta discovers 22 tools on the Mail MCP server
Repeat for each server you want to expose.
MCP servers list in Okta showing Microsoft Calendar and Mail
Step 6: Create the Okta Agent Gateway
This is where least privilege stops being a principle and becomes a configuration.
Create the gateway: Go to Security > Agent Gateway, select Create Agent Gateway, and give it a name and description.
Agent Gateway page in the Okta Admin Console
- Assign agents: Select the agent you imported from Copilot Studio.
Assigning an AI agent to the gateway
- Add resource connections: Add the Microsoft MCP servers you created.
Adding Mail and Calendar MCP servers to the Agent Gateway
- Choose the tools: Select Manage tools for each server, then specify exactly which tools the agent may call.
Selecting the tools available through the gateway
Activate: Turn the gateway on.
An email-triage agent might get read access to Mail and Calendar and nothing else. Anything you don't select simply isn't reachable.
Step 7: Connect Copilot Studio to the gateway
Add an MCP tool: In Copilot Studio, open your agent, select Add tool, and choose Model Context Protocol.
Adding a Model Context Protocol tool in Copilot Studio
- Point to the gateway: Use your Okta Agent Gateway URL as the server URL.
- Configure OAuth: Choose OAuth 2.0 with manual configuration. Enter the agent's client ID and secret from Okta, and copy the authorization URL and token URL from the gateway's authorization server.
- Allowlist the redirect: Add the redirect URL generated by Copilot Studio as a sign-in redirect URI in the agent's Okta app.
- Connect: Create the connection, authorize the Okta sign-in, and save.
Seeing it work: Consent, tool calls, and the audit trail
In Copilot chat, ask the agent to list its tools to verify your configuration. If everything is set up correctly, it will only see the tools you allowed in the gateway.
Copilot chat with the prompt "list tools"
The agent describing the tools it can use
Next, test a prompt that triggers a tool call, like asking for your last two emails. The first time you run it, the gateway prompts the user to consent in Microsoft. After the user provides consent, the gateway forwards the tool call and returns the results.
Behind the scenes, the gateway does the real work. It confirms whether this agent is authorized for this tool, attaches the appropriate token that the agent has never seen, and forwards the call.
Ask the agent to "list all enterprise users," and the gateway checks that the agent holds authorization for the list_users tool before anything runs. Every transaction lands in the Agent Gateway activity log, ready for auditing and threat detection.
How to govern multiple MCP clients with one gateway: Adding Claude Code
The gateway isn't tied to Copilot Studio. Any MCP client you register receives the same policy and audit trail. Here's how to add Claude Code:
Register the agent: In your Okta Admin Console, go to AI Agents and register a new agent for Claude Code with a name and description.
Registering a new AI agent in Okta
Naming the Claude Code agent
Link an OIDC app: Create a new OIDC app linked to the agent and assign owners.
Enable client ID metadata: Under Client registration, enable the client ID metadata document using
https://claude.ai/oauth/claude-code-client-metadata, then activate it.
Enabling the client ID metadata document for Claude Code
- Assign users: Activate the OIDC app and assign users.
- Add it to the gateway: Open your Microsoft MCP gateway under Security > Agent Gateway, and add the Claude Code agent alongside the Copilot agent.
- Connect from the terminal: Run
claude mcp add msftTools https:///mcp/servers/ --transport http --callback-port 9898. - Authenticate: In Claude Code, run /mcp, select msftTools, and sign in through the browser. The first real prompt triggers the Microsoft consent challenge. Complete it and retry.
Two very different clients: a no-code enterprise agent in Copilot Studio and a local developer CLI in Claude Code, governed by one policy and captured in one audit trail.
Governance doesn't end at launch: Automating access reviews and kill switches for AI agents
Periodic access certification using Okta Identity Governance
Granting access is the easy part. The challenge is knowing when that access should end. Agents get repurposed, and their owners change roles, meaning a permission that made sense in March can quietly become a liability by September. Just like human access, agent access requires periodic certification.
To set up a review in OIG:
- Go to Identity Governance > Access Certification and click Create > Resource Campaign.
- Set the Resource Type to AI Agent, then select your target agent.
- Assign reviewers, such as an Agent Certification Reviewers group.
- Set the remediation action to Remove Access.
When a reviewer revokes access, Okta for AI Agents immediately removes the user or group entitlement, and that user can no longer access the agent.
Real-time automated kill switch using Okta Workflows
Periodic reviews catch slow drift. Fast failures—such as an agent going rogue, or a prompt attempting to coax it into extracting personally identifiable information (PII)—require something that acts in seconds.
You can build an automated kill switch with Okta Workflows using three building blocks:
- A risk attribute: A custom profile attribute, such as
RiskScore, tracks the agent's current risk level. - A trigger: When the agent detects a risky prompt or unauthorized action, a Copilot Studio event fires a workflow action that updates the agent’s risk score in Okta.
- A response: An Okta event hook triggers a workflow that listens for that profile change and immediately shuts down the agent.
When the risk threshold is crossed, the workflow deactivates the agent, revokes its OAuth tokens, and blocks further tool calls through the gateway, before any data is exposed, without waiting for an admin to step in.
Securing the future of agentic scale
Agents will keep getting more capable, and the number of tools they touch will keep growing. The organizations that scale most effectively won't be the ones that pick speed over control—they'll never have to choose.
Pairing Microsoft Copilot Studio with Okta Agent Gateway and Okta Identity Governance gives you:
- Centralized identity: Agents become managed identities with named human owners.
- Hidden secrets: Backend resource tokens never reach the agent's runtime.
- Least privilege: You decide exactly which tools each agent can call.
- Real-time auditing: Every tool call traces back through the Agent Gateway Activity Log.
- Lifecycle governance and risk control: OIG reviews catch drift, and automated kill switches stop high-risk behavior instantly.
Identity is the control plane that makes agentic AI safe to scale. When every tool call is brokered, scoped, and audited in real time, moving from prototype to production becomes a repeatable process rather than a leap of faith.
Ready to bring runtime governance to your AI workforce? Get started with Okta for AI Agents.