Flowise icon indicating copy to clipboard operation
Flowise copied to clipboard

Add pre-execution trust verification hook for MCP tool calls

Open vdineshk opened this issue 6 months ago • 4 comments

Problem

When a Flowise agent calls an MCP tool, there's no framework-level hook to verify the server's trustworthiness before execution. Flowise has had documented MCP-related security vulnerabilities in the past, and currently there's no middleware layer to validate MCP servers before tool dispatch.

This is especially relevant for Flowise deployments where users configure MCP servers from untrusted sources.

Proposal

Add a configurable middleware/hook point that runs before any MCP tool execution:

// Example: pluggable trust verification
const flow = new Flowise({
  mcpTrustVerifier: {
    async verify(serverUri, toolName, params) {
      // User brings their own verification logic
      const result = await myTrustCheck(serverUri);
      return { allowed: result.score > 0.5, reason: result.details };
    }
  }
});

The hook should:

  1. Run before any MCP tool call is dispatched
  2. Receive the server URI, tool name, and parameters
  3. Return allow/deny/warn with optional metadata
  4. Be opt-in with zero overhead when not configured

Benefits

  • Framework-agnostic: Users choose their own verification backend (local policy, external API, OWASP-aligned checks)
  • Opt-in: Doesn't break existing workflows
  • Extensible: Works with any trust scoring service or local policy engine
  • Security: Addresses OWASP MCP Top 10 risks around unverified server trust (MCP08)

References

vdineshk avatar May 26 '26 02:05 vdineshk

pre-execution trust verification + post-execution signed receipts give full coverage.

trust verification says "this server is safe to call." the receipt proves "this is what the server actually did." if the server passes trust but returns compromised data, the receipt chain makes it auditable.

we built this. 4 lines to integrate. cross-validated across 5 JCS implementations.

github.com/arian-gogani/nobulex

arian-gogani avatar May 28 '26 22:05 arian-gogani

I did a quick public-code pass on the MCP path, and this looks like it could be made testable without needing a large design upfront.

Two concrete surfaces I would consider:

  • packages/server/src/services/custom-mcp-servers/index.ts: authorizeCustomMcpServer() already builds serverParams, creates MCPToolkit, initializes, stores discovered tools, and has focused tests in index.test.ts. This looks like a good place to test registration/discovery trust decisions.
  • packages/components/nodes/tools/MCP/core.ts: MCPTool() is the actual dispatch point that creates a fresh client and calls client.request({ method: 'tools/call', ... }). If the goal is pre-execution trust verification, this is the place where a deny/warn/allow decision should happen before tools/call, not only during initial authorization.

A small acceptance checklist that would make the hook safer:

  1. No verifier configured means no behavior change.
  2. A deny decision prevents tools/call and still closes the client.
  3. The verifier receives redacted/contextual fields only: transport type, server URL/origin or server id, tool name, and arguments summary/shape rather than raw secrets.
  4. Cached tool discovery does not bypass per-call verification; the cache can avoid re-listing tools, but each execution should still pass through the hook.
  5. Tests cover both discovery-time behavior around authorizeCustomMcpServer() and execution-time denial in MCPTool().

No private access or credentials needed for this. Happy to help with a small test-first PR if maintainers want that direction. No worries if not useful.

bmtriet avatar Jun 14 '26 13:06 bmtriet

MCP tool trust verification needs to happen at the transport layer, not the application layer. Before the agent sees any tool schema, the framework should validate the MCP server's identity and capabilities against an allowlist. We handle this by requiring each MCP server to pass a health check endpoint and match a configured tool allowlist before any tool calls are dispatched. Unknown servers or servers returning unexpected tool schemas get rejected before the agent can invoke them. The verification step adds negligible latency (<50ms) but prevents an entire class of attacks where a malicious MCP server exposes tools designed to exfiltrate data or execute unauthorized operations. Production deployment with MCP security: https://github.com/dakera-ai/dakera-deploy/blob/main/docker/docker-compose.yml

ferhimedamine avatar Jun 15 '26 21:06 ferhimedamine

following up since this thread has been active — a few things worth connecting.

@bmtriet's two integration surfaces are right. the authorizeCustomMcpServer() path covers discovery-time trust decisions; MCPTool() is where per-call execution-time verification should happen. the key property that distinguishes these: discovery-time authorization is cached (the server is known-good) but execution-time verification is per-call (the specific tool call stays within authorized scope).

the receipt layer sits at the MCPTool() boundary — after the tool executes, the receipt proves exactly what was called with what parameters, independently verifiable by a party who wasn't running Flowise. action_ref = SHA-256(JCS({agent_id, action_type, scope, timestamp_ms})) is the content-derived identifier that ties the authorized scope to the executed action.

for the Flowise-specific integration: the action_type maps to the MCP tool name and the scope maps to the server origin + tool schema hash — so two calls to the same tool with the same inputs produce the same action_ref, enabling idempotency checking alongside audit. pip install nobulex for the receipt primitive; the field set is in agentrust-io/integrations#6 (merged this week) as a concrete reference.

arian-gogani avatar Jun 23 '26 16:06 arian-gogani