Skip to content

Commit d9fe4f8

Browse files
committed
Document high-level MCP/DI/imperative entry points
Grow the README with the primary MCP builder (WithBedrockGovernance), DI container (AddBedrockGovernance), and imperative kernel (AddBedrockGuardrailsPolicy / AddCloudWatchAudit) entry points that wire up policy, PII sanitization, and audit together. Add the corresponding changelog message; no new csproj dependencies (hosting/DI abstractions come transitively via Microsoft.AgentGovernance and ModelContextProtocol).
1 parent ee91a13 commit d9fe4f8

2 files changed

Lines changed: 27 additions & 25 deletions

File tree

.autover/changes/AWS.Bedrock.MAG-initial-preview.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"Initial preview scaffold (0.1.0-preview): package infrastructure and a shared internal guardrail client wrapping ApplyGuardrail. User-facing features (policy backend, audit sink, PII sanitizer, high-level entry points) ship in follow-up preview releases.",
88
"Bedrock Guardrails policy backend: an IExternalPolicyBackend that evaluates tool-call context via ApplyGuardrail and denies calls that trip the guardrail. Fails closed on Bedrock/AWS errors by default. Wire it up imperatively with PolicyEngine.AddExternalBackend.",
99
"CloudWatch audit sink: subscribes to the toolkit's AuditEmitter and writes governance events to CloudWatch Logs via AWS.Logger.Core, aggregating per-agent/per-policy counters and publishing them as CloudWatch metrics on a configurable flush interval. Delivery is background and non-blocking; sink hiccups can't break the governance loop.",
10-
"Bedrock Guardrails PII sanitization for MCP tool output: BedrockGuardrailsSanitizer runs the ANONYMIZE action on tool-result text blocks (30+ PII entity types). GovernedBedrockMcpServerTool decorates an MCP tool so sanitization runs after the toolkit's own scrubbing. Structured (non-text) tool content is passed through unchanged (post-v1 follow-up)."
10+
"Bedrock Guardrails PII sanitization for MCP tool output: BedrockGuardrailsSanitizer runs the ANONYMIZE action on tool-result text blocks (30+ PII entity types). GovernedBedrockMcpServerTool decorates an MCP tool so sanitization runs after the toolkit's own scrubbing. Structured (non-text) tool content is passed through unchanged (post-v1 follow-up).",
11+
"High-level entry points: WithBedrockGovernance on an MCP server builder, AddBedrockGovernance on IServiceCollection, and GovernanceKernel.AddBedrockGuardrailsPolicy / AddCloudWatchAudit for imperative wiring. BedrockGovernanceOptions carries umbrella Region/Credentials/FailClosed defaults that flow into each feature."
1112
]
1213
}
1314
]

src/AWS.Bedrock.MAG/README.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# AWS.Bedrock.MAG
22

3-
AWS backends for [Microsoft's Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit). This package plugs AWS managed services into the toolkit's extension points so a .NET AI agent can pick up Bedrock-backed policy, PII sanitization, and durable audit with a few lines of configuration.
3+
AWS backends for [Microsoft's Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit). This package plugs AWS managed services into the toolkit's existing extension points, so a .NET AI agent gets Bedrock-backed policy, PII sanitization, and durable audit with about two lines of configuration.
44

55
- **Bedrock Guardrails policy backend**: ML policy evaluation added alongside the toolkit's rule, OPA, and Cedar backends. Fails closed on error.
6-
- **CloudWatch audit sink**: writes governance events to CloudWatch Logs with aggregated metrics.
76
- **Bedrock Guardrails PII sanitization**: redacts or blocks 30+ PII entity types in MCP tool output.
7+
- **CloudWatch audit sink**: writes governance events to CloudWatch Logs with aggregated metrics.
88

9-
> Preview (0.1.0). The API may change while the toolkit's extension surface stabilizes. Remaining features (high-level MCP/DI entry points, inline guardrail checks) ship in follow-up preview releases.
9+
> Preview (0.1.0). The API may change while the toolkit's extension surface stabilizes. Inline guardrail checks (no pre-created Bedrock guardrail required) ship in a follow-up preview release.
1010
1111
## Install
1212

@@ -18,45 +18,46 @@ Targets net8.0. Requires `Microsoft.AgentGovernance` 5.0.0.
1818

1919
## Use it
2020

21-
### Imperative (you already hold a kernel)
21+
### MCP server (primary)
2222

23-
Attach the policy backend and audit sink directly to a `GovernanceKernel` you constructed:
23+
Add `WithBedrockGovernance` after the toolkit's `WithGovernance`:
2424

2525
```csharp
26-
var kernel = new GovernanceKernel(new GovernanceOptions { PolicyPaths = { "policies/default.yaml" } });
27-
28-
kernel.PolicyEngine.AddExternalBackend(
29-
new BedrockGuardrailsPolicyBackend(new BedrockGuardrailsPolicyOptions
26+
builder.Services.AddMcpServer()
27+
.WithGovernance(o => o.PolicyPaths.Add("policies/default.yaml")) // Microsoft's toolkit
28+
.WithBedrockGovernance(o => // this package
3029
{
31-
GuardrailId = "gr-abc123",
32-
}));
30+
o.Policy.GuardrailId = "gr-abc123";
31+
o.EnablePiiSanitization = true; // ANONYMIZE tool output
32+
o.Audit.LogGroupName = "/agent-governance/audit";
33+
});
34+
```
35+
36+
### Non-MCP agent (plain DI)
3337

34-
using var audit = new CloudWatchAuditSink(new CloudWatchAuditOptions
38+
```csharp
39+
builder.Services.AddBedrockGovernance(o =>
3540
{
36-
LogGroupName = "/agent-governance/audit",
37-
MetricNamespace = "AgentGovernance/Bedrock",
41+
o.Policy.GuardrailId = "gr-abc123";
42+
o.Audit.MetricNamespace = "AgentGovernance/Bedrock";
3843
});
39-
audit.Subscribe(kernel.AuditEmitter);
44+
// Requires a GovernanceKernel already in DI (from the toolkit).
4045
```
4146

42-
### PII sanitization on MCP tool output
43-
44-
`BedrockGuardrailsSanitizer` runs the ANONYMIZE action on the text blocks of an MCP tool result. The MCP server wiring that plugs it in for you (via `WithBedrockGovernance`) lands in the next preview; in the meantime you can construct the sanitizer directly to feed it tool-result text:
47+
### Imperative (you already hold a kernel)
4548

4649
```csharp
47-
var sanitizer = new BedrockGuardrailsSanitizer(new BedrockSanitizationOptions
48-
{
49-
GuardrailId = "gr-abc123",
50-
});
50+
var kernel = new GovernanceKernel(new GovernanceOptions { PolicyPaths = { "policies/default.yaml" } });
5151

52-
var scrubbed = await sanitizer.SanitizeAsync(rawToolText, cancellationToken);
52+
kernel.AddBedrockGuardrailsPolicy(o => o.GuardrailId = "gr-abc123");
53+
using var audit = kernel.AddCloudWatchAudit(o => o.LogGroupName = "/agent-governance/audit");
5354
```
5455

5556
## Required IAM
5657

5758
The credentials the agent runs under need:
5859

59-
- `bedrock:ApplyGuardrail` on the guardrail (policy backend and PII sanitization).
60+
- `bedrock:ApplyGuardrail` on the guardrail (policy and PII sanitization).
6061
- `logs:CreateLogGroup`, `logs:CreateLogStream`, `logs:PutLogEvents` on the audit log group (audit sink).
6162
- `cloudwatch:PutMetricData` (audit metrics, when `EmitMetrics` is on).
6263

0 commit comments

Comments
 (0)