Architecture

Internal modules and data flow


MCPTrust is a Go CLI for securing AI-agent tool supply chains. It verifies Model Context Protocol (MCP) servers before agents use them.

High-Level Data Flow

Module Reference

1. Scanner (internal/scanner/engine.go)

Purpose: Interrogates MCP servers via stdio JSON-RPC to enumerate capabilities.

Key Types:

TypeDescription
EngineManages MCP server connection, request IDs, and mutex
RiskAnalyzerAssesses risk based on dangerous keyword patterns

2. Locker (internal/locker/)

Purpose: Creates immutable lockfiles with cryptographic hashes for drift detection.

Key Types:

TypeDescription
ManagerHandles lockfile CRUD operations
DriftTypeEnum: tool_added, tool_removed, description_changed, schema_changed, risk_level_changed

3. Differ (internal/differ/)

Purpose: Detects and translates changes between locked and live server state.

Key Functions:

FunctionDescription
ComputeDiffLoads lockfile, performs fresh scan, computes patches
TranslateConverts JSON patches to human sentences

4. Policy (internal/policy/engine.go)

Purpose: Evaluates security rules written in CEL against scan reports.

Key Functions:

FunctionDescription
EvaluateRuns all rules against ScanReport
CompileAndValidateValidates all CEL expressions

5. Crypto (internal/crypto/signer.go)

Purpose: Ed25519 key generation, signing, and verification.

6. Bundler (internal/bundler/writer.go)

Purpose: Packages security artifacts into distributable ZIP archive.

Inputs: mcp-lock.json, mcp-lock.json.sig, public.key (optional), policy.yaml (optional). Outputs: Deterministic .zip bundle.