Skip to content

feat: add pre-execution MCP trust verification hook (#2501)#2590

Open
pranav-afk wants to merge 1 commit into
arc53:mainfrom
pranav-afk:feature/mcp-trust-verification-hook
Open

feat: add pre-execution MCP trust verification hook (#2501)#2590
pranav-afk wants to merge 1 commit into
arc53:mainfrom
pranav-afk:feature/mcp-trust-verification-hook

Conversation

@pranav-afk

Copy link
Copy Markdown

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:

    • New module application/security/mcp_trust.py with:
      • TrustVerifier protocol (sync or async)
      • TrustContext / TrustResult / TrustVerdict (allowed | blocked | warned)
      • set_trust_verifier() for custom backends (allowlist API, SBOM, policy engine, etc.)
      • Built-in AllowlistTrustVerifier (URI/host allowlist + denylist)
      • enforce_mcp_trust() raises MCPTrustBlockedError when blocked
    • Wired into MCPTool.execute_action before any call_tool network call
    • Opt-in by default — existing workflows unchanged until configured
    • Settings:
      • MCP_TRUST_VERIFICATION_ENABLED (default false)
      • MCP_TRUST_ALLOWED_SERVERS / MCP_TRUST_BLOCKED_SERVERS (CSV)
      • MCP_TRUST_ON_WARN (proceed | block)
      • MCP_TRUST_FAIL_OPEN (default true — verifier errors do not hard-fail)
    • Unit tests in tests/security/test_mcp_trust.py (20 passed)
    • Backend-only change (no UI screenshots)

    Custom verifier example:

    from application.security.mcp_trust import (
        TrustContext, TrustResult, TrustVerdict, set_trust_verifier,
    )
    
    class MyVerifier:
        def verify(self, context: TrustContext) -> TrustResult:
            return TrustResult(verdict=TrustVerdict.ALLOWED, reason="ok")
    
    set_trust_verifier(MyVerifier())

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

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.
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

@pranav-afk is attempting to deploy a commit to the Arc53 Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added application Application tests Tests labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

application Application tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pre-execution trust verification hook for MCP tool calls

1 participant