feat: MCP audit middleware and human-in-the-loop approval gate#9
Open
Copilot wants to merge 3 commits into
Open
feat: MCP audit middleware and human-in-the-loop approval gate#9Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
- Create RequiresApprovalAttribute for marking dangerous MCP tools - Create AuditConfig record for audit/approval configuration - Create McpAuditRecord DTO for structured audit log entries - Create McpAuditMiddleware with audit logging and Signal poll approval gate - Wire middleware into server-side agent pipeline via HausServiceCollectionExtensions - Decorate UnlockHouseDoor, SetSmartPlugPower, SwitchOffAllHouseLights with [RequiresApproval] - Add AuditConfig section to appsettings.json and appsettings.Development.json Agent-Logs-Url: https://github.com/f2calv/SmartHaus/sessions/baa200f2-2fbe-4d1c-9472-b1b54288bc8f Co-authored-by: f2calv <16097639+f2calv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/f2calv/SmartHaus/sessions/baa200f2-2fbe-4d1c-9472-b1b54288bc8f Co-authored-by: f2calv <16097639+f2calv@users.noreply.github.com>
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.
Adds centralised auditing of every MCP tool call and an attribute-driven approval gate that pauses dangerous actions pending human confirmation via Signal poll.
Audit Middleware
McpAuditMiddlewareimplements theAIAgentBuilder.Use(...)function invocation delegate — captures tool name, arguments, duration, success/failure for every callInformationlevel per invocation (plugs into existing Serilog/OTel pipeline)HausServiceCollectionExtensions.CreateAgent— no changes needed to individualMcpQueryServiceclassesHuman-in-the-Loop Approval
[RequiresApproval]attribute marks methods that gate on human confirmation before executionIPollTracker, then proceeds or deniesAlwaysRequireApproval/NeverRequireApproval) allow ops control without redeploymentDecorated Tools
UnlockHouseDoor— physical securitySetSmartPlugPower— appliance power controlSwitchOffAllHouseLights— bulk state changeConfiguration
Development config disables approval and exempts all current tools for unblocked local iteration.