Skip to main content

Verification, Validation & Uncertainty Quantification MCP for marketplace contracts

Project description

VVUQ-MCP: Verification, Validation & Uncertainty Quantification

MCP Server for automated marketplace contract verification

Overview

VVUQ-MCP is a FastMCP server that acts as an automated judge for marketplace contracts. It verifies formal proofs (starting with Lean4), validates contract fulfillment, and executes cryptographic payments.

Features

  • Tiered Dependency Management - Dynamic workspace provisioning with deterministic caching
  • Server-Side Context Injection - Secure injection of versioned assumption contexts (e.g. Physics:v1.0.0)
  • Lean4 Proof Verification - Compile and verify proofs against contract claims
  • Cryptographic Payments - Secure payment settlement with audit trail
  • Neo4j Integration - Contract storage and query
  • MCP Protocol - Standard interface for AI agents

Quick Start

# Setup
python -m venv .venv
source .venv/bin/activate
pip install vvuq-mcp
# Or for development: pip install -e ".[dev]"

# Run MCP server
# Automatically manages its own workspaces directory
python -m vvuq_mcp.server

# Run tests
pytest tests/ -v

Architecture

See VVUQ_MCP_ARCHITECTURE.md (in mcp-marketplace repo) for complete architecture documentation.

Core components:

  • server.py - FastMCP server with 4 core tools
  • workspaces/ - Tiered Dependency Manager (Refactored v2.0)
    • path_generator.py - Deterministic SHA256 path generation
    • provisioner.py - Dynamic lakefile generation and mathlib downloading
  • verifiers/lean4.py - Lean4 compilation and verification with context injection
  • payments/ledger.py - Simple cryptographic ledger
  • storage/neo4j_client.py - Async Neo4j integration

MCP Tools

verify_lean4_proof

Verify a Lean4 proof against a contract claim.

Input:

{
  "contract_id": "lean4-uuid-123",
  "claim_id": 1,
  "proof_code": "theorem my_theorem : ... := by ...",
  "dependencies": ["Mathlib.Data.Nat.Basic"],
  "mathlib_version": "v4.15.0",           # Optional: Pin specific version
  "assumption_contexts": ["Physics:v1.0.0"] # Optional: Inject specific context
}

Output:

{
  "verdict": "ACCEPTED",  # or REJECTED/ERROR
  "matches_claim": true,
  "payment_executed": {...},
  "verification_time_ms": 4823
}

submit_contract_proof

Submit a proof file for verification (convenience wrapper).

get_contract_requirements

Retrieve contract requirements for a specific contract.

query_verification_history

Query past verification attempts and outcomes.

Development

TDD Workflow

# 1. Write test FIRST (RED)
pytest tests/unit/test_lean4_verifier.py::test_new_feature -v

# 2. Implement (GREEN)
# Edit src/vvuq_mcp/verifiers/lean4.py

# 3. Verify
pytest tests/unit/test_lean4_verifier.py::test_new_feature -v

# 4. Refactor

Running Tests

# All tests
pytest tests/ -v

# Unit tests only (fast)
pytest tests/unit/ -v

# Integration tests (require Neo4j)
pytest tests/integration/ -v

# E2E Tests (Real filesystem/network)
pytest tests/e2e/ -v --slow

# With coverage
pytest tests/ -v --cov=vvuq_mcp --cov-report=term-missing

Configuration

Create .env file:

NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_password

# Optional customizations
# WORKSPACES_DIR=./workspaces (default: ~/.vvuq/workspaces)
# MAX_CONCURRENT_PROVISIONS=3
# MAX_TOTAL_WORKSPACES=50

PAYMENT_SECRET_KEY=<generate with: python -c "import secrets; print(secrets.token_hex(32))">
PAYMENT_LEDGER_MODE=simple

Security (Hardened v2.0)

  • Command Injection Prevention - Strict regex validation (^[a-f0-9]{40}$ or ^v\d+...) for version inputs.
  • Path Traversal Prevention - pathlib sandboxing and regex validation for context injection.
  • Sandboxed Execution - Lean4 compilation in isolated, hashed directories.
  • Resource Limits - Semaphore-based concurrency limits (MAX_CONCURRENT_PROVISIONS).
  • Integrity Checks - Lockfiles (.vvuq_contexts) verify workspace consistency.

Status

Phase: Production (v2.0.0) Progress: 100% (Tiered Dependency Management & Security Hardening Complete) Next: Continuous Maintenance

License

MIT

Contact

Dirk Englund - englund@mit.edu

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vvuq_mcp-2.0.1.tar.gz (50.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vvuq_mcp-2.0.1-py3-none-any.whl (56.8 kB view details)

Uploaded Python 3

File details

Details for the file vvuq_mcp-2.0.1.tar.gz.

File metadata

  • Download URL: vvuq_mcp-2.0.1.tar.gz
  • Upload date:
  • Size: 50.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for vvuq_mcp-2.0.1.tar.gz
Algorithm Hash digest
SHA256 cf6498b8a566c346321549211ffa1f080dac2dfdd0354369fc7c56818e705f0f
MD5 e359fb4126b2e8ed17eb80ea3b08ec40
BLAKE2b-256 f60dcb6b84fce2187ef33074f3964974fe0c5b625a5b7b4ffb7ad2de8762d0c5

See more details on using hashes here.

File details

Details for the file vvuq_mcp-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: vvuq_mcp-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 56.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for vvuq_mcp-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68760f9dfd0159a63b236f34af70bc46258eb30a1527c6c1627b485b2ce37f69
MD5 9e69884892caa364403b80853875a406
BLAKE2b-256 edf89125595e7ebb8293bfcf5cd94ec024d89e06abe9bcaf9eaaf524015a281d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page