Skip to content

Commit f642a28

Browse files
committed
Document PII sanitizer and MCP tool decorator, add ModelContextProtocol dep
Grow the README with an example of constructing BedrockGuardrailsSanitizer directly and note the structured-content limitation. Bring in ModelContextProtocol 2.1.0 (for the tool-decorator types) and record the new user-facing feature in the autover changelog.
1 parent 05b615a commit f642a28

3 files changed

Lines changed: 23 additions & 5 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
@@ -6,7 +6,8 @@
66
"ChangelogMessages": [
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.",
9-
"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."
9+
"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)."
1011
]
1112
}
1213
]

src/AWS.Bedrock.MAG/AWS.Bedrock.MAG.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<PackageReference Include="AWS.Logger.Core" Version="4.0.3" />
3333
<PackageReference Include="AWSSDK.CloudWatch" Version="4.0.103.2" />
3434
<PackageReference Include="Microsoft.AgentGovernance" Version="5.0.0" />
35+
<PackageReference Include="ModelContextProtocol" Version="2.1.0" />
3536
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300" PrivateAssets="All" />
3637
</ItemGroup>
3738

src/AWS.Bedrock.MAG/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ AWS backends for [Microsoft's Agent Governance Toolkit](https://github.com/micro
44

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

8-
> Preview (0.1.0). The API may change while the toolkit's extension surface stabilizes. Remaining features (PII sanitization, 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. Remaining features (high-level MCP/DI entry points, inline guardrail checks) ship in follow-up preview releases.
910
1011
## Install
1112

@@ -38,21 +39,36 @@ using var audit = new CloudWatchAuditSink(new CloudWatchAuditOptions
3839
audit.Subscribe(kernel.AuditEmitter);
3940
```
4041

41-
The high-level MCP and DI entry points that wire these up for you (`WithBedrockGovernance`, `AddBedrockGovernance`, `AddBedrockGuardrailsPolicy`, `AddCloudWatchAudit`) land in a follow-up preview release.
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:
45+
46+
```csharp
47+
var sanitizer = new BedrockGuardrailsSanitizer(new BedrockSanitizationOptions
48+
{
49+
GuardrailId = "gr-abc123",
50+
});
51+
52+
var scrubbed = await sanitizer.SanitizeAsync(rawToolText, cancellationToken);
53+
```
4254

4355
## Required IAM
4456

4557
The credentials the agent runs under need:
4658

47-
- `bedrock:ApplyGuardrail` on the guardrail evaluated by the policy backend.
59+
- `bedrock:ApplyGuardrail` on the guardrail (policy backend and PII sanitization).
4860
- `logs:CreateLogGroup`, `logs:CreateLogStream`, `logs:PutLogEvents` on the audit log group (audit sink).
4961
- `cloudwatch:PutMetricData` (audit metrics, when `EmitMetrics` is on).
5062

5163
The audit sink uses [AWS.Logger.Core](https://github.com/aws/aws-logging-dotnet), which creates the log group and stream on first use, so the `logs:Create*` permissions are required.
5264

65+
## Limitations
66+
67+
PII sanitization covers the **text** blocks of an MCP tool result, matching the toolkit's own sanitizer. A tool result's `StructuredContent` (structured JSON) is passed through unchanged. If a tool returns PII in `StructuredContent`, mirror it into a text block so the guardrail sees it. Sanitizing arbitrary structured output is a post-v1 follow-up.
68+
5369
## Cost
5470

55-
This package calls billed AWS services: Bedrock Guardrails (priced per text unit evaluated) on every governed tool call, plus CloudWatch Logs ingestion/storage and CloudWatch custom metrics from the audit sink. Tune `FlushInterval` to trade audit latency against request volume.
71+
This package calls billed AWS services: Bedrock Guardrails (priced per text unit evaluated, once for policy on the input and once for PII on the output), CloudWatch Logs ingestion and storage, and CloudWatch custom metrics. Tune `FlushInterval` to trade audit latency against request volume.
5672

5773
## License
5874

0 commit comments

Comments
 (0)