veilgate 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. veilgate-0.1.1/.env.example +23 -0
  2. veilgate-0.1.1/.github/workflows/ci.yml +33 -0
  3. veilgate-0.1.1/.github/workflows/publish.yml +139 -0
  4. veilgate-0.1.1/.gitignore +60 -0
  5. veilgate-0.1.1/.python-version +1 -0
  6. veilgate-0.1.1/LICENSE +21 -0
  7. veilgate-0.1.1/PKG-INFO +330 -0
  8. veilgate-0.1.1/README.md +275 -0
  9. veilgate-0.1.1/docs/assets/dashboard-approval-preview.png +0 -0
  10. veilgate-0.1.1/docs/assets/logo.svg +50 -0
  11. veilgate-0.1.1/policies/examples/invoice_recon.yaml +38 -0
  12. veilgate-0.1.1/policies/examples/minimal_dev.yaml +13 -0
  13. veilgate-0.1.1/policies/recommended.yaml +31 -0
  14. veilgate-0.1.1/policies/strict.yaml +35 -0
  15. veilgate-0.1.1/pyproject.toml +106 -0
  16. veilgate-0.1.1/src/veilgate/__init__.py +3 -0
  17. veilgate-0.1.1/src/veilgate/cli.py +545 -0
  18. veilgate-0.1.1/src/veilgate/config/constants.py +86 -0
  19. veilgate-0.1.1/src/veilgate/config/policy_loader.py +332 -0
  20. veilgate-0.1.1/src/veilgate/config/policy_models.py +432 -0
  21. veilgate-0.1.1/src/veilgate/config/settings.py +90 -0
  22. veilgate-0.1.1/src/veilgate/dashboard/api.py +216 -0
  23. veilgate-0.1.1/src/veilgate/dashboard/app.py +46 -0
  24. veilgate-0.1.1/src/veilgate/dashboard/models.py +65 -0
  25. veilgate-0.1.1/src/veilgate/dashboard/static/styles.css +314 -0
  26. veilgate-0.1.1/src/veilgate/dashboard/templates/index.html +208 -0
  27. veilgate-0.1.1/src/veilgate/engines/operators/__init__.py +61 -0
  28. veilgate-0.1.1/src/veilgate/engines/operators/base.py +14 -0
  29. veilgate-0.1.1/src/veilgate/engines/operators/checksums.py +91 -0
  30. veilgate-0.1.1/src/veilgate/engines/operators/text.py +76 -0
  31. veilgate-0.1.1/src/veilgate/exceptions/__init__.py +41 -0
  32. veilgate-0.1.1/src/veilgate/exceptions/types.py +267 -0
  33. veilgate-0.1.1/src/veilgate/gateway.py +130 -0
  34. veilgate-0.1.1/src/veilgate/integrations/__init__.py +1 -0
  35. veilgate-0.1.1/src/veilgate/middleware/__init__.py +15 -0
  36. veilgate-0.1.1/src/veilgate/middleware/context_middleware.py +95 -0
  37. veilgate-0.1.1/src/veilgate/middleware/context_mw.py +26 -0
  38. veilgate-0.1.1/src/veilgate/middleware/discovery_mw.py +35 -0
  39. veilgate-0.1.1/src/veilgate/middleware/firewall_call_mw.py +65 -0
  40. veilgate-0.1.1/src/veilgate/middleware/init_mw.py +11 -0
  41. veilgate-0.1.1/src/veilgate/packs/arg-guards.yaml +31 -0
  42. veilgate-0.1.1/src/veilgate/packs/bloat-http.yaml +33 -0
  43. veilgate-0.1.1/src/veilgate/packs/core-verbs.yaml +35 -0
  44. veilgate-0.1.1/src/veilgate/packs/pii-global.yaml +88 -0
  45. veilgate-0.1.1/src/veilgate/packs/pii-india.yaml +45 -0
  46. veilgate-0.1.1/src/veilgate/packs/sensitive-keys.yaml +64 -0
  47. veilgate-0.1.1/src/veilgate/packs/server-profiles.yaml +24 -0
  48. veilgate-0.1.1/src/veilgate/pipeline.py +323 -0
  49. veilgate-0.1.1/src/veilgate/repositories/__init__.py +35 -0
  50. veilgate-0.1.1/src/veilgate/repositories/approval_repo.py +82 -0
  51. veilgate-0.1.1/src/veilgate/repositories/audit_repo.py +194 -0
  52. veilgate-0.1.1/src/veilgate/repositories/catalog_repo.py +174 -0
  53. veilgate-0.1.1/src/veilgate/repositories/db.py +55 -0
  54. veilgate-0.1.1/src/veilgate/repositories/migrations/0001_init.sql +118 -0
  55. veilgate-0.1.1/src/veilgate/repositories/models.py +123 -0
  56. veilgate-0.1.1/src/veilgate/repositories/session_repo.py +82 -0
  57. veilgate-0.1.1/src/veilgate/repositories/stash_repo.py +87 -0
  58. veilgate-0.1.1/src/veilgate/repositories/vault_repo.py +158 -0
  59. veilgate-0.1.1/src/veilgate/security/crypto.py +173 -0
  60. veilgate-0.1.1/src/veilgate/services/acl_service.py +152 -0
  61. veilgate-0.1.1/src/veilgate/services/approval_service.py +236 -0
  62. veilgate-0.1.1/src/veilgate/services/audit_service.py +50 -0
  63. veilgate-0.1.1/src/veilgate/services/catalog_service.py +193 -0
  64. veilgate-0.1.1/src/veilgate/services/compaction_service.py +111 -0
  65. veilgate-0.1.1/src/veilgate/services/diet_service.py +111 -0
  66. veilgate-0.1.1/src/veilgate/services/explain_service.py +150 -0
  67. veilgate-0.1.1/src/veilgate/services/injection_service.py +73 -0
  68. veilgate-0.1.1/src/veilgate/services/minimizer_service.py +611 -0
  69. veilgate-0.1.1/src/veilgate/services/models.py +178 -0
  70. veilgate-0.1.1/src/veilgate/services/taint_service.py +421 -0
  71. veilgate-0.1.1/src/veilgate/services/tokenizer_service.py +80 -0
  72. veilgate-0.1.1/src/veilgate/services/upstream_registry.py +209 -0
  73. veilgate-0.1.1/src/veilgate/utils/ids.py +30 -0
  74. veilgate-0.1.1/src/veilgate/utils/json_paths.py +115 -0
  75. veilgate-0.1.1/src/veilgate/utils/logging_utils.py +50 -0
  76. veilgate-0.1.1/src/veilgate/utils/text_scan.py +104 -0
  77. veilgate-0.1.1/src/veilgate/utils/token_count.py +26 -0
  78. veilgate-0.1.1/tests/benchmarks/test_pipeline_perf.py +154 -0
  79. veilgate-0.1.1/tests/e2e/test_stdio_purity.py +181 -0
  80. veilgate-0.1.1/tests/fixtures/servers/fx_crm.py +35 -0
  81. veilgate-0.1.1/tests/fixtures/servers/fx_hostile.py +38 -0
  82. veilgate-0.1.1/tests/fixtures/servers/fx_invoice_db.py +68 -0
  83. veilgate-0.1.1/tests/fixtures/servers/fx_mailer.py +35 -0
  84. veilgate-0.1.1/tests/golden/fetch_server.json +44 -0
  85. veilgate-0.1.1/tests/golden/filesystem_server.json +61 -0
  86. veilgate-0.1.1/tests/golden/invoicedb_server.json +83 -0
  87. veilgate-0.1.1/tests/golden/time_server.json +53 -0
  88. veilgate-0.1.1/tests/integration/test_gateway_pipeline.py +210 -0
  89. veilgate-0.1.1/tests/integration/test_golden_fixtures.py +157 -0
  90. veilgate-0.1.1/tests/integration/test_real_mcp_transports.py +594 -0
  91. veilgate-0.1.1/tests/security/test_attack_catalog_a1_a16.py +635 -0
  92. veilgate-0.1.1/tests/spikes/test_fastmcp_middleware_spike.py +139 -0
  93. veilgate-0.1.1/tests/unit/test_cli.py +109 -0
  94. veilgate-0.1.1/tests/unit/test_constants.py +60 -0
  95. veilgate-0.1.1/tests/unit/test_dashboard.py +93 -0
  96. veilgate-0.1.1/tests/unit/test_db_and_crypto.py +126 -0
  97. veilgate-0.1.1/tests/unit/test_egress_approval.py +123 -0
  98. veilgate-0.1.1/tests/unit/test_exceptions.py +92 -0
  99. veilgate-0.1.1/tests/unit/test_operators.py +72 -0
  100. veilgate-0.1.1/tests/unit/test_policy_loader.py +92 -0
  101. veilgate-0.1.1/tests/unit/test_policy_models.py +76 -0
  102. veilgate-0.1.1/tests/unit/test_property_fuzzing.py +84 -0
  103. veilgate-0.1.1/tests/unit/test_repositories.py +208 -0
  104. veilgate-0.1.1/tests/unit/test_settings.py +26 -0
  105. veilgate-0.1.1/uv.lock +3694 -0
@@ -0,0 +1,23 @@
1
+ # Veilgate Environment Configuration Template
2
+ # Copy to .env for local runtime overrides. NEVER commit actual .env files containing secrets.
3
+
4
+ # Local Storage (SQLite WAL mode)
5
+ VEILGATE_DB_PATH=./veilgate.db
6
+
7
+ # Logging (DEBUG | INFO | WARNING | ERROR)
8
+ VEILGATE_LOG_LEVEL=INFO
9
+
10
+ # Cryptography (3-Tier Auto-Provisioning: if empty, auto-stored in OS native keyring)
11
+ VEILGATE_MASTER_KEY=
12
+
13
+ # Declarative Policy File Path
14
+ VEILGATE_POLICY_PATH=./policy.yaml
15
+
16
+ # Dashboard Port (FastAPI)
17
+ VEILGATE_DASHBOARD_PORT=7878
18
+
19
+ # Streamable HTTP Gateway Port
20
+ VEILGATE_HTTP_PORT=8765
21
+
22
+ # Remote MCP Testing Upstream Auth (Optional)
23
+ GITHUB_PERSONAL_ACCESS_TOKEN=
@@ -0,0 +1,33 @@
1
+ name: CI Quality Gate
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ jobs:
10
+ test:
11
+ name: Unit & Security Tests
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.11", "3.12"]
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v5
23
+ with:
24
+ version: "latest"
25
+
26
+ - name: Set up Python ${{ matrix.python-version }}
27
+ run: uv python install ${{ matrix.python-version }}
28
+
29
+ - name: Install dependencies
30
+ run: uv sync --extra dev --extra dashboard
31
+
32
+ - name: Run unit test suite
33
+ run: uv run pytest tests/unit -q
@@ -0,0 +1,139 @@
1
+ name: Publish to PyPI / TestPyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ target:
7
+ description: 'Publish destination registry'
8
+ required: true
9
+ default: 'testpypi'
10
+ type: choice
11
+ options:
12
+ - testpypi
13
+ - pypi
14
+ push:
15
+ tags:
16
+ - 'v*' # Official release to PyPI (e.g., v0.1.0)
17
+ - 'test-v*' # Test release to TestPyPI (e.g., test-v0.1.0)
18
+
19
+ jobs:
20
+ test:
21
+ name: Run Quality Gate & Tests
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ python-version: ["3.11", "3.12"]
26
+
27
+ steps:
28
+ - name: Checkout repository
29
+ uses: actions/checkout@v4
30
+
31
+ - name: Install uv
32
+ uses: astral-sh/setup-uv@v5
33
+ with:
34
+ version: "latest"
35
+
36
+ - name: Set up Python ${{ matrix.python-version }}
37
+ run: uv python install ${{ matrix.python-version }}
38
+
39
+ - name: Install dependencies
40
+ run: uv sync --extra dev --extra dashboard
41
+
42
+ - name: Run unit tests
43
+ run: uv run pytest tests/unit -q
44
+
45
+ build:
46
+ name: Build Distribution Packages
47
+ needs: test
48
+ runs-on: ubuntu-latest
49
+ steps:
50
+ - name: Checkout repository
51
+ uses: actions/checkout@v4
52
+
53
+ - name: Install uv
54
+ uses: astral-sh/setup-uv@v5
55
+ with:
56
+ version: "latest"
57
+
58
+ - name: Set up Python
59
+ run: uv python install 3.11
60
+
61
+ - name: Build sdist and wheel
62
+ run: uv build
63
+
64
+ - name: Verify package distributions with twine
65
+ run: uvx twine check dist/*
66
+
67
+ - name: Store distribution artifacts
68
+ uses: actions/upload-artifact@v4
69
+ with:
70
+ name: python-package-distributions
71
+ path: dist/
72
+ retention-days: 5
73
+
74
+ publish-to-testpypi:
75
+ name: Publish to TestPyPI
76
+ needs: build
77
+ if: |
78
+ (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi') ||
79
+ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/test-v'))
80
+ runs-on: ubuntu-latest
81
+ environment:
82
+ name: testpypi
83
+ url: https://test.pypi.org/p/veilgate
84
+ permissions:
85
+ id-token: write
86
+ env:
87
+ HAS_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN != '' }}
88
+
89
+ steps:
90
+ - name: Download distribution artifacts
91
+ uses: actions/download-artifact@v4
92
+ with:
93
+ name: python-package-distributions
94
+ path: dist/
95
+
96
+ - name: Publish to TestPyPI (Trusted Publishing / OIDC)
97
+ if: env.HAS_TOKEN == 'false'
98
+ uses: pypa/gh-action-pypi-publish@release/v1
99
+ with:
100
+ repository-url: https://test.pypi.org/legacy/
101
+
102
+ - name: Publish to TestPyPI (API Token)
103
+ if: env.HAS_TOKEN == 'true'
104
+ uses: pypa/gh-action-pypi-publish@release/v1
105
+ with:
106
+ repository-url: https://test.pypi.org/legacy/
107
+ password: ${{ secrets.TEST_PYPI_API_TOKEN }}
108
+
109
+ publish-to-pypi:
110
+ name: Publish to Official PyPI
111
+ needs: build
112
+ if: |
113
+ (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'pypi') ||
114
+ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !startsWith(github.ref, 'refs/tags/test-v'))
115
+ runs-on: ubuntu-latest
116
+ environment:
117
+ name: pypi
118
+ url: https://pypi.org/p/veilgate
119
+ permissions:
120
+ id-token: write
121
+ env:
122
+ HAS_TOKEN: ${{ secrets.PYPI_API_TOKEN != '' }}
123
+
124
+ steps:
125
+ - name: Download distribution artifacts
126
+ uses: actions/download-artifact@v4
127
+ with:
128
+ name: python-package-distributions
129
+ path: dist/
130
+
131
+ - name: Publish to PyPI (Trusted Publishing / OIDC)
132
+ if: env.HAS_TOKEN == 'false'
133
+ uses: pypa/gh-action-pypi-publish@release/v1
134
+
135
+ - name: Publish to PyPI (API Token)
136
+ if: env.HAS_TOKEN == 'true'
137
+ uses: pypa/gh-action-pypi-publish@release/v1
138
+ with:
139
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,60 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+
24
+ # Virtual environments
25
+ .venv/
26
+ env/
27
+ venv/
28
+ ENV/
29
+
30
+ # Testing & Coverage
31
+ .pytest_cache/
32
+ .coverage
33
+ htmlcov/
34
+ .hypothesis/
35
+
36
+ # Type checking & Linters
37
+ .mypy_cache/
38
+ .ruff_cache/
39
+
40
+ # Veilgate Local Database & Sensitive Key Material (NEVER commit secrets or DBs)
41
+ *.db
42
+ *.db-wal
43
+ *.db-shm
44
+ *.key
45
+ *.bak
46
+ *.bak.json
47
+ .env
48
+ .env.local
49
+
50
+ # IDEs
51
+ .idea/
52
+ .vscode/
53
+ *.swp
54
+ *.swo
55
+
56
+ # OS
57
+ Thumbs.db
58
+ ehthumbs.db
59
+ Desktop.ini
60
+ .DS_Store
@@ -0,0 +1 @@
1
+ 3.14
veilgate-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Om Harsh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,330 @@
1
+ Metadata-Version: 2.5
2
+ Name: veilgate
3
+ Version: 0.1.1
4
+ Summary: Local-First Zero-Trust MCP Privacy Firewall & Context-Diet Gateway
5
+ Author: Veilgate Authors
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: ai-agents,firewall,llm,mcp,model-context-protocol,privacy,security
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Security
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: aiosqlite>=0.21
21
+ Requires-Dist: cryptography>=44
22
+ Requires-Dist: fastapi>=0.115
23
+ Requires-Dist: fastmcp<5,>=4.1.1
24
+ Requires-Dist: jinja2>=3.1
25
+ Requires-Dist: keyring>=25
26
+ Requires-Dist: numpy>=2.0
27
+ Requires-Dist: phonenumbers>=9.0
28
+ Requires-Dist: pydantic-settings>=2.10
29
+ Requires-Dist: pydantic<3,>=2.11
30
+ Requires-Dist: python-ulid>=3.0
31
+ Requires-Dist: pyyaml>=6.0
32
+ Requires-Dist: rank-bm25>=0.2.2
33
+ Requires-Dist: rich>=13.0
34
+ Requires-Dist: tiktoken>=0.9
35
+ Requires-Dist: typer>=0.15
36
+ Requires-Dist: uvicorn>=0.32
37
+ Provides-Extra: dashboard
38
+ Requires-Dist: fastapi>=0.115; extra == 'dashboard'
39
+ Requires-Dist: jinja2>=3.1; extra == 'dashboard'
40
+ Requires-Dist: uvicorn>=0.32; extra == 'dashboard'
41
+ Provides-Extra: dev
42
+ Requires-Dist: anyio>=4; extra == 'dev'
43
+ Requires-Dist: faker>=30; extra == 'dev'
44
+ Requires-Dist: httpx>=0.28.1; extra == 'dev'
45
+ Requires-Dist: hypothesis>=6; extra == 'dev'
46
+ Requires-Dist: mypy; extra == 'dev'
47
+ Requires-Dist: pyinstrument; extra == 'dev'
48
+ Requires-Dist: pytest-benchmark; extra == 'dev'
49
+ Requires-Dist: pytest-cov; extra == 'dev'
50
+ Requires-Dist: pytest>=8; extra == 'dev'
51
+ Requires-Dist: ruff; extra == 'dev'
52
+ Provides-Extra: presidio
53
+ Requires-Dist: presidio-analyzer>=2.2.36; extra == 'presidio'
54
+ Description-Content-Type: text/markdown
55
+
56
+ <p align="center">
57
+ <a href="https://github.com/OmH3/Veilgate" target="blank"><img src="https://raw.githubusercontent.com/OmH3/Veilgate/main/docs/assets/logo.svg" width="120" alt="Veilgate Logo" /></a>
58
+ </p>
59
+
60
+ <p align="center">A local-first zero-trust <a href="https://modelcontextprotocol.io" target="_blank">Model Context Protocol (MCP)</a> privacy firewall & context-diet gateway.</p>
61
+
62
+ <p align="center">
63
+ <a href="https://github.com/OmH3/Veilgate/releases" target="_blank"><img src="https://img.shields.io/badge/version-0.1.1-blue.svg" alt="Version" /></a>
64
+ <a href="https://github.com/OmH3/Veilgate/blob/main/LICENSE" target="_blank"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" /></a>
65
+ <a href="https://www.python.org/" target="_blank"><img src="https://img.shields.io/badge/python-%3E%3D3.11-blue.svg" alt="Python Versions" /></a>
66
+ <a href="https://github.com/OmH3/Veilgate/actions" target="_blank"><img src="https://img.shields.io/badge/build-passing-brightgreen.svg" alt="Build Status" /></a>
67
+ <a href="https://github.com/OmH3/Veilgate" target="_blank"><img src="https://img.shields.io/badge/coverage-96%25-brightgreen.svg" alt="Coverage" /></a>
68
+ <a href="https://discord.gg/veilgate" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
69
+ </p>
70
+
71
+ ---
72
+
73
+ ## Description
74
+
75
+ **Veilgate** is an enterprise-grade, local-first proxy and security gateway that sits transparently between AI client hosts (Claude Desktop, Cursor, Antigravity, LangGraph) and upstream Model Context Protocol (MCP) tool servers.
76
+
77
+ As agentic AI workflows adopt dozens of autonomous MCP tools, developers face critical security and efficiency risks:
78
+ 1. **Unchecked Data Exfiltration:** Upstream tools can leak corporate databases, PII, and financial accounts directly into public LLM context windows.
79
+ 2. **Confused Deputy Attacks:** Tainted prompt data can trick LLMs into re-routing sensitive secrets into unmonitored external network sinks (email, webhooks, cURL).
80
+ 3. **Rug-Pull Tool Mutation:** Malicious or compromised servers can stealthily alter tool schemas and descriptions after initial approval.
81
+ 4. **Context Window Token Bloat:** Unbounded tool definitions consume 40–70% of prompt token limits before reasoning even begins.
82
+
83
+ Veilgate eliminates these risks with a **zero-trust, fail-closed security architecture**:
84
+ - **Lossless Context Diet:** Dynamically prunes bloated schemas and applies BM25 adaptive ranking to keep prompts lean and fast.
85
+ - **Cryptographic Data Minimization:** Intercepts sensitive PII/secrets, stores them locally in an AES-256-GCM vault, and injects format-preserving synthetic tokens (`<vg:TYPE:ID>`) into LLM prompts.
86
+ - **Taint-Aware Egress Enforcement:** Tracks data origin and halts unauthorized token re-hydration into external sinks.
87
+ - **Interactive Human-in-the-Loop (HITL) Review:** Prompts developers via terminal or the sleek web dashboard with `⚡ Allow Once`, `🛡️ Allow Always`, or `✕ Deny`.
88
+ - **Tamper-Evident SHA-256 Audit Trail:** Cryptographically hash-chains every discovery, call, token transformation, and approval in a local SQLite WAL ledger.
89
+
90
+ ---
91
+
92
+ ## System Architecture
93
+
94
+ ```mermaid
95
+ flowchart TD
96
+ subgraph ClientHost["AI Client Host (Claude Desktop / Cursor / CLI)"]
97
+ LLM["AI Agent / LLM Engine"]
98
+ end
99
+
100
+ subgraph VeilgateGateway["Veilgate Zero-Trust Privacy Firewall"]
101
+ Proxy["FastMCP MITM Proxy Router"]
102
+
103
+ subgraph Pipeline["Firewall Security Pipeline"]
104
+ RugPull["1. Rug-Pull & Fingerprint Guard"]
105
+ Diet["2. Lossless Context-Diet & BM25 Ranker"]
106
+ ACL["3. Zero-Trust ACL & Egress Inspector"]
107
+ HITL["4. Interactive HITL Review Queue"]
108
+ Taint["5. Taint Tracker & Vault Minimizer"]
109
+ end
110
+
111
+ Vault[("Local AES-GCM Vault & Stash")]
112
+ Audit[("Tamper-Evident Audit Ledger (SHA-256)")]
113
+ Policy[("policy.yaml & policy.learned.yaml")]
114
+ end
115
+
116
+ subgraph UpstreamMCP["Upstream MCP Ecosystem"]
117
+ ServerA["Database MCP (invoicedb)"]
118
+ ServerB["Egress MCP (mailer / web)"]
119
+ ServerC["Filesystem / CLI Tools"]
120
+ end
121
+
122
+ LLM <-->|"MCP stdio / SSE"| Proxy
123
+ Proxy --> Pipeline
124
+ Pipeline --> Vault
125
+ Pipeline --> Audit
126
+ Pipeline --> Policy
127
+ HITL <-->|"WebSocket / REST API"| Dashboard["Local Web Dashboard (Port 8765)"]
128
+ Pipeline <-->|"Safe Filtered Calls"| UpstreamMCP
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Repository Layout
134
+
135
+ | Path | Responsibility |
136
+ | :--- | :--- |
137
+ | `src/veilgate/config/` | Declarative Pydantic settings, constants, and layered policy compilers (`policy.yaml`, `policy.learned.yaml`). |
138
+ | `src/veilgate/middleware/` | FastMCP interceptor middlewares for discovery filtering, tool calls, and structured error routing. |
139
+ | `src/veilgate/pipeline.py` | Central `FirewallPipeline` orchestrating ACL, taint tracking, vault minimization, and audit hashing. |
140
+ | `src/veilgate/services/` | Modular domain services: `AclService`, `ApprovalService`, `TaintService`, `MinimizerService`, `DietService`, `CatalogService`. |
141
+ | `src/veilgate/security/` | Cryptographic primitives: AES-256-GCM envelope encryption, OS keyring integration, and blind hashing. |
142
+ | `src/veilgate/repositories/` | Async SQLite repositories for sessions, tool catalog entries, approval states, and immutable audit logs. |
143
+ | `src/veilgate/dashboard/` | Local FastAPI & Jinja2 monitoring dashboard featuring live metrics, interactive HITL approval queue, and audit trail stream. |
144
+ | `src/veilgate/cli.py` | Rich Typer CLI powering `run`, `dashboard`, `init`, `adopt`, `keygen`, and `audit`. |
145
+ | `tests/` | Comprehensive test suite containing unit tests, hypothesis property tests, and the A1–A16 security attack catalog. |
146
+
147
+ ---
148
+
149
+ ## Prerequisites
150
+
151
+ | Requirement | Minimum Version | Description |
152
+ | :--- | :--- | :--- |
153
+ | **Python** | `>= 3.11` | Modern async runtime supporting typed Pydantic models. |
154
+ | **uv** *(Recommended)* | `>= 0.5.0` | Ultra-fast package installer and virtualenv manager. |
155
+ | **SQLite** | `>= 3.35` | Built-in WAL mode database for local-first cryptographic storage. |
156
+
157
+ ### Installing uv
158
+
159
+ ```bash
160
+ # macOS / Linux
161
+ curl -LsSf https://astral.sh/uv/install.sh | sh
162
+
163
+ # Windows (PowerShell)
164
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Project Setup
170
+
171
+ Clone the repository and synchronize dependencies into an isolated virtual environment:
172
+
173
+ ```bash
174
+ # Clone repository
175
+ git clone https://github.com/OmH3/Veilgate.git
176
+ cd veilgate
177
+
178
+ # Install with development and dashboard extras
179
+ uv sync --extra dev --extra dashboard
180
+
181
+ # Alternatively with standard pip
182
+ python -m venv .venv
183
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
184
+ pip install -e ".[dev,dashboard]"
185
+ ```
186
+
187
+ Generate your master cryptographic key:
188
+ ```bash
189
+ uv run veilgate keygen
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Quickstart & CLI Commands
195
+
196
+ ### 1. Initialize a New Policy
197
+ Generate a baseline `policy.yaml` pre-configured with recommended security rules and PII detectors:
198
+ ```bash
199
+ uv run veilgate init
200
+ ```
201
+
202
+ ### 2. Adopt Existing MCP Configurations
203
+ Instantly migrate existing Claude Desktop, Cursor, or Cline MCP configs into Veilgate:
204
+ ```bash
205
+ uv run veilgate adopt --client claude-desktop
206
+ ```
207
+
208
+ ### 3. Run the Veilgate Firewall Proxy
209
+ Start the proxy gateway in foreground mode:
210
+ ```bash
211
+ uv run veilgate run --config policy.yaml
212
+ ```
213
+
214
+ ### 4. Launch the Live Observability Dashboard
215
+ Start the local review and monitoring dashboard:
216
+ ```bash
217
+ uv run veilgate dashboard --config policy.yaml --port 8765
218
+ ```
219
+ Open **`http://localhost:8765`** in your browser.
220
+
221
+ ---
222
+
223
+ ## Interactive Human-in-the-Loop (HITL) Approvals
224
+
225
+ Veilgate treats egress and unallowed tools with zero trust. Whenever an agent attempts to invoke a tool that lacks pre-approved authorization or touches external networks, execution is **automatically paused** and queued for developer review:
226
+
227
+ <p align="center">
228
+ <img src="https://raw.githubusercontent.com/OmH3/Veilgate/main/docs/assets/dashboard-approval-preview.png" width="850" alt="Veilgate Approval Dashboard Preview" />
229
+ </p>
230
+
231
+ ### Decision Matrix
232
+
233
+ | Action | Decision State | Behavior & Security Guarantee |
234
+ | :--- | :--- | :--- |
235
+ | **`⚡ Allow Once`** | `APPROVED` | Permits this single tool call to proceed upstream. Leaves the policy unchanged so future invocations require fresh approval. |
236
+ | **`🛡️ Allow Always`** | `APPROVED_AND_SAVED` | Permits execution **and** permanently appends a new grant rule to `policy.learned.yaml`. Subsequent invocations execute instantly without prompting. |
237
+ | **`✕ Deny`** | `DENIED` | Immediately aborts the invocation with `ApprovalDeniedError`. Zero upstream data is transmitted, and the denial is logged to the audit ledger. |
238
+
239
+ > [!NOTE]
240
+ > All pending requests enforce a configurable fail-closed timeout (default: `120s`). If an approval expires without user intervention, Veilgate automatically denies the call.
241
+
242
+ ---
243
+
244
+ ## Live Web Dashboard & Observability
245
+
246
+ The local-first dashboard (`http://localhost:8765`) gives developers complete visibility into agentic operations:
247
+
248
+ 1. **Minimization Metrics:**
249
+ - **Total Intercepted Calls:** Lifetime count of all MCP tool executions.
250
+ - **Blocked Exfiltrations:** Real-time count of blocked unauthorized calls or taint policy violations.
251
+ - **Tokens Minted:** Number of sensitive values safely anonymized into `<vg:TYPE:ID>`.
252
+ - **Pending Approvals:** Real-time count of calls awaiting human review.
253
+ 2. **Interactive Review Queue:**
254
+ - Visual cards detailing the tool name, session ID, reason code, and sanitized argument preview.
255
+ - Action buttons with real-time feedback.
256
+ 3. **Tamper-Evident Audit Stream:**
257
+ - Live stream of all gateway events chronologically ordered.
258
+ - Cryptographic SHA-256 hashes linking each row to its predecessor (`prev_hash`).
259
+
260
+ ---
261
+
262
+ ## Audit Verification & Security
263
+
264
+ Veilgate maintains an append-only, tamper-evident cryptographic ledger:
265
+
266
+ ```bash
267
+ # Verify integrity of all audit events
268
+ uv run veilgate audit verify
269
+
270
+ # Export audit trail to JSONL for SIEM ingestion
271
+ uv run veilgate audit export --output audit_export.jsonl
272
+
273
+ # Inspect details of a specific tool
274
+ uv run veilgate explain mailer.send_email
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Running Tests
280
+
281
+ Veilgate maintains exhaustive test coverage across unit contracts and real-world attack vectors:
282
+
283
+ ```bash
284
+ # Run all unit tests
285
+ uv run pytest tests/unit -q
286
+
287
+ # Run security attack suite (A1-A16 catalog)
288
+ uv run pytest tests/security -q
289
+
290
+ # Run test suite with coverage report
291
+ uv run pytest --cov=src/veilgate --cov-report=term-missing
292
+ ```
293
+
294
+ ---
295
+
296
+ ## Publishing to PyPI
297
+
298
+ Veilgate uses standard modern PyPA packaging powered by `hatchling` and `twine`:
299
+
300
+ ```bash
301
+ # 1. Clean previous build artifacts
302
+ rm -rf dist build *.egg-info
303
+
304
+ # 2. Build sdist and wheel
305
+ uv run python -m build
306
+
307
+ # 3. Validate packages
308
+ uv run twine check dist/*
309
+
310
+ # 4. Upload to TestPyPI (optional verification)
311
+ uv run twine upload --repository testpypi dist/*
312
+
313
+ # 5. Upload to official PyPI
314
+ uv run twine upload dist/*
315
+ ```
316
+
317
+ ---
318
+
319
+ ## Resources & Support
320
+
321
+ - **Documentation:** [https://github.com/OmH3/Veilgate](https://github.com/OmH3/Veilgate)
322
+ - **Model Context Protocol Specification:** [https://modelcontextprotocol.io](https://modelcontextprotocol.io)
323
+ - **Issues & Bug Reports:** [https://github.com/OmH3/Veilgate/issues](https://github.com/OmH3/Veilgate/issues)
324
+ - **Discussions & Community:** [Discord Community](https://discord.gg/veilgate)
325
+
326
+ ---
327
+
328
+ ## License
329
+
330
+ Veilgate is open-source software licensed under the **[MIT License](LICENSE)**.