jevguard-mcp 1.0.0__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.
- jevguard_mcp-1.0.0/LICENSE +21 -0
- jevguard_mcp-1.0.0/PKG-INFO +230 -0
- jevguard_mcp-1.0.0/README.md +208 -0
- jevguard_mcp-1.0.0/jevguard_mcp/__init__.py +29 -0
- jevguard_mcp-1.0.0/jevguard_mcp/__main__.py +8 -0
- jevguard_mcp-1.0.0/jevguard_mcp/server.py +385 -0
- jevguard_mcp-1.0.0/jevguard_mcp/tools.py +2116 -0
- jevguard_mcp-1.0.0/jevguard_mcp.egg-info/PKG-INFO +230 -0
- jevguard_mcp-1.0.0/jevguard_mcp.egg-info/SOURCES.txt +12 -0
- jevguard_mcp-1.0.0/jevguard_mcp.egg-info/dependency_links.txt +1 -0
- jevguard_mcp-1.0.0/jevguard_mcp.egg-info/entry_points.txt +2 -0
- jevguard_mcp-1.0.0/jevguard_mcp.egg-info/top_level.txt +1 -0
- jevguard_mcp-1.0.0/pyproject.toml +43 -0
- jevguard_mcp-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Seb4Ez
|
|
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,230 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jevguard-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Model Context Protocol (MCP) server for JevGuard deterministic evaluation runtime.
|
|
5
|
+
Author: Seb4Ez
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: mcp,model-context-protocol,jevguard,typesafe,deterministic,evaluation,json-rpc
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# JevGuard MCP Server
|
|
24
|
+
|
|
25
|
+
Official Model Context Protocol (MCP) server for JevGuard, providing a deterministic local caching, state sanitization, and guardrail layer for TypeSafe AI's System One decision model.
|
|
26
|
+
|
|
27
|
+
This package exposes core JevGuard primitives through JSON-RPC 2.0 over standard input/output (stdio), adhering to the MCP 2024-11-05 specification.
|
|
28
|
+
|
|
29
|
+
## Architectural Principles
|
|
30
|
+
|
|
31
|
+
1. Zero External Dependencies: Implemented strictly with the Python standard library (`sys`, `json`, `sqlite3`, `hashlib`, `urllib`).
|
|
32
|
+
2. Protocol Fidelity: Full compliance with the MCP 2024-11-05 standard, supporting initialize handshakes, ping, tool discovery, and tool execution.
|
|
33
|
+
3. Deterministic Local Layer: Canonical state sanitization, neutral escape injection, probability dispersion analysis, and SHA-256 fingerprint caching in SQLite.
|
|
34
|
+
4. Process Isolation: Runs as an independent stdio subprocess compatible with Claude Desktop, Cursor IDE, LibreChat, and custom MCP clients.
|
|
35
|
+
|
|
36
|
+
## Live Verification Benchmark (5 Direct Calls vs 5 JevGuard MCP Calls)
|
|
37
|
+
|
|
38
|
+
A live comparison was conducted directly against the official TypeSafe AI endpoint (`https://api.typesafe.ai/v1/systemone`, model `jev-latest`) comparing 5 direct API calls against 5 JevGuard MCP tool calls from a development workstation.
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
### Key Empirical Observations
|
|
43
|
+
|
|
44
|
+
1. Local Cache Retrieval (0.099 ms): Repeated queries containing dynamic timestamps and trace IDs are intercepted locally. Volatile key masking matches the canonical SHA-256 fingerprint, avoiding WAN network roundtrips (~740 ms) and billing 0 tokens on cache hits.
|
|
45
|
+
2. Closed-World Trap Mitigation: In Scenario 3 (an off-topic inquiry about corporate tax offices in Zurich), the unguided model forced a classification (`credit_card_chargeback`). JevGuard MCP injected `UNRESOLVED_OR_OTHER`, routing the off-topic input to the neutral escape option.
|
|
46
|
+
3. Ambiguity Calibration: In Scenario 1, boundary uncertainty on `is_outage` (`noul=0.49`, distance 0.01 to threshold) and flat distribution on `severity` (0.08 gap) were flagged as `AMBIGUOUS_STATE` using default operational heuristics.
|
|
47
|
+
4. Standard Library Overhead: Local middleware execution latency remained below 0.3 ms for cold requests and 0.099 ms for warm cache lookups.
|
|
48
|
+
|
|
49
|
+
## Available Tools
|
|
50
|
+
|
|
51
|
+
### Atomic Tools for Coding Agents (Cursor, Antigravity, Claude Desktop)
|
|
52
|
+
|
|
53
|
+
High-level tools with atomic arguments (`str`, `bool`, `list[str]`) designed specifically for AI code agents, preventing hallucinated question schemas:
|
|
54
|
+
|
|
55
|
+
#### 1. `evaluate_command_safety`
|
|
56
|
+
Evaluates whether a terminal/shell command is destructive, requires human approval, or can execute autonomously:
|
|
57
|
+
- **Arguments**:
|
|
58
|
+
- `command: str` (required): Shell command to evaluate.
|
|
59
|
+
- `working_dir: str = ""` (optional): Target execution directory.
|
|
60
|
+
- `elevated_privileges: bool = false` (optional): Whether the command runs with `sudo` or administrator privileges.
|
|
61
|
+
- **Pipeline**: Constructs a unified Noul (boundary destruction probability), Score (operational blast radius), and Choice (policy recommendation) evaluation with certainty calibration.
|
|
62
|
+
- **Output**: Returns an execution policy: `ALLOW_AUTONOMOUS`, `REQUIRE_HUMAN_APPROVAL`, or `DENY_DESTRUCTIVE`.
|
|
63
|
+
|
|
64
|
+
#### 2. `verify_code_patch`
|
|
65
|
+
Verifies unified git diffs or code patches for regressions, broken syntax, or critical system impact:
|
|
66
|
+
- **Arguments**:
|
|
67
|
+
- `patch_content: str` (required): Unified diff or patch text.
|
|
68
|
+
- `target_file: str` (required): Target file path.
|
|
69
|
+
- `risk_tolerance: str = "balanced"` (optional): Risk threshold (`"strict"`, `"balanced"`, `"permissive"`).
|
|
70
|
+
- **Pipeline**: Calibrates regression probability and risk score against the configured risk tolerance threshold.
|
|
71
|
+
- **Output**: Returns `approved` (boolean), `recommendation` (`"APPROVE"`, `"REQUEST_CHANGES"`, `"REJECT"`), and `risk_level` (`"LOW"`, `"MEDIUM"`, `"HIGH"`, `"CRITICAL"`).
|
|
72
|
+
|
|
73
|
+
#### 3. `evaluate_decision`
|
|
74
|
+
Allows coding agents to resolve architectural or technical decisions with a flat options list:
|
|
75
|
+
- **Arguments**:
|
|
76
|
+
- `context: str` (required): Background context and requirements.
|
|
77
|
+
- `decision_question: str` (required): Core decision question.
|
|
78
|
+
- `options: list[str]` (required): Candidate options (e.g. `["PostgreSQL", "SQLite", "DuckDB"]`).
|
|
79
|
+
- **Pipeline**: Automatically injects closed-world neutral escape (`UNRESOLVED_OR_OTHER`) to catch out-of-distribution choices and calibrates probability dispersion.
|
|
80
|
+
- **Output**: Returns `selected_option`, `confidence`, `is_escape_selected`, and `status` (`CONFIDENT` or `AMBIGUOUS_STATE`).
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### Core JevGuard Primitives
|
|
85
|
+
|
|
86
|
+
#### 4. `jevguard_evaluate`
|
|
87
|
+
Executes the full deterministic JevGuard evaluation pipeline:
|
|
88
|
+
- Prunes incoming state data to eliminate empty keys and duplicate whitespace.
|
|
89
|
+
- Normalizes question schemas and injects closed-world escape alternatives (`UNRESOLVED_OR_OTHER`) to prevent false positives.
|
|
90
|
+
- Computes canonical SHA-256 fingerprints with volatile key masking.
|
|
91
|
+
- Queries the zero-token cache on hit or dispatches upstream to TypeSafe AI when credentials are configured.
|
|
92
|
+
- Calibrates response certainty and dispersion metrics.
|
|
93
|
+
|
|
94
|
+
#### 5. `jevguard_calibrate`
|
|
95
|
+
Analyzes response probability distributions to prevent false certainty:
|
|
96
|
+
- Flags low confidence when the top probability falls below 0.40 (`top_prob < 0.40`).
|
|
97
|
+
- Flags flat distributions when the gap between top and runner-up choices is below 0.15 (`dispersion_gap < 0.15`).
|
|
98
|
+
- Evaluates boundary uncertainty for continuous noul probability ranges near 0.50 (`|prob - 0.50| < 0.12`).
|
|
99
|
+
- Returns structured verdicts: `AMBIGUOUS_STATE` or `CONFIDENT`.
|
|
100
|
+
|
|
101
|
+
#### 6. `jevguard_prune_state`
|
|
102
|
+
Sanitizes structured input states:
|
|
103
|
+
- Removes null values and empty strings/collections from mapping objects.
|
|
104
|
+
- Normalizes and collapses repeated whitespace.
|
|
105
|
+
- Detects circular references and replaces them with `<cyclic_ref>` tokens.
|
|
106
|
+
- Calculates an input token count estimate.
|
|
107
|
+
|
|
108
|
+
#### 7. `jevguard_cache_fingerprint`
|
|
109
|
+
Calculates a canonical SHA-256 fingerprint:
|
|
110
|
+
- Recursively strips volatile ephemeral request fields (`timestamp`, `trace_id`, `span_id`, `request_id`, `correlation_id`, `nonce`).
|
|
111
|
+
- Orders dictionary keys deterministically.
|
|
112
|
+
- Produces identical hashes for semantically identical states regardless of key ordering or ephemeral trace variance.
|
|
113
|
+
- Preserves domain date/time attributes (`created_at`, `updated_at`) by default to prevent version collisions.
|
|
114
|
+
|
|
115
|
+
## Robustness & Fault Tolerance
|
|
116
|
+
|
|
117
|
+
1. **Hardened SQLite Concurrency**:
|
|
118
|
+
- Connections use `timeout=60.0` and `PRAGMA busy_timeout = 60000;` to prevent `database is locked` contention under parallel agent execution.
|
|
119
|
+
- Operates with `PRAGMA journal_mode=WAL;` and `PRAGMA synchronous=NORMAL;` for non-blocking concurrent reads and writes.
|
|
120
|
+
- Any unrecoverable lock, filesystem, or permission error transparently degrades to shared `:memory:` without crashing or aborting execution.
|
|
121
|
+
|
|
122
|
+
2. **Structured Exception Handling & Protocol Stability**:
|
|
123
|
+
- All tool executions are wrapped in defensive error handlers.
|
|
124
|
+
- Failures (HTTP errors, timeouts, network interruptions, validation errors) return actionable JSON text payloads with `"fallback_action": "MANUAL_REVIEW_REQUIRED"`.
|
|
125
|
+
- Tool failures return actionable structured JSON error payloads with standard MCP `isError: true`, while keeping the stdio transport cleanly connected so client environments (Cursor, Claude Desktop, Antigravity) never crash or drop sessions.
|
|
126
|
+
|
|
127
|
+
3. **Third-Party Data Transmission Disclosure**:
|
|
128
|
+
- Live evaluations (cache misses or `bypass_cache=True`) transmit the evaluated `command`, `patch_content`, or `state` payload over encrypted HTTPS directly to the official TypeSafe AI endpoint (`api.typesafe.ai`).
|
|
129
|
+
- Ephemeral headers and keys are never forwarded across redirect chains (`NoRedirectHandler` blocks 301/302/303 redirect leakage).
|
|
130
|
+
- When deterministic cache hits occur, zero tokens are consumed and zero bytes leave the local host.
|
|
131
|
+
|
|
132
|
+
## Installation
|
|
133
|
+
|
|
134
|
+
Install the package directly in editable mode or as a standalone module using standard Python:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
cd /path/to/jevguard-mcp
|
|
138
|
+
pip install -e .
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Alternatively, run directly with Python without installing:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
python -m jevguard_mcp.server
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Client Configurations
|
|
148
|
+
|
|
149
|
+
### 1. Claude Desktop
|
|
150
|
+
|
|
151
|
+
Add the server to your `claude_desktop_config.json`:
|
|
152
|
+
|
|
153
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
154
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
155
|
+
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"mcpServers": {
|
|
160
|
+
"jevguard": {
|
|
161
|
+
"command": "python",
|
|
162
|
+
"args": [
|
|
163
|
+
"-m",
|
|
164
|
+
"jevguard_mcp.server"
|
|
165
|
+
],
|
|
166
|
+
"env": {
|
|
167
|
+
"TYPESAFE_API_KEY": "your_typesafe_api_key_here"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 2. Cursor IDE
|
|
175
|
+
|
|
176
|
+
Add the server in Cursor Settings under Features -> MCP Servers -> Add New MCP Server, or save directly into `.cursor/mcp.json`:
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"mcpServers": {
|
|
181
|
+
"jevguard": {
|
|
182
|
+
"command": "python",
|
|
183
|
+
"args": [
|
|
184
|
+
"-m",
|
|
185
|
+
"jevguard_mcp.server"
|
|
186
|
+
],
|
|
187
|
+
"env": {
|
|
188
|
+
"TYPESAFE_API_KEY": "your_typesafe_api_key_here"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 3. LibreChat
|
|
196
|
+
|
|
197
|
+
Add the server to your `librechat.yaml` configuration file:
|
|
198
|
+
|
|
199
|
+
```yaml
|
|
200
|
+
mcpServers:
|
|
201
|
+
jevguard:
|
|
202
|
+
type: stdio
|
|
203
|
+
command: python
|
|
204
|
+
args:
|
|
205
|
+
- "-m"
|
|
206
|
+
- "jevguard_mcp.server"
|
|
207
|
+
env:
|
|
208
|
+
TYPESAFE_API_KEY: "your_typesafe_api_key_here"
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Running the Test Suite
|
|
212
|
+
|
|
213
|
+
Run the unit tests with Python's standard `unittest` runner:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
python -m unittest test_mcp_server.py -v
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Project Status and Validation Transparency
|
|
220
|
+
|
|
221
|
+
JevGuard MCP is an independent open-source runtime (v1.0.0) built solely with the Python standard library. Initial design and test suites were developed iteratively using AI assistance and local unit test harnesses.
|
|
222
|
+
|
|
223
|
+
Key engineering notes:
|
|
224
|
+
- The local server (protocol serialization, SQLite caching, state pruning, and calibration checks) is deterministic, while upstream evaluations from TypeSafe AI / Jev are probabilistic.
|
|
225
|
+
- Default calibration thresholds (e.g. top probability below 0.40, margin below 0.15) represent operational heuristics for tie and uncertainty detection rather than parameters fitted on a specific domain corpus.
|
|
226
|
+
- We welcome community peer review, external testing, and issue reports.
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
MIT License. Copyright (c) 2026 Seb4Ez.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# JevGuard MCP Server
|
|
2
|
+
|
|
3
|
+
Official Model Context Protocol (MCP) server for JevGuard, providing a deterministic local caching, state sanitization, and guardrail layer for TypeSafe AI's System One decision model.
|
|
4
|
+
|
|
5
|
+
This package exposes core JevGuard primitives through JSON-RPC 2.0 over standard input/output (stdio), adhering to the MCP 2024-11-05 specification.
|
|
6
|
+
|
|
7
|
+
## Architectural Principles
|
|
8
|
+
|
|
9
|
+
1. Zero External Dependencies: Implemented strictly with the Python standard library (`sys`, `json`, `sqlite3`, `hashlib`, `urllib`).
|
|
10
|
+
2. Protocol Fidelity: Full compliance with the MCP 2024-11-05 standard, supporting initialize handshakes, ping, tool discovery, and tool execution.
|
|
11
|
+
3. Deterministic Local Layer: Canonical state sanitization, neutral escape injection, probability dispersion analysis, and SHA-256 fingerprint caching in SQLite.
|
|
12
|
+
4. Process Isolation: Runs as an independent stdio subprocess compatible with Claude Desktop, Cursor IDE, LibreChat, and custom MCP clients.
|
|
13
|
+
|
|
14
|
+
## Live Verification Benchmark (5 Direct Calls vs 5 JevGuard MCP Calls)
|
|
15
|
+
|
|
16
|
+
A live comparison was conducted directly against the official TypeSafe AI endpoint (`https://api.typesafe.ai/v1/systemone`, model `jev-latest`) comparing 5 direct API calls against 5 JevGuard MCP tool calls from a development workstation.
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
### Key Empirical Observations
|
|
21
|
+
|
|
22
|
+
1. Local Cache Retrieval (0.099 ms): Repeated queries containing dynamic timestamps and trace IDs are intercepted locally. Volatile key masking matches the canonical SHA-256 fingerprint, avoiding WAN network roundtrips (~740 ms) and billing 0 tokens on cache hits.
|
|
23
|
+
2. Closed-World Trap Mitigation: In Scenario 3 (an off-topic inquiry about corporate tax offices in Zurich), the unguided model forced a classification (`credit_card_chargeback`). JevGuard MCP injected `UNRESOLVED_OR_OTHER`, routing the off-topic input to the neutral escape option.
|
|
24
|
+
3. Ambiguity Calibration: In Scenario 1, boundary uncertainty on `is_outage` (`noul=0.49`, distance 0.01 to threshold) and flat distribution on `severity` (0.08 gap) were flagged as `AMBIGUOUS_STATE` using default operational heuristics.
|
|
25
|
+
4. Standard Library Overhead: Local middleware execution latency remained below 0.3 ms for cold requests and 0.099 ms for warm cache lookups.
|
|
26
|
+
|
|
27
|
+
## Available Tools
|
|
28
|
+
|
|
29
|
+
### Atomic Tools for Coding Agents (Cursor, Antigravity, Claude Desktop)
|
|
30
|
+
|
|
31
|
+
High-level tools with atomic arguments (`str`, `bool`, `list[str]`) designed specifically for AI code agents, preventing hallucinated question schemas:
|
|
32
|
+
|
|
33
|
+
#### 1. `evaluate_command_safety`
|
|
34
|
+
Evaluates whether a terminal/shell command is destructive, requires human approval, or can execute autonomously:
|
|
35
|
+
- **Arguments**:
|
|
36
|
+
- `command: str` (required): Shell command to evaluate.
|
|
37
|
+
- `working_dir: str = ""` (optional): Target execution directory.
|
|
38
|
+
- `elevated_privileges: bool = false` (optional): Whether the command runs with `sudo` or administrator privileges.
|
|
39
|
+
- **Pipeline**: Constructs a unified Noul (boundary destruction probability), Score (operational blast radius), and Choice (policy recommendation) evaluation with certainty calibration.
|
|
40
|
+
- **Output**: Returns an execution policy: `ALLOW_AUTONOMOUS`, `REQUIRE_HUMAN_APPROVAL`, or `DENY_DESTRUCTIVE`.
|
|
41
|
+
|
|
42
|
+
#### 2. `verify_code_patch`
|
|
43
|
+
Verifies unified git diffs or code patches for regressions, broken syntax, or critical system impact:
|
|
44
|
+
- **Arguments**:
|
|
45
|
+
- `patch_content: str` (required): Unified diff or patch text.
|
|
46
|
+
- `target_file: str` (required): Target file path.
|
|
47
|
+
- `risk_tolerance: str = "balanced"` (optional): Risk threshold (`"strict"`, `"balanced"`, `"permissive"`).
|
|
48
|
+
- **Pipeline**: Calibrates regression probability and risk score against the configured risk tolerance threshold.
|
|
49
|
+
- **Output**: Returns `approved` (boolean), `recommendation` (`"APPROVE"`, `"REQUEST_CHANGES"`, `"REJECT"`), and `risk_level` (`"LOW"`, `"MEDIUM"`, `"HIGH"`, `"CRITICAL"`).
|
|
50
|
+
|
|
51
|
+
#### 3. `evaluate_decision`
|
|
52
|
+
Allows coding agents to resolve architectural or technical decisions with a flat options list:
|
|
53
|
+
- **Arguments**:
|
|
54
|
+
- `context: str` (required): Background context and requirements.
|
|
55
|
+
- `decision_question: str` (required): Core decision question.
|
|
56
|
+
- `options: list[str]` (required): Candidate options (e.g. `["PostgreSQL", "SQLite", "DuckDB"]`).
|
|
57
|
+
- **Pipeline**: Automatically injects closed-world neutral escape (`UNRESOLVED_OR_OTHER`) to catch out-of-distribution choices and calibrates probability dispersion.
|
|
58
|
+
- **Output**: Returns `selected_option`, `confidence`, `is_escape_selected`, and `status` (`CONFIDENT` or `AMBIGUOUS_STATE`).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### Core JevGuard Primitives
|
|
63
|
+
|
|
64
|
+
#### 4. `jevguard_evaluate`
|
|
65
|
+
Executes the full deterministic JevGuard evaluation pipeline:
|
|
66
|
+
- Prunes incoming state data to eliminate empty keys and duplicate whitespace.
|
|
67
|
+
- Normalizes question schemas and injects closed-world escape alternatives (`UNRESOLVED_OR_OTHER`) to prevent false positives.
|
|
68
|
+
- Computes canonical SHA-256 fingerprints with volatile key masking.
|
|
69
|
+
- Queries the zero-token cache on hit or dispatches upstream to TypeSafe AI when credentials are configured.
|
|
70
|
+
- Calibrates response certainty and dispersion metrics.
|
|
71
|
+
|
|
72
|
+
#### 5. `jevguard_calibrate`
|
|
73
|
+
Analyzes response probability distributions to prevent false certainty:
|
|
74
|
+
- Flags low confidence when the top probability falls below 0.40 (`top_prob < 0.40`).
|
|
75
|
+
- Flags flat distributions when the gap between top and runner-up choices is below 0.15 (`dispersion_gap < 0.15`).
|
|
76
|
+
- Evaluates boundary uncertainty for continuous noul probability ranges near 0.50 (`|prob - 0.50| < 0.12`).
|
|
77
|
+
- Returns structured verdicts: `AMBIGUOUS_STATE` or `CONFIDENT`.
|
|
78
|
+
|
|
79
|
+
#### 6. `jevguard_prune_state`
|
|
80
|
+
Sanitizes structured input states:
|
|
81
|
+
- Removes null values and empty strings/collections from mapping objects.
|
|
82
|
+
- Normalizes and collapses repeated whitespace.
|
|
83
|
+
- Detects circular references and replaces them with `<cyclic_ref>` tokens.
|
|
84
|
+
- Calculates an input token count estimate.
|
|
85
|
+
|
|
86
|
+
#### 7. `jevguard_cache_fingerprint`
|
|
87
|
+
Calculates a canonical SHA-256 fingerprint:
|
|
88
|
+
- Recursively strips volatile ephemeral request fields (`timestamp`, `trace_id`, `span_id`, `request_id`, `correlation_id`, `nonce`).
|
|
89
|
+
- Orders dictionary keys deterministically.
|
|
90
|
+
- Produces identical hashes for semantically identical states regardless of key ordering or ephemeral trace variance.
|
|
91
|
+
- Preserves domain date/time attributes (`created_at`, `updated_at`) by default to prevent version collisions.
|
|
92
|
+
|
|
93
|
+
## Robustness & Fault Tolerance
|
|
94
|
+
|
|
95
|
+
1. **Hardened SQLite Concurrency**:
|
|
96
|
+
- Connections use `timeout=60.0` and `PRAGMA busy_timeout = 60000;` to prevent `database is locked` contention under parallel agent execution.
|
|
97
|
+
- Operates with `PRAGMA journal_mode=WAL;` and `PRAGMA synchronous=NORMAL;` for non-blocking concurrent reads and writes.
|
|
98
|
+
- Any unrecoverable lock, filesystem, or permission error transparently degrades to shared `:memory:` without crashing or aborting execution.
|
|
99
|
+
|
|
100
|
+
2. **Structured Exception Handling & Protocol Stability**:
|
|
101
|
+
- All tool executions are wrapped in defensive error handlers.
|
|
102
|
+
- Failures (HTTP errors, timeouts, network interruptions, validation errors) return actionable JSON text payloads with `"fallback_action": "MANUAL_REVIEW_REQUIRED"`.
|
|
103
|
+
- Tool failures return actionable structured JSON error payloads with standard MCP `isError: true`, while keeping the stdio transport cleanly connected so client environments (Cursor, Claude Desktop, Antigravity) never crash or drop sessions.
|
|
104
|
+
|
|
105
|
+
3. **Third-Party Data Transmission Disclosure**:
|
|
106
|
+
- Live evaluations (cache misses or `bypass_cache=True`) transmit the evaluated `command`, `patch_content`, or `state` payload over encrypted HTTPS directly to the official TypeSafe AI endpoint (`api.typesafe.ai`).
|
|
107
|
+
- Ephemeral headers and keys are never forwarded across redirect chains (`NoRedirectHandler` blocks 301/302/303 redirect leakage).
|
|
108
|
+
- When deterministic cache hits occur, zero tokens are consumed and zero bytes leave the local host.
|
|
109
|
+
|
|
110
|
+
## Installation
|
|
111
|
+
|
|
112
|
+
Install the package directly in editable mode or as a standalone module using standard Python:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
cd /path/to/jevguard-mcp
|
|
116
|
+
pip install -e .
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Alternatively, run directly with Python without installing:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
python -m jevguard_mcp.server
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Client Configurations
|
|
126
|
+
|
|
127
|
+
### 1. Claude Desktop
|
|
128
|
+
|
|
129
|
+
Add the server to your `claude_desktop_config.json`:
|
|
130
|
+
|
|
131
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
132
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
133
|
+
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"jevguard": {
|
|
139
|
+
"command": "python",
|
|
140
|
+
"args": [
|
|
141
|
+
"-m",
|
|
142
|
+
"jevguard_mcp.server"
|
|
143
|
+
],
|
|
144
|
+
"env": {
|
|
145
|
+
"TYPESAFE_API_KEY": "your_typesafe_api_key_here"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 2. Cursor IDE
|
|
153
|
+
|
|
154
|
+
Add the server in Cursor Settings under Features -> MCP Servers -> Add New MCP Server, or save directly into `.cursor/mcp.json`:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"mcpServers": {
|
|
159
|
+
"jevguard": {
|
|
160
|
+
"command": "python",
|
|
161
|
+
"args": [
|
|
162
|
+
"-m",
|
|
163
|
+
"jevguard_mcp.server"
|
|
164
|
+
],
|
|
165
|
+
"env": {
|
|
166
|
+
"TYPESAFE_API_KEY": "your_typesafe_api_key_here"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 3. LibreChat
|
|
174
|
+
|
|
175
|
+
Add the server to your `librechat.yaml` configuration file:
|
|
176
|
+
|
|
177
|
+
```yaml
|
|
178
|
+
mcpServers:
|
|
179
|
+
jevguard:
|
|
180
|
+
type: stdio
|
|
181
|
+
command: python
|
|
182
|
+
args:
|
|
183
|
+
- "-m"
|
|
184
|
+
- "jevguard_mcp.server"
|
|
185
|
+
env:
|
|
186
|
+
TYPESAFE_API_KEY: "your_typesafe_api_key_here"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Running the Test Suite
|
|
190
|
+
|
|
191
|
+
Run the unit tests with Python's standard `unittest` runner:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
python -m unittest test_mcp_server.py -v
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Project Status and Validation Transparency
|
|
198
|
+
|
|
199
|
+
JevGuard MCP is an independent open-source runtime (v1.0.0) built solely with the Python standard library. Initial design and test suites were developed iteratively using AI assistance and local unit test harnesses.
|
|
200
|
+
|
|
201
|
+
Key engineering notes:
|
|
202
|
+
- The local server (protocol serialization, SQLite caching, state pruning, and calibration checks) is deterministic, while upstream evaluations from TypeSafe AI / Jev are probabilistic.
|
|
203
|
+
- Default calibration thresholds (e.g. top probability below 0.40, margin below 0.15) represent operational heuristics for tie and uncertainty detection rather than parameters fitted on a specific domain corpus.
|
|
204
|
+
- We welcome community peer review, external testing, and issue reports.
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT License. Copyright (c) 2026 Seb4Ez.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JevGuard MCP Server - Official Model Context Protocol runtime for JevGuard.
|
|
3
|
+
Provides deterministic evaluation, state pruning, certainty calibration,
|
|
4
|
+
and canonical cache fingerprinting over standard JSON-RPC 2.0 stdio transport.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .server import MCPServer, run_server
|
|
8
|
+
from .tools import (
|
|
9
|
+
DeterministicCache,
|
|
10
|
+
QuestionOptimizer,
|
|
11
|
+
ResponseCalibrator,
|
|
12
|
+
StatePruner,
|
|
13
|
+
ToolRegistry,
|
|
14
|
+
get_default_cache_db_path,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__version__ = "1.0.0"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"MCPServer",
|
|
21
|
+
"run_server",
|
|
22
|
+
"DeterministicCache",
|
|
23
|
+
"QuestionOptimizer",
|
|
24
|
+
"ResponseCalibrator",
|
|
25
|
+
"StatePruner",
|
|
26
|
+
"ToolRegistry",
|
|
27
|
+
"get_default_cache_db_path",
|
|
28
|
+
"__version__",
|
|
29
|
+
]
|