Your AI agent shouldn't hold the keys: Securing and governing Microsoft Copilot Studio agents with Okta

Routing every Microsoft MCP tool call through Okta keeps backend tokens out of the agent, limits each agent to the tools it actually needs, and leaves an audit trail you can act on.

About the Author

23 noviembre 2026 Time to read: ~

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.

Architecture diagram showing a user interacting with an AI agent connected through a central Okta Agent Gateway layer to downstream MCP and API servers. 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:

  1. Interception: The Copilot Studio agent routes its tool call to Okta Agent Gateway, never directly to the MCP server.
  2. 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.
  3. 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 dimensionDirect MCP connectionOkta Agent Gateway
Backend token storageStored inside the agent runtimeIsolated inside Okta Agent Gateway
User consentHandled ad hoc per toolBrokered centrally
Tool access scopeAll tools exposed by the MCP serverOnly the tools you select
Audit trailScattered across multiple service logsUnified in the Agent Gateway Activity Log
Access reviewsNone by defaultAutomated OIG certification campaigns
Incident response and emergency shutoffManual, if possible at allAutomated 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 RiskScore or BusinessUnit that you can reference in policy, including the RiskScore attribute 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.

Agent build screen for MSFTDemoAgentusingOktaGateway showing Claude Opus 5.5, Teams + Microsoft 365 channel, Search all websites knowledge, and instructions editor 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.

  1. Register the app: In the Azure portal, open App registrations, select New registration, choose Web as the application type, and register it.
  2. Create a client secret: Under Certificates & secrets, generate a secret and save the value for configuration in Okta.
Microsoft Azure "Certificates & secrets" screen for CisOktaAgentImportApp showing no client secrets created Certificates and secrets in the Azure portal
  1. Grant the import permission: Under API permissions, add the Microsoft Graph application permission CopilotPackages.Read.All, then grant admin consent for the tenant.
Microsoft Entra API permissions screen for CisOktaAgentImportApp showing Delegated and Application permissions, User.Read configured, and CopilotPackages.Read.All checked Adding the CopilotPackages.Read.All permission
  1. Add the Okta redirect URI: Under Authentication, add https://.okta.com/oauth2/v1/sts/callback and enable ID tokens and access tokens.
  2. 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.
Microsoft Entra API permissions screen for CisOktaAgentImportApp showing Delegated permissions selected and McpServers.Calendar.All checked under mcpservers Requesting Agent Tools MCP permissions
Microsoft Entra API permissions screen for CisOktaAgentImportApp showing delegated permissions granted for McpServers.Calendar.All, McpServers.Mail.All, and McpServers.Teams.All under Agent Tools Admin consent granted for the MCP permissions

Step 3: Import and register the agent in Okta

  1. Add the integration: In the Okta Admin Console, go to Applications and Resources, search the catalog, and select Microsoft Office 365.

Okta Admin Console App Integration Catalog showing a search for "365" with Microsoft Office 365 results displayed Searching the Okta app catalog for Microsoft Office 365
  1. 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.
Okta "AI agent import" configuration screen showing "Enable AI agent import" checked, masked Client ID and Client secret fields, and a "Test API Credentials" button Enabling AI agent import and entering the Azure client credentials
  1. 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.
Okta "Imported AI agents" dashboard under Microsoft Office 365 Agent import, showing 36 unconfirmed agents with MSFTDemoAgentusingOktaGateway selected and a "Register AI agent" action button Imported Copilot Studio agents, with the Register AI agent action
  1. Generate credentials and activate: Under Client registration > Client secret, generate a secret for Copilot Studio to use, then activate the agent.
  2. Allow user access: Under User access, click Allow user access and choose Create a new OIDC app.
Okta dashboard for MSFTDemoAgentusingOktaGateway showing staged status, Microsoft Office 365 Agent import details, and the User access setup tab with an "Allow user access" button The User access tab for a registered AI agent
  1. Assign users: Activate the new OpenID Connect (OIDC) app and assign the users or groups who can access the agent.
Okta Assignments dashboard for MSFTDemoAgentusingOktaGateway showing active status, the Groups filter selected, and the "Everyone" group assigned at priority 1 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.

Configuration screen for MSFTDemoAgentusingOktaGateway showing base attributes for the Copilot Studio platform alongside custom attributes including a "Low" agent risk score and mapped MSFT Agent ID 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.

  1. 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.
  2. Point to Entra ID: For the authorization server, select External authorization server and copy the details from the Azure app's Endpoints page.
MCP serverResource identifier URL
Calendarhttps://agent365.svc.cloud.microsoft/agents/tenants//servers/mcp_CalendarTools
Mailhttps://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_MailTools
Teamshttps://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_TeamsTools
OneDrivehttps://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_OneDriveTools
SharePointhttps://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_SharePointTools
User directoryhttps://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_UserDirectoryTools
Taskshttps://agent365.svc.cloud.microsoft/agents/tenants/<tenant_ID>/servers/mcp_TasksTools
Enterprisehttps://mcp.svc.cloud.microsoft/enterprise
Configuration screen for Microsoft MCP - Mail showing the "Add authorization server" dropdown menu with options to select an External server or an Okta custom authorization server Adding an external authorization server to a Microsoft MCP server in Okta
  1. Add credentials: Enter the client ID and client secret from the Azure app, then select All available scopes. Don't customize the scopes.
  2. Discover tools: Choose Test credentials and discover tools. Okta lists all the tools the server exposes.
MCP server configuration interface showing a green "Success" badge next to the "Test credentials and discover tools" button, with 22 discovered tools listed below Okta discovers 22 tools on the Mail MCP server

Repeat for each server you want to expose.

Admin dashboard listing active MCP servers (Microsoft MCP - Calendar and Microsoft MCP - Mail), both showing ACTIVE status and options to connect an agent gateway 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.

  1. Create the gateway: Go to Security > Agent Gateway, select Create Agent Gateway, and give it a name and description.

Okta Admin Console showing the Agent Gateway section Agent Gateway page in the Okta Admin Console
  1. Assign agents: Select the agent you imported from Copilot Studio.
Microsoft MCP Agentgateway configuration page in a web-based admin console Assigning an AI agent to the gateway
  1. Add resource connections: Add the Microsoft MCP servers you created.
Add MCP servers to Agent Gateway modal showing selected Mail and Calendar MCP servers for CisOktaAgentImportApp, with Cancel and Save buttons Adding Mail and Calendar MCP servers to the Agent Gateway
  1. Choose the tools: Select Manage tools for each server, then specify exactly which tools the agent may call.
Tool customization screen for Agent Gateway showing unconnected Microsoft MCP Calendar and Mail tools, with "Manage tools" buttons Selecting the tools available through the gateway
  1. 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

  1. Add an MCP tool: In Copilot Studio, open your agent, select Add tool, and choose Model Context Protocol.

Add a tool modal over MSFTDemoAgentusingOktaGateway showing a search bar, filter tabs including MCP, a list of tools, and a context menu Adding a Model Context Protocol tool in Copilot Studio
  1. Point to the gateway: Use your Okta Agent Gateway URL as the server URL.
  2. 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.
  3. Allowlist the redirect: Add the redirect URL generated by Copilot Studio as a sign-in redirect URI in the agent's Okta app.
  4. 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.

Chat interface for MSFTDemoAgentusingOktaGateway showing a search icon and a prompt box with "+ list tools" Copilot chat with the prompt "list tools"
Copilot interface listing web search, browse, file analysis skills, and Outlook email and calendar capabilities 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:

  1. 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.

Okta Admin Console AI agents screen showing MSFTDemoAgentusingOktaGateway and the "Register AI agent" menu Registering a new AI agent in Okta
Web dashboard form for registering an AI agent. Naming the Claude Code agent
  1. Link an OIDC app: Create a new OIDC app linked to the agent and assign owners.

  2. 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.

Okta admin interface showing the Client ID metadata (CIMD) configuration page Enabling the client ID metadata document for Claude Code
  1. Assign users: Activate the OIDC app and assign users.
  2. Add it to the gateway: Open your Microsoft MCP gateway under Security > Agent Gateway, and add the Claude Code agent alongside the Copilot agent.
  3. Connect from the terminal: Run claude mcp add msftTools https:///mcp/servers/ --transport http --callback-port 9898.
  4. 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:

  1. Go to Identity Governance > Access Certification and click Create > Resource Campaign.
  2. Set the Resource Type to AI Agent, then select your target agent.
  3. Assign reviewers, such as an Agent Certification Reviewers group.
  4. 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. 

About the Author

Continue your Identity journey