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:
| Type | Description |
|---|---|
Engine | Manages MCP server connection, request IDs, and mutex |
RiskAnalyzer | Assesses risk based on dangerous keyword patterns |
2. Locker (internal/locker/)
Purpose: Creates immutable lockfiles with cryptographic hashes for drift detection.
Key Types:
| Type | Description |
|---|---|
Manager | Handles lockfile CRUD operations |
DriftType | Enum: 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:
| Function | Description |
|---|---|
ComputeDiff | Loads lockfile, performs fresh scan, computes patches |
Translate | Converts JSON patches to human sentences |
4. Policy (internal/policy/engine.go)
Purpose: Evaluates security rules written in CEL against scan reports.
Key Functions:
| Function | Description |
|---|---|
Evaluate | Runs all rules against ScanReport |
CompileAndValidate | Validates 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.