apex-psi-mcp 1.1.0 → 1.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.
package/README.md CHANGED
@@ -1,24 +1,25 @@
1
- # APEX PSI MCP Server
1
+ # APEX PSI MCP server
2
2
 
3
- > **Apex PSI is not a tool and not a product. It is the verification substrate — the layer beneath proof. It does not judge. It does not certify. It only remembers.** This server is an application built on that layer.
3
+ > **Apex PSI is not a tool and not a product. It is the verification substrate — the layer beneath proof. It does not judge. It does not certify. It only remembers.** This server is one application built on that layer.
4
4
 
5
- Cryptographic truth infrastructure for AI agents.
5
+ One config line gives any MCP-capable agent (Claude, Cursor, Qoder, Cline, Windsurf, and the rest) five evidence tools: `seal`, `verify`, `anchor`, `cite`, `verify_chain`.
6
6
 
7
- One config line gives any MCP-capable AI agent (Claude, Cursor, Qoder, Cline, Windsurf, and more) five provenance tools: seal, verify, anchor, cite, verify_chain.
7
+ A seal records the SHA-256 hash of a decision, document or artefact in a public append-only ledger and returns a receipt. Anyone can look that hash up again — free, forever, with no account, no key and no cooperation from us.
8
8
 
9
- This server proves the existence and integrity of a record at a point in time. It does not judge the truth of a record's contents. It is an independent verification service, not advice.
9
+ **What a receipt proves:** that this exact content existed at this timestamp, and has not changed since.
10
+ **What it never proves:** that the content is true. A seal is an audit trail, not a verdict.
10
11
 
11
12
  ## Tools
12
13
 
13
- | Tool | Description |
14
+ | Tool | What it actually does |
14
15
  |------|-------------|
15
- | **seal** | Stamp a cryptographic receipt on content (SHA-256 + Ed25519 + post-quantum LMS-W4) |
16
- | **verify** | Confirm a receipt's integrity (hash present in the append-only ledger) |
17
- | **anchor** | Read Bitcoin anchoring status (default), or request anchoring of pending roots |
18
- | **cite** | Generate a citation for a receipt (APA, BibTeX, MLA) |
19
- | **verify_chain** | Independently verify a chain of receipts for integrity |
16
+ | **seal** | Writes the record's SHA-256 hash to the ledger and returns a receipt carrying an Ed25519 signature over the Merkle leaf, an ML-DSA-65 post-quantum signature, and — when a slot is available — an LMS-W4-SHA256 signature. The receipt's own `algorithm` field states which of those it got. |
17
+ | **verify** | Looks a hash (or a whole receipt) up in the ledger and reports whether it is present and unchanged. Integrity, not truth. |
18
+ | **anchor** | Reads the Bitcoin/OpenTimestamps anchoring state of the ledger's pending Merkle roots. Pass `action: "anchor"` explicitly to request that pending roots be submitted — an anchor is confirmed only when a real block is found. |
19
+ | **cite** | Turns a receipt into a citation (APA, BibTeX, MLA) that points at a public, independently checkable record. |
20
+ | **verify_chain** | Recomputes each hash's presence and Merkle continuity across a chain of receipts. A recomputation result, not an opinion. |
20
21
 
21
- ## Installation
22
+ ## Install
22
23
 
23
24
  Add to your MCP client config:
24
25
 
@@ -33,41 +34,50 @@ Add to your MCP client config:
33
34
  }
34
35
  ```
35
36
 
36
- Or install locally:
37
+ Or locally: `npm install apex-psi-mcp`.
37
38
 
38
- ```bash
39
- npm install apex-psi-mcp
40
- ```
39
+ ## Prove it works in two minutes
41
40
 
42
- ## Configuration
41
+ 1. Ask the agent: *"Seal the sentence 'hello psi' with APEX PSI."*
42
+ 2. Take the `decision_hash` from the receipt and paste it into the public verifier:
43
+ <https://www.ai-governance-standard.com/verify>
43
44
 
44
- Environment variables (optional):
45
+ If the site returns the record, the seal is real. You never had to trust this server, our npm
46
+ package, or our word — which is the entire point of the protocol.
45
47
 
46
- - `APEX_API_BASE` — API endpoint (default: `https://qhtntebpcribjiwrdtdd.supabase.co/functions/v1`)
47
- - `APEX_API_KEY` — API key for authenticated access
48
+ ## Limits, stated plainly
48
49
 
49
- ## Usage
50
+ Free use needs no account and no key: **20 operations per minute and 100 per day**, enforced per
51
+ server instance — a flood guard rather than a subscription quota. Above that, an API key raises the
52
+ ceiling; capacity is priced, **the finding never is**. Verification itself is unlimited and free:
53
+ running the verifier locally costs nothing at all —
54
+ [`apex-psi-verifier`](https://www.npmjs.com/package/apex-psi-verifier) on npm,
55
+ [`psi-verifier`](https://pypi.org/project/psi-verifier/) on PyPI.
56
+
57
+ ## Configuration
50
58
 
51
- Once installed, your AI agent can:
59
+ Environment variables (both optional):
52
60
 
53
- 1. **Seal content** — "Seal this document with APEX PSI"
54
- 2. **Verify receipts** — "Verify this receipt against the ledger"
55
- 3. **Check anchoring** — "What is the Bitcoin anchor status of this seal?"
56
- 4. **Generate citations** — "Cite this receipt in APA format"
57
- 5. **Verify a chain** — "Independently verify this chain of receipts"
61
+ - `APEX_API_BASE` — override the notary endpoint. Default:
62
+ `https://qhtntebpcribjiwrdtdd.supabase.co/functions/v1`
63
+ - `APEX_API_KEY` — raises the daily ceiling for a workload. Never required to seal or verify.
58
64
 
59
- Every receipt carries a verify link to `https://ai-governance-standard.com/verify` — sealed arithmetic, public provenance.
65
+ ## What this server does not do
66
+
67
+ - It does not store your content. Only the hash leaves your machine.
68
+ - It does not certify, grade, score or approve anything.
69
+ - It exposes no edit or delete path: the interface this server uses is write-once sealing plus
70
+ read-only lookup. The check that matters is yours to run — re-verify any receipt at any time, and
71
+ any change shows up as a failed lookup.
72
+ - It is not a legal opinion, and no court has agreed to accept a receipt in advance.
60
73
 
61
74
  ## Links
62
75
 
63
- - **Website:** https://ai-governance-standard.com
64
- - **Public Verifier:** https://ai-governance-standard.com/verify
65
- - **npm:** https://www.npmjs.com/package/apex-psi-mcp
76
+ - **Protocol and standard:** <https://www.ai-governance-standard.com>
77
+ - **Public verifier:** <https://www.ai-governance-standard.com/verify>
78
+ - **Machine-readable summary for AI answers:** <https://www.ai-governance-standard.com/llms.txt>
79
+ - **npm:** <https://www.npmjs.com/package/apex-psi-mcp>
66
80
 
67
81
  ## License
68
82
 
69
83
  MIT
70
-
71
- ## Limits
72
-
73
- Free hosted allowance: 20 receipts/minute, 100/day. Offline verification is always free (`npm i apex-psi-verifier`). Higher volume: https://ai-governance-standard.com/upgrade
package/dist/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * APEX PSI MCP Server
4
- * Cryptographic truth infrastructure for AI agents.
4
+ * Append-only evidence receipts for AI agents and auditors.
5
5
  *
6
6
  * 5 tools: seal, verify, anchor, cite, verify_chain
7
- * Backend: APEX NOTARY v1.0 (Supabase Edge Functions) — SHA-256 + Ed25519 + LMS-W4-SHA256 (post-quantum)
7
+ * Backend: APEX NOTARY (Supabase Edge Functions) — SHA-256, Ed25519 over the Merkle
8
+ * leaf, ML-DSA-65, and LMS-W4-SHA256 when a slot is available. Each receipt states in
9
+ * its own `algorithm` field which signatures it actually carries.
8
10
  * Override base URL with APEX_API_BASE if self-hosting.
9
11
  *
10
- * Scope: this server anchors the existence and integrity of a record at a point
11
- * in time. It does not judge the truth of a record's contents. It is an
12
- * independent verification service, not advice or an attestable opinion.
12
+ * Scope: this server records the existence and integrity of a record at a point in
13
+ * time. It does not judge the truth of a record's contents. It is an independent
14
+ * verification service, not advice or an attestable opinion.
13
15
  */
14
16
  export {};
package/dist/index.js CHANGED
@@ -1,15 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * APEX PSI MCP Server
4
- * Cryptographic truth infrastructure for AI agents.
4
+ * Append-only evidence receipts for AI agents and auditors.
5
5
  *
6
6
  * 5 tools: seal, verify, anchor, cite, verify_chain
7
- * Backend: APEX NOTARY v1.0 (Supabase Edge Functions) — SHA-256 + Ed25519 + LMS-W4-SHA256 (post-quantum)
7
+ * Backend: APEX NOTARY (Supabase Edge Functions) — SHA-256, Ed25519 over the Merkle
8
+ * leaf, ML-DSA-65, and LMS-W4-SHA256 when a slot is available. Each receipt states in
9
+ * its own `algorithm` field which signatures it actually carries.
8
10
  * Override base URL with APEX_API_BASE if self-hosting.
9
11
  *
10
- * Scope: this server anchors the existence and integrity of a record at a point
11
- * in time. It does not judge the truth of a record's contents. It is an
12
- * independent verification service, not advice or an attestable opinion.
12
+ * Scope: this server records the existence and integrity of a record at a point in
13
+ * time. It does not judge the truth of a record's contents. It is an independent
14
+ * verification service, not advice or an attestable opinion.
13
15
  */
14
16
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
15
17
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -17,7 +19,10 @@ import { z } from "zod";
17
19
  // Configuration
18
20
  const APEX_API_BASE = (process.env.APEX_API_BASE || "https://qhtntebpcribjiwrdtdd.supabase.co/functions/v1").replace(/\/$/, "");
19
21
  const APEX_API_KEY = process.env.APEX_API_KEY || "";
20
- const VERSION = "1.1.0";
22
+ // Human-facing site. The API host is a Supabase function and is not a page a
23
+ // person can open, so every link handed back to a user points here instead.
24
+ const APEX_SITE_BASE = (process.env.APEX_SITE_BASE || "https://www.ai-governance-standard.com").replace(/\/$/, "");
25
+ const VERSION = "1.1.2";
21
26
  // Helper: make an API call to the Apex PSI backend
22
27
  async function apexApiCall(endpoint, method = "GET", body) {
23
28
  const url = `${APEX_API_BASE}${endpoint}`;
@@ -30,9 +35,6 @@ async function apexApiCall(endpoint, method = "GET", body) {
30
35
  body: body !== undefined ? JSON.stringify(body) : undefined,
31
36
  });
32
37
  if (!response.ok) {
33
- if (response.status === 429) {
34
- throw new Error("APEX PSI free allowance reached (20/min, 100/day). For higher volume: https://ai-governance-standard.com/upgrade");
35
- }
36
38
  let detail = "";
37
39
  try {
38
40
  detail = (await response.text()).slice(0, 300);
@@ -48,6 +50,36 @@ async function apexApiCall(endpoint, method = "GET", body) {
48
50
  function stripHashPrefix(value) {
49
51
  return typeof value === "string" ? value.replace(/^sha256:/i, "") : "";
50
52
  }
53
+ /**
54
+ * Accept either a bare receipt or the whole envelope `seal` returns
55
+ * (`{ success, receipt, verify_hash, ... }`). The readers below once assumed a
56
+ * flat receipt, which meant a genuine seal piped straight back into verify,
57
+ * cite or verify_chain reported "chain broken" with an empty hash.
58
+ */
59
+ function asReceipt(value) {
60
+ if (!value || typeof value !== "object")
61
+ return {};
62
+ const obj = value;
63
+ const nested = obj.receipt;
64
+ if (obj.decision_hash === undefined && nested && typeof nested === "object" && !Array.isArray(nested)) {
65
+ return nested;
66
+ }
67
+ return obj;
68
+ }
69
+ // Helper: the hash a receipt stands for, from any of the fields the ledger uses
70
+ function receiptHash(value) {
71
+ const r = asReceipt(value);
72
+ const raw = r.decision_hash ?? r.merkle_leaf ?? r.merkle_root ?? r.verify_hash ?? r.hash;
73
+ const hash = stripHashPrefix(raw);
74
+ if (!hash) {
75
+ throw new Error("This receipt carries no hash (looked for decision_hash, merkle_leaf, merkle_root) — pass the object exactly as the seal tool returned it");
76
+ }
77
+ return hash;
78
+ }
79
+ // Helper: a link a person can open in a browser
80
+ function verifyPageUrl(hash) {
81
+ return `${APEX_SITE_BASE}/verify?hash=${encodeURIComponent(hash)}`;
82
+ }
51
83
  // Helper: wrap a result (or error) into an MCP text response
52
84
  function mcpResult(result) {
53
85
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
@@ -73,7 +105,7 @@ const server = new McpServer({
73
105
  // Tool: seal
74
106
  server.registerTool("seal", {
75
107
  title: "Seal content",
76
- description: "Stamp a cryptographic receipt on content. Writes to the APEX PSI append-only ledger with SHA-256 hash, Ed25519 signature, and post-quantum LMS-W4-SHA256 signature. Proves existence and integrity at a point in time — not the truth of the contents.",
108
+ description: "Record content in the APEX PSI append-only ledger and return a receipt: SHA-256 hash, an Ed25519 signature over the Merkle leaf, and post-quantum ML-DSA-65 (plus LMS-W4-SHA256 when a slot is available — the receipt's own algorithm field states which). Proves that this content existed and has not changed since the timestamp. It never proves the contents are true. Free tier: 20 operations/minute, 100/day, no account needed.",
77
109
  inputSchema: {
78
110
  content: z.string().max(10000).describe("The content to seal (text, up to 10000 characters)"),
79
111
  context: z.string().optional().describe("Optional context label (e.g. document name, case ID)"),
@@ -94,7 +126,8 @@ server.registerTool("seal", {
94
126
  receipt,
95
127
  receipt_id: receipt.receipt_id,
96
128
  verify_hash: decisionHash,
97
- verify_url: `${APEX_API_BASE}/verify-hash?hash=${decisionHash}`,
129
+ verify_url: verifyPageUrl(decisionHash),
130
+ verify_api_url: `${APEX_API_BASE}/verify-hash?hash=${decisionHash}`,
98
131
  message: "Content sealed in the APEX PSI append-only ledger",
99
132
  });
100
133
  }
@@ -115,17 +148,19 @@ server.registerTool("verify", {
115
148
  },
116
149
  }, async ({ hash, receipt }) => {
117
150
  try {
118
- let lookup = hash || "";
119
- if (!lookup && receipt) {
120
- lookup = stripHashPrefix(receipt.decision_hash ?? receipt.merkle_leaf ?? receipt.merkle_root);
151
+ let lookup = stripHashPrefix(hash);
152
+ if (!lookup && receipt !== undefined) {
153
+ lookup = receiptHash(receipt);
121
154
  }
122
155
  if (!lookup) {
123
156
  throw new Error("Provide either a hash or a receipt object");
124
157
  }
125
- const result = await apexApiCall(`/verify-hash?hash=${encodeURIComponent(stripHashPrefix(lookup))}`);
158
+ const result = await apexApiCall(`/verify-hash?hash=${encodeURIComponent(lookup)}`);
126
159
  return mcpResult({
127
160
  success: true,
161
+ hash: lookup,
128
162
  verification: result,
163
+ verify_url: verifyPageUrl(lookup),
129
164
  message: result.verified
130
165
  ? "Seal verified — hash is present in the APEX PSI append-only ledger"
131
166
  : "Hash not found in the ledger",
@@ -137,19 +172,27 @@ server.registerTool("verify", {
137
172
  });
138
173
  // Tool: anchor (status by default; explicit request to anchor pending roots)
139
174
  server.registerTool("anchor", {
140
- title: "Bitcoin anchoring status / request",
141
- description: "Read the Bitcoin (OpenTimestamps) anchoring state of the ledger's pending Merkle roots, or — only when action:'anchor' is passed explicitly — request that pending roots be aggregated and submitted to the OTS calendars. Defaults to 'status' (read-only) so a routine call never triggers a batch write. An anchor becomes confirmed only when a real Bitcoin block is found.",
175
+ title: "Bitcoin anchoring history",
176
+ description: "Read the Bitcoin (OpenTimestamps) anchoring record for the ledger's Merkle roots. Defaults to action:'history', which is read-only and returns each anchor transaction with its txid, block height, confirmation state and how many ledger entries it covers. Pass action:'verify' with a txid to check one transaction, or action:'anchor' to explicitly request that pending roots be aggregated and submitted to the OTS calendars. Defaults to 'history' so a routine call never triggers a batch write. An anchor counts as confirmed only when a real Bitcoin block contains it.",
142
177
  inputSchema: {
143
178
  action: z
144
- .enum(["anchor", "status"])
179
+ .enum(["history", "verify", "anchor"])
180
+ .optional()
181
+ .describe("'history' reads the anchored transactions (default); 'verify' checks one txid; 'anchor' explicitly requests anchoring of pending roots"),
182
+ txid: z
183
+ .string()
145
184
  .optional()
146
- .describe("'status' reads the anchor state (default); 'anchor' explicitly requests anchoring of pending roots"),
185
+ .describe("Bitcoin transaction id — required only when action is 'verify'"),
147
186
  },
148
- }, async ({ action }) => {
187
+ }, async ({ action, txid }) => {
149
188
  try {
150
- const resolved = action || "status";
189
+ const resolved = action || "history";
190
+ if (resolved === "verify" && !txid) {
191
+ return mcpError(new Error("action 'verify' needs a txid to check"));
192
+ }
151
193
  const result = await apexApiCall("/blockchain-anchor", "POST", {
152
194
  action: resolved,
195
+ ...(txid ? { txid } : {}),
153
196
  });
154
197
  return mcpResult({
155
198
  success: true,
@@ -157,7 +200,9 @@ server.registerTool("anchor", {
157
200
  action: resolved,
158
201
  message: resolved === "anchor"
159
202
  ? "Bitcoin anchoring requested for pending roots (OpenTimestamps); confirmation follows only on a real block"
160
- : "Bitcoin anchoring status read (OpenTimestamps)",
203
+ : resolved === "verify"
204
+ ? `Bitcoin transaction ${String(txid).slice(0, 16)}… checked against the anchor record`
205
+ : "Read the anchored Bitcoin transactions (OpenTimestamps)",
161
206
  });
162
207
  }
163
208
  catch (error) {
@@ -175,13 +220,18 @@ server.registerTool("cite", {
175
220
  }, async ({ receipt, format }) => {
176
221
  try {
177
222
  const fmt = format || "apa";
178
- const receiptId = String(receipt.receipt_id || "APEX-PSI-RECEIPT");
179
- const timestamp = String(receipt.timestamp || new Date().toISOString());
223
+ const r = asReceipt(receipt);
224
+ const receiptId = String(r.receipt_id || "APEX-PSI-RECEIPT");
225
+ const timestamp = String(r.timestamp || new Date().toISOString());
180
226
  const year = timestamp.slice(0, 4);
181
227
  const date = timestamp.slice(0, 10);
182
- const decisionHash = stripHashPrefix(receipt.decision_hash);
183
- const verifyUrl = `${APEX_API_BASE}/verify-hash?hash=${decisionHash}`;
184
- const algorithm = String(receipt.algorithm || "SHA-256 + Ed25519 + LMS-W4-SHA256");
228
+ const decisionHash = receiptHash(receipt);
229
+ const verifyUrl = verifyPageUrl(decisionHash);
230
+ // Only name algorithms the receipt itself names. The ledger attaches
231
+ // LMS-W4-SHA256 only when a slot is available, so a hard-coded default
232
+ // would cite signatures this particular receipt does not carry.
233
+ const stated = typeof r.algorithm === "string" ? r.algorithm.trim() : "";
234
+ const algorithm = stated || "algorithms not stated in this receipt";
185
235
  let citation;
186
236
  if (fmt === "bibtex") {
187
237
  citation = [
@@ -226,9 +276,12 @@ server.registerTool("verify_chain", {
226
276
  let previousRoot = "";
227
277
  let chainIntact = true;
228
278
  for (let i = 0; i < receipts.length; i++) {
229
- const r = receipts[i];
230
- const hash = stripHashPrefix(r.decision_hash ?? r.merkle_leaf ?? r.merkle_root);
231
- if (!hash) {
279
+ const r = asReceipt(receipts[i]);
280
+ let hash = "";
281
+ try {
282
+ hash = receiptHash(r);
283
+ }
284
+ catch {
232
285
  results.push({ index: i, receipt_id: String(r.receipt_id || "?"), verified: false, found: false, hash: "" });
233
286
  chainIntact = false;
234
287
  continue;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "apex-psi-mcp",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "mcpName": "io.github.kawal393/apex-psi-mcp",
5
- "description": "APEX PSI MCP Server - Cryptographic truth infrastructure for AI agents: seal, verify, anchor, cite, verify_chain",
5
+ "description": "APEX PSI MCP server - append-only evidence receipts for AI decisions and documents: seal a record, verify a hash against the public ledger, check a chain, cite a receipt, read Bitcoin anchoring status. Verification is free and needs no account.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "files": [
@@ -15,7 +15,9 @@
15
15
  "scripts": {
16
16
  "build": "tsc",
17
17
  "start": "node dist/index.js",
18
- "dev": "tsx src/index.ts"
18
+ "dev": "tsx src/index.ts",
19
+ "check:roundtrip": "node scripts/roundtrip-check.mjs",
20
+ "check:all": "npm run build && node scripts/roundtrip-check.mjs && node scripts/anchor-tool-check.mjs && node scripts/card-copy-check.mjs"
19
21
  },
20
22
  "keywords": [
21
23
  "mcp",
@@ -24,12 +26,23 @@
24
26
  "apex-psi",
25
27
  "cryptographic-verification",
26
28
  "provenance",
27
- "truth-infrastructure",
29
+ "evidence",
30
+ "audit-trail",
31
+ "record-integrity",
32
+ "tamper-evident",
33
+ "append-only-ledger",
34
+ "post-quantum",
35
+ "ai-governance",
36
+ "compliance",
28
37
  "ai-agents"
29
38
  ],
30
39
  "author": "APEX PSI",
31
40
  "license": "MIT",
32
- "homepage": "https://ai-governance-standard.com/mcp",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/kawal393/apex-psi-mcp-server.git"
44
+ },
45
+ "homepage": "https://www.ai-governance-standard.com/mcp",
33
46
  "dependencies": {
34
47
  "@modelcontextprotocol/sdk": "^1.12.0",
35
48
  "zod": "^3.23.8"
@@ -44,4 +57,4 @@
44
57
  "publishConfig": {
45
58
  "access": "public"
46
59
  }
47
- }
60
+ }