Skip to content

docs(guardrails): add Microsoft Agent 365 MCP guardrail page - #1011

Merged
yucheng-berri merged 12 commits into
mainfrom
litellm_agent365_docs
Sep 16, 2026
Merged

yucheng-berri merged 12 commits into
mainfrom
litellm_agent365_docs

Conversation

@yucheng-berri

@yucheng-berri yucheng-berri commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Adds the guardrail page for the new Microsoft Agent 365 integration, which evaluates MCP tool calls with Microsoft Defender through the Agent 365 tool-evaluation API, authenticating as the calling user via the Entra On-Behalf-Of flow. The page covers the pre_mcp_call mode, OBO prerequisites, quickstart config and curl, parameter and failure tables, and conversation grouping

Also registers the AGENT365_* environment variables in config_settings.md and adds the sidebar entry before Microsoft Purview. Companion code PR: BerriAI/litellm#38241


Open in Devin Review

Note

Low Risk
Documentation-only changes with no runtime or security behavior in this repository.

Overview
Documents the agent_365 MCP guardrail that sends MCP tool calls to Microsoft Agent 365 / Defender before execution, using Entra On-Behalf-Of so evaluations run as the signed-in user.

Adds docs/proxy/guardrails/microsoft_agent_365.md with Entra onboarding steps, pre_mcp_call quickstart (config.yaml, env vars, curl), end-to-end client flow, config/failure tables, conversationId grouping, and RFC 9728 browser sign-in for single-server MCP routes. Registers five AGENT365_* variables in config_settings.md and links the page in sidebars.js before Microsoft Purview (implementation is in companion code PR BerriAI/litellm#38241).

Reviewed by Cursor Bugbot for commit 5258ff8. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
litellm Ready Ready Preview Sep 15, 2026 11:25pm UTC

Request Review

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

…in payload, defender skipped handling

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

…ial failures

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

…and metadata

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…lenge only default-on guardrails

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

yucheng-berri and others added 2 commits September 14, 2026 23:58
…rdrail can govern

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ly on single-server MCP routes

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 1 new potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review


The LiteLLM credential travels separately in the `x-litellm-api-key` header, which leaves the `Authorization` header free to carry the user's Entra token

That only works on MCP servers where `Authorization` stays with the gateway. A server with `auth_type: oauth2`, `oauth_delegate` or `true_passthrough`, or one that lists `Authorization` under `extra_headers`, sends that header upstream or fills it with its own token, so the guardrail never sees an Entra user token there and every tool call on it fails closed with HTTP 401. Forwarding a client API key header such as `x-api-key`, `api-key` or `apikey` under `extra_headers` is fine: it travels upstream in its own header while the Entra token stays in `Authorization`, and sign-in discovery keeps working for that server

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 OAuth tool calls falsely ruled out

An oauth2 server can evaluate calls when Authorization contains a gateway-audienced Entra token. Server OAuth replaces only the upstream credential.

Learn more

The Agent 365 hook reads incoming_bearer_token, which pre_call_tool_check extracts directly from the raw inbound Authorization header. MCP server authentication prepares a separate outbound credential and does not remove that raw value before the hook runs. Therefore, auth_type: oauth2 prevents Agent 365 browser discovery but does not make evaluation impossible when the client supplies the Entra token itself. Authorization-forwarding modes also expose the inbound token to the hook, although one header cannot generally serve both Agent 365 and an unrelated upstream issuer.

Example: A client sends x-litellm-api-key plus a gateway-audienced Entra token in Authorization to an oauth2 server. Agent 365 exchanges that inbound token successfully. LiteLLM then uses the server's stored OAuth token for the upstream call instead of forwarding the Entra token.

Recommended fix: Describe these server modes as incompatible with automatic Agent 365 sign-in discovery, not with guardrail evaluation. Explain that manual Entra-token delivery can work when upstream authentication occupies a separately resolved credential slot.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5258ff8. Configure here.

…oc links (#1404)

* docs(guardrails): agent 365 agent identity auth mode and env keys

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(guardrails): use typed Graph segments for agent identity setup and cover both auth modes in overview

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(guardrails): replace agent 365 agent identity mode with the four caller scenarios and sibling doc links

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(guardrails): agent 365 guardrail applies to servers whose Authorization header carries the Entra token

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(guardrails): scope the scenario D sign-in challenge to default-on Agent 365 guardrails

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(guardrails): name the authorization and oauth2_id_jag auth types in the agent 365 server list

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(guardrails): tighten the Agent 365 page to half its length

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yucheng <yucheng@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review


### B. MCP clients that sign the user in (Claude Code, VS Code, Cursor)

The user registers LiteLLM's per-server MCP URL with only the LiteLLM key. The first call gets a 401 with an [RFC 9728](https://www.rfc-editor.org/rfc/rfc9728) challenge, the client opens the Microsoft sign-in page, and from then on it attaches and refreshes the Entra token itself. Setup is under [Browser sign-in](#browser-sign-in-from-the-mcp-client); client-side mechanics are on [MCP OAuth](/docs/mcp_oauth)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Browser sign-in flow is unavailable

With only x-litellm-api-key, agent_365 does not emit the documented RFC 9728 challenge. MCP clients cannot start Entra sign-in, so guarded calls fail with 401.

Learn more

The companion implementation only performs OBO exchange after a caller supplies an Entra bearer token. Its final patch removes Agent 365 protected-resource metadata, connect-time challenge generation, and token probing. The generic MCP challenge remains tied to MCP server authentication modes, not this guardrail. Therefore scenario B and the Browser sign-in section describe behavior absent from the referenced implementation.

Example: A user configures deepwiki with auth_type: none, enables the guardrail, and registers /deepwiki/mcp with only x-litellm-api-key. The client receives no Agent 365 WWW-Authenticate challenge. Its tool call reaches the guardrail without an Entra assertion and returns 401 instead of opening Microsoft sign-in.

Recommended fix: Remove the browser sign-in scenario, challenge claims, metadata examples, and related failure-table language until the stacked MCP discovery changes ship. Otherwise update the companion implementation and tests to provide that flow before publishing these instructions.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

1. LiteLLM admission: key or JWT check, then the key's MCP server and tool permissions. A bad credential fails here with the usual 401 or 403
2. The guardrail reads the Entra token from `Authorization`. Missing: HTTP 401. On the per-server `/mcp` route the 401 carries a sign-in challenge, see [Browser sign-in](#browser-sign-in-from-the-mcp-client)
3. OBO exchange, cached for the token's lifetime
4. The pending call goes to Agent 365: tool name, arguments, server name, `conversationId`, and the tool's description and input schema when the server published them. The user's prompt is never sent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Tool metadata transmission is overstated

For tools with published metadata, agent_365 sends only the tool name. Defender never receives the documented description or input schema.

Learn more

The companion PR's final patch removes tool-description and input-schema propagation from the MCP request objects and the Agent 365 payload. The remaining payload builds tool as { "name": tool_name }.

Example: An MCP server publishes send_email with a description and a JSON schema containing recipient and body fields. Agent 365 receives the name and actual arguments, but not that description or schema.

Recommended fix: Document only the fields the current payload sends. Add the metadata claim later if the stacked implementation that propagates those fields ships.

Suggested change
4. The pending call goes to Agent 365: tool name, arguments, server name, `conversationId`, and the tool's description and input schema when the server published them. The user's prompt is never sent
4. The pending call goes to Agent 365: tool name, arguments, server name, and `conversationId`. The user's prompt is never sent
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@yucheng-berri
yucheng-berri merged commit e276aaf into main Sep 16, 2026
5 checks passed
@yucheng-berri
yucheng-berri deleted the litellm_agent365_docs branch September 16, 2026 01:15

This branch was previously deployed

1 inactive deployment
Preview — cf579835 Deployed Sep 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants