feat: add pre-execution MCP trust verification hook (#2501)#2590
Open
pranav-afk wants to merge 1 commit into
Open
feat: add pre-execution MCP trust verification hook (#2501)#2590pranav-afk wants to merge 1 commit into
pranav-afk wants to merge 1 commit into
Conversation
Introduce a pluggable TrustVerifier that runs before MCP tool calls, with opt-in allowlist/denylist settings and fail-open defaults so existing workflows stay unchanged until configured.
|
@pranav-afk is attempting to deploy a commit to the Arc53 Team on Vercel. A member of the Team first needs to authorize it. |
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.
Add a configurable pre-execution trust verification hook for MCP tool calls so operators can block, warn, or allow remote MCP servers before any tool action runs.
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature — pluggable security middleware for MCP tool execution.
Why was this change needed? (You can also link to an open issue here)
DocsGPT currently has no framework-level gate before MCP tool execution. A misconfigured or malicious MCP server could run arbitrary operations without a pre-flight trust check. As third-party MCP servers become more common, this is an important security surface. Closes Add pre-execution trust verification hook for MCP tool calls #2501.
Other information:
application/security/mcp_trust.pywith:TrustVerifierprotocol (sync or async)TrustContext/TrustResult/TrustVerdict(allowed|blocked|warned)set_trust_verifier()for custom backends (allowlist API, SBOM, policy engine, etc.)AllowlistTrustVerifier(URI/host allowlist + denylist)enforce_mcp_trust()raisesMCPTrustBlockedErrorwhen blockedMCPTool.execute_actionbefore anycall_toolnetwork callMCP_TRUST_VERIFICATION_ENABLED(defaultfalse)MCP_TRUST_ALLOWED_SERVERS/MCP_TRUST_BLOCKED_SERVERS(CSV)MCP_TRUST_ON_WARN(proceed|block)MCP_TRUST_FAIL_OPEN(defaulttrue— verifier errors do not hard-fail)tests/security/test_mcp_trust.py(20 passed)Custom verifier example:
Type of change
• [ ] Bug fix (non-breaking change which fixes an issue)
• [x] New feature (non-breaking change which adds functionality)
• [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
• [ ] This change requires a documentation update
How has this been tested?
• [x] Unit tests
• [x] Manual tests
Test Configuration:
• Python: 3.11
• Suite: tests/security/test_mcp_trust.py (20 passed)
Checklist:
• [x] My code follows the style guidelines of this project
• [x] I have already covered my code with unit tests
• [x] I have made corresponding changes to the documentation (N/A — settings documented in settings.py)
• [x] I have added an explanation of my changes
Related issues
Closes #2501