Python: Autolabelling MCP servers based on hints and Github MCP server ifc labels#6171
Merged
eavanvalkenburg merged 19 commits intoJun 29, 2026
Merged
Conversation
…ecurity, and change context label only using the labels of unhidden result from tools
…nto pr/fides-mcp-autolabel-clean
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR expands the FIDES security samples and core framework to support securely running remote MCP tools with local policy enforcement, including tool auto-labeling from MCP annotations, per-result IFC label parsing from MCP _meta, and improved variable-reference tool chaining.
Changes:
- Add
SecureMCPToolProxy, MCP tool auto-labeling (apply_mcp_security_labels), and_meta.ifcresult label propagation into per-itemsecurity_label. - Add a new GitHub MCP sample demonstrating direct MCP URL connection with local FIDES enforcement (CLI + DevUI) and update docs accordingly.
- Enhance variable-reference expansion in tool arguments and adjust label-taint behavior to account for hidden vs visible items; add tests for the new behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/02-agents/security/repo_confidentiality_example.py | Adds explicit DevUI auth token generation and passes it into serve(...). |
| python/samples/02-agents/security/github_mcp_example.py | New sample for direct GitHub MCP URL + local FIDES enforcement with DevUI/CLI modes. |
| python/samples/02-agents/security/email_security_example.py | Adds debug logging flag, explicit DevUI token handling, and content-filter exception handling. |
| python/samples/02-agents/security/README.md | Documents the new GitHub MCP sample and DevUI bearer token behavior. |
| python/samples/02-agents/security/FIDES_DEVELOPER_GUIDE.md | Updates/extends developer guide with MCP integration guidance and refreshed sections. |
| python/packages/core/tests/test_security.py | Adds tests for variable reference expansion, auto-hide behavior, mixed-result tainting, and MCP _meta.ifc parsing/stamping. |
| python/packages/core/agent_framework/security.py | Implements variable reference expansion for tool args, refines context tainting rules, and adds MCP auto-labeling + _meta.ifc stamping + SecureMCPToolProxy. |
| python/packages/core/agent_framework/_mcp.py | Propagates MCP result _meta onto each produced Content via __mcp_result_meta__. |
| python/packages/core/agent_framework/init.py | Exposes SecureMCPToolProxy and apply_mcp_security_labels from the package. |
| docs/features/FIDES_IMPLEMENTATION_SUMMARY.md | Documents MCP hint labeling and _meta.ifc result label support. |
| docs/decisions/0024-prompt-injection-defense.md | Adds design notes for MCP hint-based tool labeling and _meta.ifc result label enforcement. |
Comments suppressed due to low confidence (1)
python/packages/core/agent_framework/security.py:1
- The docstring claims
destructiveHintis used for label inference, but the implementation only readsreadOnlyHintandopenWorldHint. Either incorporatedestructiveHintinto_map_mcp_annotations_to_labelsor remove it from the documentation to avoid misleading users.
# Copyright (c) Microsoft. All rights reserved.
Contributor
… instead of /insiders - Switch MCP_URL from /mcp/insiders to /mcp/ in github_mcp_example.py - Add MCP_HEADERS constant with X-MCP-Features: ifc_labels to opt-in to server-side IFC label emission in _meta payloads - Fix SecureMCPToolProxy to pass headers via httpx.AsyncClient so they are included on session.initialize(), not just on tool calls (was causing 401 to silently surface as anyio cancel-scope CancelledError) - Update README, FIDES_DEVELOPER_GUIDE, FIDES_IMPLEMENTATION_SUMMARY, and 0024-prompt-injection-defense.md to remove all /insiders references
shrutitople
force-pushed
the
pr/fides-mcp-autolabel-clean
branch
from
June 18, 2026 10:40
bc4264e to
3831fd0
Compare
…ntConfig quarantine client global behavior
eavanvalkenburg
approved these changes
Jun 23, 2026
eavanvalkenburg
left a comment
Member
There was a problem hiding this comment.
couple of small comments, but nothing major
Contributor
|
Please resolve the comments that are addressed. |
Contributor
Author
|
All the existing comments are addressed. |
Contributor
|
Will approve once the pipelines pass |
TaoChenOSU
approved these changes
Jun 25, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jun 25, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jun 26, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jun 27, 2026
eavanvalkenburg
enabled auto-merge
June 29, 2026 08:27
This was referenced Jun 29, 2026
RudrenduPaul
added a commit
to RudrenduPaul/toolgovern
that referenced
this pull request
Jul 18, 2026
Implement the smallest real primitive that lets a genuine label-propagation check exist, scoped deliberately against Microsoft Agent Framework's FIDES (microsoft/agent-framework#6171, #6860, both shrutitople) rather than attempting a reimplementation of it. - ConfidentialityLabel: a fixed, closed, ordered type (public < internal < confidential < restricted) in types.ts/types.py. - IfcPolicy: a new optional ScopeDeclaration.ifc field -- a hand-declared source/sink labeling map the caller maintains. Not automatic inference: toolgovern has no way to know a resource is confidential or a destination is untrusted from a bare argument, so this only evaluates what is declared. - TG08-confidential-source-to-untrusted-sink: fires when a call's declared source argument names a resource labeled confidential-or-higher AND its declared sink argument names a destination whose trust tier is lower (deny) or was never declared at all (require-approval -- fails closed on ambiguity, never a silent allow). - Ported to Python (classifier/information_flow.py), same semantics, same matching style as isCredentialGranted (exact / trailing-segment / substring). - 12 new tests per language proving both sides: allow when sink trust covers the source label, deny when explicitly lower-trust, and require-approval when the sink is undeclared. Honest scope, documented in docs/security-model.md (finding #12) and SECURITY.md: no automatic label inference, no MCP gateway integration, no cross-call taint tracking, no reader-scoped lattice, no result-value inspection. Checked against the real upstream PRs this was scoped from -- #6171 (MCP-annotation autolabeling, _meta.ifc result-label parsing) and #6860 (gateway-delegated policy evaluation, a readers-lattice label type) are both real, larger engineering efforts than a classifier rule can close; this is the one primitive both presuppose, not a smaller version of either. Rule counts: TS classifier 34 -> 35 synchronous rules (36 total with the async-only TG03-dns-resolves-private); Python 35 -> 36 (folds the DNS check into one synchronous registry). README, docs/concepts.md, docs/policy-schema.md, python/README.md, benchmarks/README.md updated to match; the 2026-07-12 latency benchmark numbers are left as a dated historical measurement rather than fabricated as re-measured against the new count.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This PR adds end-to-end MCP security integration for FIDES by introducing automatic tool labeling from MCP annotations and per-result IFC label parsing from MCP metadata. It also adds a SecureMCPToolProxy convenience path for local MCP execution with policy enforcement, expands security test coverage for MCP labeling behavior, and updates docs and samples to reflect the new workflow.
Description
Core security pipeline updates for MCP annotation-to-label mapping and _meta.ifc result label handling.
MCP transport and framework export updates to support secure labeling flow.
New consolidated GitHub MCP sample with CLI/attack/devui flows and debug-gated security output.
Security documentation refresh (developer guide, implementation summary, ADR notes), including stale/duplicate cleanup.
Sample/document cleanup replacing older split MCP sample references with the consolidated example.
Impact:
Improves deterministic prompt-injection defense for MCP-connected agents by ensuring tool-level and result-level labels are consistently enforced locally before model-visible execution.