delentia-mcp 2.1.1 → 2.1.2

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 (4) hide show
  1. package/README.md +184 -170
  2. package/bin/cli.js +116 -36
  3. package/package.json +55 -54
  4. package/server.json +20 -20
package/README.md CHANGED
@@ -1,170 +1,184 @@
1
- <div align="center">
2
-
3
- <img src="./assets/delentia-green-logo.png" alt="Delentia Labs Logo" width="128" height="128" />
4
-
5
- # Delentia Sovereign AI Operating System
6
- ### Official Model Context Protocol (MCP) Public Client & Connector
7
-
8
- [![Release](https://img.shields.io/github/v/release/delentia-labs/delentia-mcp?color=brightgreen)](https://github.com/delentia-labs/delentia-mcp/releases)
9
- [![Smithery Quality](https://img.shields.io/badge/Smithery%20Quality-100%2F100-brightgreen)](https://smithery.ai/servers/delentia/delentia-sovereign)
10
- [![Edge Health Check](https://github.com/delentia-labs/delentia-mcp/actions/workflows/healthcheck.yml/badge.svg)](https://github.com/delentia-labs/delentia-mcp/actions/workflows/healthcheck.yml)
11
- [![MCP Protocol](https://img.shields.io/badge/MCP%20Protocol-2024--11--05-blue)](https://modelcontextprotocol.io/)
12
- [![License](https://img.shields.io/badge/License-Apache%202.0-orange)](./LICENSE)
13
- [![Benchmarks](https://img.shields.io/badge/Benchmarks-measured-blueviolet)](./BENCHMARKS.md)
14
- [![Website](https://img.shields.io/badge/Website-delentia.com-emerald)](https://delentia.com)
15
-
16
- **Stop rogue AI-agent tool calls before they run: a deterministic policy gate with an audit trail.**
17
- Bridging autonomous AI agents (Claude, Cursor, VS Code, Windsurf, Codex) to the Delentia Sovereign Edge Network.
18
- 📊 **[View Empirical Benchmarks & 30-Second Visual Proof](./BENCHMARKS.md)**
19
-
20
- ---
21
-
22
- </div>
23
-
24
- ## 🏛️ Executive Architectural Overview
25
-
26
- The **Delentia Sovereign AI Operating System** provides a mathematically verifiable layer of defense, reasoning rigor, context compression, and swarm coordination for autonomous AI workflows:
27
-
28
- ```text
29
- ┌─────────────────────────────────────────────────────────────┐
30
- │ Autonomous AI Clients & IDEs │
31
- │ (Claude Desktop, Cursor, VS Code, Windsurf, Cline) │
32
- └──────────────────────────────┬──────────────────────────────┘
33
- │
34
- stdio / Streamable HTTP (MCP)
35
- │
36
- ┌──────────────────────────────▼──────────────────────────────┐
37
- │ Delentia Sovereign Edge Gateway │
38
- │ (Cloudflare Global Workers + Durable Objects) │
39
- └──────────────────────────────┬──────────────────────────────┘
40
- │
41
- ┌────────────────────────────┼────────────────────────────┐
42
- ▼ ▼ ▼
43
- [ 1. FDIA Security ] [ 2. RCT-7 Thinking ] [ 3. Delta & JITNA ]
44
- Deterministic policy gate 7-stage reasoning Context compression
45
- F = (D^I) * A checklist & signed task packets
46
- ```
47
-
48
- ---
49
-
50
- ## 🛠️ The 6 Tools
51
-
52
- | Tool Name | Type | What it does |
53
- | :--- | :---: | :--- |
54
- | **`evaluate_fdia`** | Read-Only | Scores a proposed action with F = (D^I) × A against your policy and returns AUTHORIZED or a block verdict with a SHA-256 audit digest. A = 0 (policy says no, or a required human signature is missing) always gives F = 0. Actions that need a human require an Ed25519-signed Architect token from a key the deployment trusts. |
55
- | **`configure_policy`** | Action | Sets the rules for *your* session only (RBAC, blocked actions, dual sign-off, safety threshold). The deployment's default policy is never changed. |
56
- | **`rct_think`** | Read-Only | Walks a 7-stage reasoning checklist over a plan and returns a heuristic alignment score. It helps catch vague or misaligned plans; it does not guarantee correct answers. |
57
- | **`compress_context`** | Read-Only | Deterministic compression of long tool output and logs (no LLM call). Measured ~70% fewer tokens on real logs while literal-wording questions stayed answerable ([benchmark](./BENCHMARKS.md)). Can keep the original for `expand_context`. |
58
- | **`expand_context`** | Read-Only | Returns lines of the original behind a compressed result, by line range or search, when the compressed version left something out. |
59
- | **`orchestrate_swarm`** | Read-Only | Splits a goal into signed JITNA task packets for several roles. |
60
-
61
- > **Advisory vs enforcing:** these tools help an agent that chooses to call them. To *enforce* a policy on every tool call of another MCP server, use **Delentia Guard** (`delentia-guard`), an stdio proxy with a signed audit log.
62
-
63
- ---
64
-
65
- ## 🚀 Quickstart: Universal 1-Click Client Setup
66
-
67
- ### Universal Remote Bridge (Zero-Friction 1-Click Setup)
68
- Connect any MCP-compatible environment (Claude Desktop, Cursor, Antigravity IDE, VS Code, Windsurf) directly to the Delentia Sovereign Global Edge:
69
-
70
- ```bash
71
- npx -y mcp-remote https://delentia-sovereign-mcp.delentia.workers.dev/mcp
72
- ```
73
-
74
- > **Developer Sandbox Free Tier**: Includes 50 daily free calls per caller IP out of the box with zero registration required!
75
- > **Paid tier (preview)**: For a higher quota, pass a Zuplo API Key from the [Delentia Developer Portal](https://delentia-gateway-main-c7624a5.zuplo.site/pricing):
76
- > ```bash
77
- > npx -y mcp-remote https://delentia-sovereign-mcp.delentia.workers.dev/mcp --header "Authorization: Bearer YOUR_ZUPLO_API_KEY"
78
- > ```
79
-
80
- ### Option A: Cursor IDE Configuration (`~/.cursor/mcp.json`)
81
- ```json
82
- {
83
- "mcpServers": {
84
- "delentia-sovereign": {
85
- "command": "npx",
86
- "args": [
87
- "-y",
88
- "mcp-remote",
89
- "https://delentia-sovereign-mcp.delentia.workers.dev/mcp"
90
- ]
91
- }
92
- }
93
- }
94
- ```
95
-
96
- ### Option B: Claude Desktop Configuration (`claude_desktop_config.json`)
97
-
98
- #### 1. Free Community Sandbox (Zero-Config / 50 calls daily):
99
- ```json
100
- {
101
- "mcpServers": {
102
- "delentia-sovereign": {
103
- "command": "npx",
104
- "args": [
105
- "-y",
106
- "mcp-remote",
107
- "https://delentia-sovereign-mcp.delentia.workers.dev/mcp"
108
- ]
109
- }
110
- }
111
- }
112
- ```
113
-
114
- #### 2. Paid tier (Zuplo API Key, higher quota — no SLA is offered yet):
115
- ```json
116
- {
117
- "mcpServers": {
118
- "delentia-sovereign": {
119
- "command": "node",
120
- "args": [
121
- "./bin/cli.js"
122
- ],
123
- "env": {
124
- "DELENTIA_API_KEY": "YOUR_ZUPLO_API_KEY"
125
- }
126
- }
127
- }
128
- }
129
- ```
130
-
131
- ### Option D: Instant Terminal Verification (1-Line cURL)
132
- Test the live Sovereign MCP server directly in any terminal:
133
-
134
- ```bash
135
- curl -X POST https://delentia-sovereign-mcp.delentia.workers.dev/mcp \
136
- -H "Content-Type: application/json" \
137
- -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}"
138
- ```
139
-
140
- ---
141
-
142
- ## 🌐 Official Marketplace & Registry Listings
143
-
144
- | Marketplace / Directory | Status | Official Live Listing Link |
145
- | :--- | :---: | :--- |
146
- | **Smithery.ai** | **Published (100/100 Quality)** | [smithery.ai/servers/delentia/delentia-sovereign](https://smithery.ai/servers/delentia/delentia-sovereign) |
147
- | **Glama.ai** | **Published (Triple-A Verified)** | [glama.ai/mcp/servers/delentia-labs/delentia-mcp](https://glama.ai/mcp/servers/delentia-labs/delentia-mcp) |
148
- | **Official MCP Registry** | **Published** | [registry.modelcontextprotocol.io/?q=delentia](https://registry.modelcontextprotocol.io/?q=delentia) |
149
- | **MCPize** | **Published** | [mcpize.com/mcp/delentia-mcp](https://mcpize.com/mcp/delentia-mcp) |
150
- | **Zuplo Developer Portal** | **Published** | [delentia-gateway-main-c7624a5.zuplo.site/introduction](https://delentia-gateway-main-c7624a5.zuplo.site/introduction) |
151
- | **PulseMCP** | **Auto-Syncing** | Synced via Official MCP Registry Index |
152
- | **Awesome MCP Servers** | **PR Submitted (Pending Merge)** | [github.com/punkpeye/awesome-mcp-servers/pull/13430](https://github.com/punkpeye/awesome-mcp-servers/pull/13430) |
153
- | **MCP Market (CherryHQ)** | **Issue Submitted (Pending Review)** | [github.com/CherryHQ/mcpmarket/issues/51](https://github.com/CherryHQ/mcpmarket/issues/51) |
154
-
155
- ---
156
-
157
- ## 🔒 Enterprise Security & Verification
158
-
159
- - **Tamper-Proof Audit Digest:** Every security evaluation computes a SHA-256 cryptographic verification digest.
160
- - **Dual Sign-Off Gate:** High-risk actions unconditionally mandate multi-party authorization tokens.
161
- - **Structured pre-execution reasoning:** `rct_think` walks a 7-stage checklist and returns a heuristic alignment score. It helps catch vague or misaligned plans; it does not guarantee the absence of hallucinations.
162
-
163
- ---
164
-
165
- ## 📜 Intellectual Property & Attribution
166
-
167
- - **Developer:** **Delentia Labs**
168
- - **Chief Architect:** **Ittirit Saengow (The Architect)**
169
- - **Official Portal:** [https://delentia.com](https://delentia.com)
170
- - **License:** Apache-2.0 (Public Client Connector)
1
+ <div align="center">
2
+
3
+ <img src="./assets/delentia-green-logo.png" alt="Delentia Labs Logo" width="128" height="128" />
4
+
5
+ # Delentia MCP connector
6
+ ### Advisory policy-check, reasoning-checklist and context-compression tools for MCP agents, plus a pointer to Delentia Guard (the enforcing proxy)
7
+
8
+ [![Release](https://img.shields.io/github/v/release/delentia-labs/delentia-mcp?color=brightgreen)](https://github.com/delentia-labs/delentia-mcp/releases)
9
+ [![Smithery listing](https://img.shields.io/badge/Smithery-listed-lightgrey)](https://smithery.ai/servers/delentia/delentia-sovereign)
10
+ [![Edge Health Check](https://github.com/delentia-labs/delentia-mcp/actions/workflows/healthcheck.yml/badge.svg)](https://github.com/delentia-labs/delentia-mcp/actions/workflows/healthcheck.yml)
11
+ [![MCP Protocol](https://img.shields.io/badge/MCP%20Protocol-2024--11--05-blue)](https://modelcontextprotocol.io/)
12
+ [![License](https://img.shields.io/badge/License-Apache%202.0-orange)](./LICENSE)
13
+ [![Benchmarks](https://img.shields.io/badge/Benchmarks-measured-blueviolet)](./BENCHMARKS.md)
14
+ [![Website](https://img.shields.io/badge/Website-delentia.com-emerald)](https://delentia.com)
15
+
16
+ **What this package is:** a small stdio bridge that lets MCP clients (Claude, Cursor, VS Code, Windsurf, Codex) call six tools hosted on Delentia's Cloudflare Workers. **The tools are advisory**: an agent that does not call `evaluate_fdia` is not stopped by it. **To stop tool calls before they run, use [Delentia Guard](ecosystem/docs/GUARD.md)** (`npx delentia-guard`), a local proxy that checks every call and keeps a signed, hash-chained log.
17
+ 📊 **[Measured results, their limits, and the figures we withdrew](./BENCHMARKS.md)**
18
+
19
+ ---
20
+
21
+ </div>
22
+
23
+ ## 🏛️ Executive Architectural Overview
24
+
25
+ The hosted tools give an agent a deterministic policy score (F = D^I x A, same inputs, same answer), a seven-step reasoning checklist, deterministic context compression and signed task packets. They are checks an agent can ask for, not guarantees:
26
+
27
+ ```text
28
+ ┌─────────────────────────────────────────────────────────────┐
29
+ │ Autonomous AI Clients & IDEs │
30
+ │ (Claude Desktop, Cursor, VS Code, Windsurf, Cline) │
31
+ └──────────────────────────────┬──────────────────────────────┘
32
+ │
33
+ stdio / Streamable HTTP (MCP)
34
+ │
35
+ ┌──────────────────────────────▼──────────────────────────────┐
36
+ │ Delentia Sovereign Edge Gateway │
37
+ │ (Cloudflare Global Workers + Durable Objects) │
38
+ └──────────────────────────────┬──────────────────────────────┘
39
+ │
40
+ ┌────────────────────────────┼────────────────────────────┐
41
+ ▼ ▼ ▼
42
+ [ 1. FDIA Security ] [ 2. RCT-7 Thinking ] [ 3. Delta & JITNA ]
43
+ Deterministic policy gate 7-stage reasoning Context compression
44
+ F = (D^I) * A checklist & signed task packets
45
+ ```
46
+
47
+ ---
48
+
49
+ ## 🛠️ The 6 Tools
50
+
51
+ | Tool Name | Type | What it does |
52
+ | :--- | :---: | :--- |
53
+ | **`evaluate_fdia`** | Read-Only | Scores a proposed action with F = (D^I) × A against your policy and returns AUTHORIZED or a block verdict with a SHA-256 audit digest. A = 0 (policy says no, or a required human signature is missing) always gives F = 0. Actions that need a human require an Ed25519-signed Architect token from a key the deployment trusts. |
54
+ | **`configure_policy`** | Action | Sets the rules for *your* session only (RBAC, blocked actions, dual sign-off, safety threshold). The deployment's default policy is never changed. |
55
+ | **`rct_think`** | Read-Only | Walks a 7-stage reasoning checklist over a plan and returns a heuristic alignment score. It helps catch vague or misaligned plans; it does not guarantee correct answers. |
56
+ | **`compress_context`** | Read-Only | Deterministic compression of long tool output and logs (no LLM call). Measured ~70% fewer tokens on real logs while literal-wording questions stayed answerable ([benchmark](./BENCHMARKS.md)). Can keep the original for `expand_context`. |
57
+ | **`expand_context`** | Read-Only | Returns lines of the original behind a compressed result, by line range or search, when the compressed version left something out. |
58
+ | **`orchestrate_swarm`** | Read-Only | Splits a goal into signed JITNA task packets for several roles. |
59
+
60
+ > **Advisory vs enforcing:** these tools help an agent that chooses to call them. To *enforce* a policy on every tool call of another MCP server, use **Delentia Guard** (`delentia-guard`), an stdio proxy with a signed audit log.
61
+
62
+ ---
63
+
64
+ ## 🚀 Quickstart: Universal 1-Click Client Setup
65
+
66
+ ### Universal Remote Bridge (Zero-Friction 1-Click Setup)
67
+ Connect any MCP-compatible environment (Claude Desktop, Cursor, Antigravity IDE, VS Code, Windsurf) directly to the Delentia Sovereign Global Edge:
68
+
69
+ ```bash
70
+ npx -y mcp-remote https://delentia-sovereign-mcp.delentia.workers.dev/mcp
71
+ ```
72
+
73
+ > **Developer Sandbox Free Tier**: Includes 50 daily free calls per caller IP out of the box with zero registration required!
74
+ > The count is kept in memory by each Worker instance, so it is a best-effort limit (it can reset when an instance restarts). Past the limit a `tools/call` returns HTTP 429 with JSON-RPC error code `-32002`; `tools/list` and `initialize` are not counted.
75
+ > **Paid tier (preview)**: For a higher quota, pass a Zuplo API Key from the [Delentia Developer Portal](https://delentia-gateway-main-c7624a5.zuplo.site/pricing):
76
+ > ```bash
77
+ > npx -y mcp-remote https://delentia-sovereign-mcp.delentia.workers.dev/mcp --header "Authorization: Bearer YOUR_ZUPLO_API_KEY"
78
+ > ```
79
+
80
+ ### Option A: Cursor IDE Configuration (`~/.cursor/mcp.json`)
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "delentia-sovereign": {
85
+ "command": "npx",
86
+ "args": [
87
+ "-y",
88
+ "mcp-remote",
89
+ "https://delentia-sovereign-mcp.delentia.workers.dev/mcp"
90
+ ]
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ ### Option B: Claude Desktop Configuration (`claude_desktop_config.json`)
97
+
98
+ #### 1. Free Community Sandbox (Zero-Config / 50 calls daily):
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "delentia-sovereign": {
103
+ "command": "npx",
104
+ "args": [
105
+ "-y",
106
+ "mcp-remote",
107
+ "https://delentia-sovereign-mcp.delentia.workers.dev/mcp"
108
+ ]
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ #### 2. Paid tier (Zuplo API Key, higher quota — no SLA is offered yet):
115
+ ```json
116
+ {
117
+ "mcpServers": {
118
+ "delentia-sovereign": {
119
+ "command": "node",
120
+ "args": [
121
+ "./bin/cli.js"
122
+ ],
123
+ "env": {
124
+ "DELENTIA_API_KEY": "YOUR_ZUPLO_API_KEY"
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Option D: Instant Terminal Verification (1-Line cURL)
132
+ Test the live Sovereign MCP server directly in any terminal:
133
+
134
+ ```bash
135
+ curl -X POST https://delentia-sovereign-mcp.delentia.workers.dev/mcp \
136
+ -H "Content-Type: application/json" \
137
+ -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}"
138
+ ```
139
+
140
+ ---
141
+
142
+ ## 🌐 Official Marketplace & Registry Listings
143
+
144
+ | Marketplace / Directory | Status | Official Live Listing Link |
145
+ | :--- | :---: | :--- |
146
+ | **Smithery.ai** | **Published** | [smithery.ai/servers/delentia/delentia-sovereign](https://smithery.ai/servers/delentia/delentia-sovereign) |
147
+ | **Glama.ai** | **Published** | [glama.ai/mcp/servers/delentia-labs/delentia-mcp](https://glama.ai/mcp/servers/delentia-labs/delentia-mcp) |
148
+ | **Official MCP Registry** | **Published** | [registry.modelcontextprotocol.io/?q=delentia](https://registry.modelcontextprotocol.io/?q=delentia) |
149
+ | **MCPize** | **Published** | [mcpize.com/mcp/delentia-mcp](https://mcpize.com/mcp/delentia-mcp) |
150
+ | **Zuplo Developer Portal** | **Published** | [delentia-gateway-main-c7624a5.zuplo.site/introduction](https://delentia-gateway-main-c7624a5.zuplo.site/introduction) |
151
+ | **PulseMCP** | **Auto-Syncing** | Synced via Official MCP Registry Index |
152
+ | **Awesome MCP Servers** | **PR Submitted (Pending Merge)** | [github.com/punkpeye/awesome-mcp-servers/pull/13430](https://github.com/punkpeye/awesome-mcp-servers/pull/13430) |
153
+ | **MCP Market (CherryHQ)** | **Issue Submitted (Pending Review)** | [github.com/CherryHQ/mcpmarket/issues/51](https://github.com/CherryHQ/mcpmarket/issues/51) |
154
+
155
+ ---
156
+
157
+ ## 🔒 Enterprise Security & Verification
158
+
159
+ - **Audit digest:** every evaluation returns a SHA-256 digest of its inputs and verdict. A digest shows that a record was changed; on its own it does not make a log tamper-proof. For an enforcing, Ed25519-signed, hash-chained log of every tool call, run [Delentia Guard](ecosystem/docs/GUARD.md).
160
+ - **Architect sign-off:** high-risk actions need an Ed25519-signed Architect token bound to that action and payload, from a key the deployment trusts; dual sign-off actions need two different trusted keys. Unsigned or forged tokens fail closed.
161
+ - **Structured pre-execution reasoning:** `rct_think` walks a 7-stage checklist and returns a heuristic alignment score. It helps catch vague or misaligned plans; it does not guarantee the absence of hallucinations.
162
+
163
+ ---
164
+
165
+ ## 🧩 Source code
166
+
167
+ This repository holds both the public connector (root: `bin/`, `dist/`, listing files) and the server source in [`ecosystem/`](ecosystem/): the Cloudflare Workers behind the 6 tools (`sovereign`, `fdia`, `rct7`, `delta`, `jitna`, `intent-loop`, `shared`) and [Delentia Guard](ecosystem/docs/GUARD.md) (`packages/guard`).
168
+
169
+ ```bash
170
+ cd ecosystem
171
+ npm ci
172
+ npm run build && npm run typecheck && npm run test:all
173
+ ```
174
+
175
+ Cross-stack bridge tests that need Delentia's non-public Python services skip unless `DELENTIA_PRIVATE_SERVICES_DIR` is set.
176
+
177
+ ---
178
+
179
+ ## 📜 Intellectual Property & Attribution
180
+
181
+ - **Developer:** **Delentia Labs**
182
+ - **Chief Architect:** **Ittirit Saengow (The Architect)**
183
+ - **Official Portal:** [https://delentia.com](https://delentia.com)
184
+ - **License:** Apache-2.0 (connector and `ecosystem/` server source)
package/bin/cli.js CHANGED
@@ -1,21 +1,60 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Delentia Sovereign AI Operating System — Official MCP Bridge CLI
5
- * Connects standard MCP stdio clients (Claude Desktop, Cursor, VS Code, Windsurf)
6
- * through the Delentia Zuplo API Gateway & Commercial Paywall.
4
+ * Delentia MCP bridge: connects a standard MCP stdio client (Claude Desktop, Cursor, VS Code,
5
+ * Windsurf) to Delentia's hosted MCP endpoint (Streamable HTTP), one JSON-RPC message at a time.
7
6
  *
8
- * Developed by Delentia Labs
9
- * Chief Architect: Ittirit Saengow (Chief Architect / Delentia Labs)
10
- * Strictly zero dollar signs enforced.
7
+ * npx delentia-mcp [--endpoint <url>] [--key <api-key>] (or DELENTIA_ENDPOINT / DELENTIA_API_KEY)
8
+ * npx delentia-mcp --help | --version
9
+ *
10
+ * The tools it exposes are ADVISORY (an agent that does not call them is not stopped). To enforce
11
+ * a policy on every tool call, use Delentia Guard (`npx delentia-guard`).
12
+ *
13
+ * Round 91: a request that gets no answer within DELENTIA_TIMEOUT_MS (default 60000) is answered
14
+ * with a JSON-RPC error instead of hanging the client; a `text/event-stream` reply is read
15
+ * (each `data:` event is one JSON-RPC message) instead of failing as "not JSON"; the server's
16
+ * `Mcp-Session-Id` is sent back on later requests; the User-Agent carries the real package
17
+ * version; `--help` and `--version` answer instead of waiting on stdin.
18
+ *
19
+ * Developed by Delentia Labs. Chief Architect: Ittirit Saengow.
11
20
  */
12
21
 
13
22
  import readline from "readline";
23
+ import { readFileSync } from "node:fs";
14
24
 
15
25
  const DEFAULT_ENDPOINT = "https://delentia-sovereign-mcp.delentia.workers.dev/mcp";
16
26
 
27
+ let VERSION = "unknown";
28
+ try {
29
+ VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
30
+ } catch {
31
+ /* running from a bundle without package.json: keep "unknown" */
32
+ }
33
+
17
34
  // Parse CLI flags and environment variables
18
35
  const args = process.argv.slice(2);
36
+
37
+ if (args.includes("--version") || args.includes("-v")) {
38
+ process.stdout.write(VERSION + "\n");
39
+ process.exit(0);
40
+ }
41
+ if (args.includes("--help") || args.includes("-h")) {
42
+ process.stdout.write(
43
+ [
44
+ `delentia-mcp ${VERSION}: stdio bridge to Delentia's hosted MCP endpoint`,
45
+ "",
46
+ "usage: delentia-mcp [--endpoint <url>] [--key <api-key>]",
47
+ " --endpoint, -e <url> MCP endpoint (default: " + DEFAULT_ENDPOINT + ", or DELENTIA_ENDPOINT)",
48
+ " --key, -k <api-key> API key for the paid tier (prefer the DELENTIA_API_KEY environment variable: a key on the command line shows in process lists)",
49
+ " DELENTIA_TIMEOUT_MS per-request timeout in milliseconds (default 60000)",
50
+ "",
51
+ "The hosted tools are advisory. To enforce a policy on every tool call use delentia-guard.",
52
+ "",
53
+ ].join("\n")
54
+ );
55
+ process.exit(0);
56
+ }
57
+
19
58
  let cliEndpoint = "";
20
59
  let cliApiKey = "";
21
60
 
@@ -35,6 +74,31 @@ for (let i = 0; i < args.length; i++) {
35
74
  const targetEndpoint = cliEndpoint || process.env.DELENTIA_ENDPOINT || DEFAULT_ENDPOINT;
36
75
  const apiKey = cliApiKey || process.env.DELENTIA_API_KEY || process.env.ZUPLO_API_KEY || "";
37
76
  const internalSecret = process.env.DELENTIA_INTERNAL_SECRET || "";
77
+ const timeoutMs = Number(process.env.DELENTIA_TIMEOUT_MS) > 0 ? Number(process.env.DELENTIA_TIMEOUT_MS) : 60000;
78
+
79
+ let sessionId = "";
80
+
81
+ const send = (message) => process.stdout.write(JSON.stringify(message) + "\n");
82
+ const rpcError = (id, code, message) => send({ jsonrpc: "2.0", id: id ?? null, error: { code, message } });
83
+
84
+ /** Every JSON-RPC message in a `text/event-stream` body (one per `data:` event). */
85
+ function messagesFromEventStream(text) {
86
+ const out = [];
87
+ for (const block of text.split(/\r?\n\r?\n/)) {
88
+ const data = block
89
+ .split(/\r?\n/)
90
+ .filter((l) => l.startsWith("data:"))
91
+ .map((l) => l.slice(5).trimStart())
92
+ .join("\n");
93
+ if (!data) continue;
94
+ try {
95
+ out.push(JSON.parse(data));
96
+ } catch {
97
+ /* not JSON: ignore this event */
98
+ }
99
+ }
100
+ return out;
101
+ }
38
102
 
39
103
  const rl = readline.createInterface({
40
104
  input: process.stdin,
@@ -45,58 +109,74 @@ rl.on("line", async (line) => {
45
109
  const trimmed = line.trim();
46
110
  if (!trimmed) return;
47
111
 
112
+ let jsonRpcRequest;
48
113
  try {
49
- const jsonRpcRequest = JSON.parse(trimmed);
114
+ jsonRpcRequest = JSON.parse(trimmed);
115
+ } catch (err) {
116
+ rpcError(null, -32700, "Client Parse Error: " + (err?.message || "Unknown error"));
117
+ return;
118
+ }
50
119
 
120
+ try {
51
121
  const headers = {
52
122
  "Content-Type": "application/json",
53
- "User-Agent": "Delentia-MCP-CLI/2.0.0",
123
+ Accept: "application/json, text/event-stream",
124
+ "User-Agent": "Delentia-MCP-CLI/" + VERSION,
54
125
  };
55
-
56
- if (apiKey) {
57
- headers["Authorization"] = "Bearer " + apiKey;
58
- }
59
-
60
- if (internalSecret) {
61
- headers["X-Delentia-Internal-Secret"] = internalSecret;
62
- }
126
+ if (apiKey) headers["Authorization"] = "Bearer " + apiKey;
127
+ if (internalSecret) headers["X-Delentia-Internal-Secret"] = internalSecret;
128
+ if (sessionId) headers["Mcp-Session-Id"] = sessionId;
63
129
 
64
130
  const response = await fetch(targetEndpoint, {
65
131
  method: "POST",
66
132
  headers,
67
133
  body: JSON.stringify(jsonRpcRequest),
134
+ signal: AbortSignal.timeout(timeoutMs),
68
135
  });
69
136
 
137
+ const newSession = response.headers.get("mcp-session-id");
138
+ if (newSession) sessionId = newSession;
139
+
70
140
  // If the request was a notification (no id member), JSON-RPC 2.0 prohibits sending a response
71
141
  if (jsonRpcRequest.id === undefined) {
142
+ await response.arrayBuffer().catch(() => undefined);
72
143
  return;
73
144
  }
74
145
 
75
146
  if (!response.ok) {
76
147
  const errorText = await response.text();
77
- const errResponse = {
78
- jsonrpc: "2.0",
79
- id: jsonRpcRequest.id ?? null,
80
- error: {
81
- code: -32603,
82
- message: "Delentia Gateway returned status " + response.status + ": " + errorText,
83
- },
84
- };
85
- process.stdout.write(JSON.stringify(errResponse) + "\n");
148
+ // A JSON-RPC error body (the quota answer is one) keeps its own code; anything else becomes -32603.
149
+ try {
150
+ const body = JSON.parse(errorText);
151
+ if (body && body.error && typeof body.error.code === "number") {
152
+ send({ jsonrpc: "2.0", id: jsonRpcRequest.id ?? null, error: body.error });
153
+ return;
154
+ }
155
+ } catch {
156
+ /* not JSON */
157
+ }
158
+ rpcError(jsonRpcRequest.id, -32603, "Delentia Gateway returned status " + response.status + ": " + errorText.slice(0, 500));
159
+ return;
160
+ }
161
+
162
+ const contentType = response.headers.get("content-type") || "";
163
+ if (contentType.includes("text/event-stream")) {
164
+ const messages = messagesFromEventStream(await response.text());
165
+ if (!messages.length) {
166
+ rpcError(jsonRpcRequest.id, -32603, "Delentia Gateway sent an event stream with no JSON-RPC message in it");
167
+ return;
168
+ }
169
+ for (const m of messages) send(m);
86
170
  return;
87
171
  }
88
172
 
89
- const jsonRpcResponse = await response.json();
90
- process.stdout.write(JSON.stringify(jsonRpcResponse) + "\n");
173
+ send(await response.json());
91
174
  } catch (err) {
92
- const parseErrorResponse = {
93
- jsonrpc: "2.0",
94
- id: null,
95
- error: {
96
- code: -32700,
97
- message: "Client Parse Error: " + (err?.message || "Unknown error"),
98
- },
99
- };
100
- process.stdout.write(JSON.stringify(parseErrorResponse) + "\n");
175
+ const timedOut = err?.name === "TimeoutError" || err?.name === "AbortError";
176
+ rpcError(
177
+ jsonRpcRequest.id,
178
+ timedOut ? -32001 : -32603,
179
+ timedOut ? `Delentia Gateway did not answer within ${timeoutMs} ms` : "Delentia bridge error: " + (err?.message || "Unknown error")
180
+ );
101
181
  }
102
182
  });
package/package.json CHANGED
@@ -1,54 +1,55 @@
1
- {
2
- "name": "delentia-mcp",
3
- "version": "2.1.1",
4
- "mcpName": "io.github.delentia-labs/delentia-mcp",
5
- "description": "Stop rogue AI-agent tool calls before they run: deterministic policy gate with audit digest. Zero-config MCP connector for Claude, Cursor, and Windsurf.",
6
- "type": "module",
7
- "main": "bin/cli.js",
8
- "bin": {
9
- "delentia-mcp": "bin/cli.js"
10
- },
11
- "scripts": {
12
- "build": "echo Delentia build ready",
13
- "start": "node bin/cli.js"
14
- },
15
- "files": [
16
- "bin",
17
- "dist",
18
- "assets",
19
- "README.md",
20
- "LICENSE",
21
- "server.json"
22
- ],
23
- "publishConfig": {
24
- "access": "public"
25
- },
26
- "keywords": [
27
- "mcp",
28
- "model-context-protocol",
29
- "prompt-injection",
30
- "tool-call-guardrail",
31
- "token-optimizer",
32
- "cursor",
33
- "claude-desktop",
34
- "windsurf",
35
- "agent-security",
36
- "agent-guardrails",
37
- "cybersecurity",
38
- "ai-safety",
39
- "reasoning",
40
- "context-compression",
41
- "multi-agent-systems",
42
- "sovereign-ai"
43
- ],
44
- "author": "Ittirit Saengow (Chief Architect) - Delentia Labs",
45
- "license": "Apache-2.0",
46
- "homepage": "https://delentia.com",
47
- "repository": {
48
- "type": "git",
49
- "url": "git+https://github.com/delentia-labs/delentia-mcp.git"
50
- },
51
- "bugs": {
52
- "url": "https://github.com/delentia-labs/delentia-mcp/issues"
53
- }
54
- }
1
+ {
2
+ "name": "delentia-mcp",
3
+ "version": "2.1.2",
4
+ "mcpName": "io.github.delentia-labs/delentia-mcp",
5
+ "description": "Advisory MCP tools for Claude, Cursor and Windsurf: policy score, reasoning checklist, context compression (stdio bridge to a hosted endpoint). To enforce a policy on every tool call use delentia-guard.",
6
+ "type": "module",
7
+ "main": "bin/cli.js",
8
+ "bin": {
9
+ "delentia-mcp": "bin/cli.js"
10
+ },
11
+ "scripts": {
12
+ "build": "echo Delentia build ready",
13
+ "start": "node bin/cli.js",
14
+ "test": "node --test test/*.test.mjs"
15
+ },
16
+ "files": [
17
+ "bin",
18
+ "dist",
19
+ "assets",
20
+ "README.md",
21
+ "LICENSE",
22
+ "server.json"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "keywords": [
28
+ "mcp",
29
+ "model-context-protocol",
30
+ "prompt-injection",
31
+ "tool-call-guardrail",
32
+ "token-optimizer",
33
+ "cursor",
34
+ "claude-desktop",
35
+ "windsurf",
36
+ "agent-security",
37
+ "agent-guardrails",
38
+ "cybersecurity",
39
+ "ai-safety",
40
+ "reasoning",
41
+ "context-compression",
42
+ "multi-agent-systems",
43
+ "sovereign-ai"
44
+ ],
45
+ "author": "Ittirit Saengow (Chief Architect) - Delentia Labs",
46
+ "license": "Apache-2.0",
47
+ "homepage": "https://delentia.com",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/delentia-labs/delentia-mcp.git"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/delentia-labs/delentia-mcp/issues"
54
+ }
55
+ }
package/server.json CHANGED
@@ -1,21 +1,21 @@
1
- {
2
- "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
- "name": "io.github.delentia-labs/delentia-mcp",
4
- "title": "Delentia Sovereign AI Operating System",
5
- "description": "Stop rogue AI-agent tool calls before they run: deterministic policy gate + audit digest.",
6
- "repository": {
7
- "url": "https://github.com/delentia-labs/delentia-mcp",
8
- "source": "github"
9
- },
10
- "version": "2.1.1",
11
- "packages": [
12
- {
13
- "registryType": "npm",
14
- "identifier": "delentia-mcp",
15
- "version": "2.1.1",
16
- "transport": {
17
- "type": "stdio"
18
- }
19
- }
20
- ]
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.delentia-labs/delentia-mcp",
4
+ "title": "Delentia Sovereign AI Operating System",
5
+ "description": "Advisory MCP tools for Claude, Cursor and Windsurf: policy score, reasoning checklist, context compression (stdio bridge to a hosted endpoint). To enforce a policy on every tool call use delentia-guard.",
6
+ "repository": {
7
+ "url": "https://github.com/delentia-labs/delentia-mcp",
8
+ "source": "github"
9
+ },
10
+ "version": "2.1.2",
11
+ "packages": [
12
+ {
13
+ "registryType": "npm",
14
+ "identifier": "delentia-mcp",
15
+ "version": "2.1.2",
16
+ "transport": {
17
+ "type": "stdio"
18
+ }
19
+ }
20
+ ]
21
21
  }