@axtary/mcp 0.0.1 → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  MCP tool provenance helpers for Axtary's local runtime plane.
4
4
 
5
+ Early `0.x` release: the runtime path is real and tested, but the API is not stable yet and may change between minor versions.
6
+
7
+ ```bash
8
+ npm install @axtary/mcp
9
+ ```
10
+
5
11
  This package keeps transport execution behind Axtary's policy and ledger path. It normalizes MCP tool definitions and calls into Axtary actions, then provides local JSON-RPC HTTP/stdio invokers and fixture handlers that execute only after the proxy has evaluated policy, issued an ActionPass, written the ledger, and rechecked the tool definition hash.
6
12
 
7
13
  ## What It Does
@@ -10,11 +16,59 @@ This package keeps transport execution behind Axtary's policy and ledger path. I
10
16
  - Computes deterministic `sha256:` definition hashes.
11
17
  - Creates `mcp.tool.call` normalized Axtary actions with `toolDefinition` provenance.
12
18
  - Wraps MCP-style tool invokers as Axtary proxy handlers.
13
- - Calls local MCP-compatible HTTP endpoints with JSON-RPC `tools/call` requests.
14
- - Calls local stdio MCP-style processes with one JSON-RPC request per invocation.
19
+ - Connects to upstream MCP servers over **stdio** (`McpStdioClient`) or the **Streamable HTTP** transport (`McpHttpClient`, spec 2025-06-18: session id + protocol-version headers, `application/json` or SSE responses) behind one transport-agnostic `McpUpstreamClient` interface.
20
+ - Refuses cleartext `http://` to non-loopback hosts (`assertSafeMcpUrl`) so upstream credentials are never sent in the clear.
15
21
  - Provides fixture-backed handlers for deterministic demos and tests.
16
22
  - Fails closed if the action's tool name, server identity, schema version, or definition hash no longer matches the registered tool.
23
+ - Persists reviewed definition hashes to a pin manifest (`axtary.mcp_pins.v1`, upgraded in place from `v0`) and reconciles a server's *current* definitions against it (`reconcileMcpPins`), so drift **between sessions** is detected — `pinned` / `new` / `drifted` — not just within one run.
24
+ - Optionally verifies **signed, versioned tool definitions** (`axtary.mcp_signed_definition.v1`): a publisher signs the exact `definitionHash`, a semantic version, the required scopes, and a `priorDefinitionHash` link to the version it supersedes, using ES256/JOSE. Unsigned, mis-signed, unknown-key, or altered definitions fail closed **before invoke** via `createSignedMcpToolHandler`. See `spec/mcp-tool-provenance-v1.md`.
25
+ - Evaluates the **version chain** (`evaluateMcpVersionChain`): a new signed version is `continuous` only if it references the pinned version's hash and bumps its semver; otherwise it is surfaced as `broken_chain` or `version_not_incremented` (rug-pull defense), never silently accepted.
26
+ - Binds verified publisher provenance (`publisher` / `publisherKeyId` / `semver` / `priorDefinitionHash`) into the normalized action's `toolDefinition`, so it rides into the ActionPass and the ledger and is independently verifiable from the ledger alone. These fields are optional: a hash-only tool produces a byte-identical `toolDefinition` to before.
27
+ - Persists verifier-side publisher trust as public-only, `0600` JSON
28
+ (`saveMcpPublisherTrustStore`) and loads a signed-definition registry mapping
29
+ `(serverIdentity, toolName)` to an expected publisher and compact JWS. The
30
+ operator CLI consumes these primitives; signatures never use trust on first
31
+ use.
32
+ - Defines a secret-free live conformance receipt/registry (`axtary.mcp_conformance_receipt.v0`) for per-server proof: pinned tools, governed call digest, ActionPass v1/DPoP ledger evidence, labeled synthetic drift quarantine, and verified signed attestation.
33
+
34
+ ## Quickstart
35
+
36
+ This example runs as-is with Node 20+:
37
+
38
+ ```ts
39
+ import { createMcpToolDefinition, createMcpAction } from "@axtary/mcp";
40
+
41
+ // Pin the tool definition: server identity, schema version, name, description,
42
+ // and input schema all hash together into one definition hash.
43
+ const definition = createMcpToolDefinition({
44
+ serverIdentity: "mcp://internal/payments",
45
+ schemaVersion: "2026-03-26",
46
+ name: "refund_customer",
47
+ description: "Issues a refund for an order.",
48
+ inputSchema: { type: "object", properties: { orderId: { type: "string" } } },
49
+ });
50
+ console.log(definition.definitionHash);
51
+
52
+ // Every call becomes a normalized action carrying that provenance, so a
53
+ // mutated tool definition (tool poisoning) breaks the hash and is denied.
54
+ const action = createMcpAction({
55
+ definition,
56
+ call: { toolName: "refund_customer", arguments: { orderId: "ord_123" } },
57
+ actor: {
58
+ agentId: "agent:claude-code",
59
+ humanOwner: "user:dev@example.com",
60
+ runtime: "claude-code",
61
+ tenant: "org:example",
62
+ },
63
+ intent: { taskId: "TASK-1", declaredGoal: "Refund duplicate charge" },
64
+ });
65
+ console.log(action.capability.tool, action.toolDefinition.definitionHash === definition.definitionHash);
66
+ ```
17
67
 
18
68
  ## Design Notes
19
69
 
20
- MCP tool poisoning and schema drift are runtime authorization problems, not just connection setup problems. Axtary records the tool definition hash in the action and checks it again at execution time, so a changed tool schema requires a fresh policy/approval path.
70
+ MCP tool poisoning and schema drift are runtime authorization problems, not just connection setup problems. Axtary records the tool definition hash in the action and checks it again at execution time, so a changed tool schema requires a fresh policy/approval path. The pin manifest makes that guarantee durable: a tool is trusted-on-first-use (or, in strict mode, only after explicit review), and any later change to its definition is quarantined until a human re-pins it — drift cannot be laundered by restarting the wrapper.
71
+
72
+ Conformance receipts are local evidence, not connection inventory. They never persist upstream headers or tool response content, and operator surfaces must treat old receipts as stale rather than implying continuous health.
73
+
74
+ Signed definitions add *publisher identity* on top of the content hash. The hash answers "did this definition change?"; the signature answers "did a publisher I trust attest to this exact version, and how does it relate to the last one I pinned?". This is the Axtary profile of the ETDI idea (arXiv:2506.01333), expressed on ES256/JOSE. Trust is exactly the publisher keys an operator configures — there is no trust-on-first-use for *signatures* (that stays at the human-reviewed pin layer). A signature attests to who published a definition and its version lineage; it does not prove the tool is safe and does not detect prompt injection.
@@ -0,0 +1,150 @@
1
+ import { z } from "zod";
2
+ export declare const MCP_CONFORMANCE_REGISTRY_VERSION = "axtary.mcp_conformance_registry.v0";
3
+ export declare const MCP_CONFORMANCE_RECEIPT_VERSION = "axtary.mcp_conformance_receipt.v0";
4
+ export declare const McpConformanceReceiptSchema: z.ZodObject<{
5
+ schemaVersion: z.ZodLiteral<"axtary.mcp_conformance_receipt.v0">;
6
+ receiptId: z.ZodString;
7
+ checkedAt: z.ZodString;
8
+ source: z.ZodLiteral<"live">;
9
+ target: z.ZodObject<{
10
+ transport: z.ZodEnum<{
11
+ stdio: "stdio";
12
+ "streamable-http": "streamable-http";
13
+ }>;
14
+ endpoint: z.ZodNullable<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ server: z.ZodObject<{
17
+ identity: z.ZodString;
18
+ version: z.ZodString;
19
+ protocolVersion: z.ZodString;
20
+ }, z.core.$strip>;
21
+ tools: z.ZodArray<z.ZodObject<{
22
+ name: z.ZodString;
23
+ definitionHash: z.ZodString;
24
+ pinStatus: z.ZodLiteral<"pinned">;
25
+ publisherEvidence: z.ZodOptional<z.ZodObject<{
26
+ trust: z.ZodEnum<{
27
+ verified: "verified";
28
+ unsigned: "unsigned";
29
+ untrusted: "untrusted";
30
+ invalid: "invalid";
31
+ }>;
32
+ publisher: z.ZodNullable<z.ZodString>;
33
+ kid: z.ZodNullable<z.ZodString>;
34
+ semver: z.ZodNullable<z.ZodString>;
35
+ priorDefinitionHash: z.ZodNullable<z.ZodString>;
36
+ chainVerdict: z.ZodNullable<z.ZodEnum<{
37
+ first_pin: "first_pin";
38
+ unchanged: "unchanged";
39
+ continuous: "continuous";
40
+ version_not_incremented: "version_not_incremented";
41
+ broken_chain: "broken_chain";
42
+ }>>;
43
+ reason: z.ZodNullable<z.ZodString>;
44
+ }, z.core.$strip>>;
45
+ }, z.core.$strip>>;
46
+ governedCall: z.ZodObject<{
47
+ toolName: z.ZodString;
48
+ succeeded: z.ZodLiteral<true>;
49
+ responseDigest: z.ZodString;
50
+ }, z.core.$strip>;
51
+ authorization: z.ZodObject<{
52
+ actionPassProfile: z.ZodLiteral<"axtary.actionpass.v1">;
53
+ dpopRequired: z.ZodLiteral<true>;
54
+ policyDecision: z.ZodLiteral<"allow">;
55
+ ledgerValid: z.ZodLiteral<true>;
56
+ appendedRecords: z.ZodNumber;
57
+ lastLedgerHash: z.ZodString;
58
+ }, z.core.$strip>;
59
+ driftProbe: z.ZodObject<{
60
+ kind: z.ZodLiteral<"synthetic_pin_mismatch">;
61
+ toolName: z.ZodString;
62
+ blocked: z.ZodLiteral<true>;
63
+ reason: z.ZodLiteral<"definition_drifted">;
64
+ }, z.core.$strip>;
65
+ attestation: z.ZodObject<{
66
+ valid: z.ZodLiteral<true>;
67
+ bundlePath: z.ZodString;
68
+ exportDigest: z.ZodString;
69
+ keyId: z.ZodString;
70
+ }, z.core.$strip>;
71
+ }, z.core.$strip>;
72
+ export type McpConformanceReceipt = z.infer<typeof McpConformanceReceiptSchema>;
73
+ export declare const McpConformanceRegistrySchema: z.ZodObject<{
74
+ schemaVersion: z.ZodLiteral<"axtary.mcp_conformance_registry.v0">;
75
+ receipts: z.ZodDefault<z.ZodArray<z.ZodObject<{
76
+ schemaVersion: z.ZodLiteral<"axtary.mcp_conformance_receipt.v0">;
77
+ receiptId: z.ZodString;
78
+ checkedAt: z.ZodString;
79
+ source: z.ZodLiteral<"live">;
80
+ target: z.ZodObject<{
81
+ transport: z.ZodEnum<{
82
+ stdio: "stdio";
83
+ "streamable-http": "streamable-http";
84
+ }>;
85
+ endpoint: z.ZodNullable<z.ZodString>;
86
+ }, z.core.$strip>;
87
+ server: z.ZodObject<{
88
+ identity: z.ZodString;
89
+ version: z.ZodString;
90
+ protocolVersion: z.ZodString;
91
+ }, z.core.$strip>;
92
+ tools: z.ZodArray<z.ZodObject<{
93
+ name: z.ZodString;
94
+ definitionHash: z.ZodString;
95
+ pinStatus: z.ZodLiteral<"pinned">;
96
+ publisherEvidence: z.ZodOptional<z.ZodObject<{
97
+ trust: z.ZodEnum<{
98
+ verified: "verified";
99
+ unsigned: "unsigned";
100
+ untrusted: "untrusted";
101
+ invalid: "invalid";
102
+ }>;
103
+ publisher: z.ZodNullable<z.ZodString>;
104
+ kid: z.ZodNullable<z.ZodString>;
105
+ semver: z.ZodNullable<z.ZodString>;
106
+ priorDefinitionHash: z.ZodNullable<z.ZodString>;
107
+ chainVerdict: z.ZodNullable<z.ZodEnum<{
108
+ first_pin: "first_pin";
109
+ unchanged: "unchanged";
110
+ continuous: "continuous";
111
+ version_not_incremented: "version_not_incremented";
112
+ broken_chain: "broken_chain";
113
+ }>>;
114
+ reason: z.ZodNullable<z.ZodString>;
115
+ }, z.core.$strip>>;
116
+ }, z.core.$strip>>;
117
+ governedCall: z.ZodObject<{
118
+ toolName: z.ZodString;
119
+ succeeded: z.ZodLiteral<true>;
120
+ responseDigest: z.ZodString;
121
+ }, z.core.$strip>;
122
+ authorization: z.ZodObject<{
123
+ actionPassProfile: z.ZodLiteral<"axtary.actionpass.v1">;
124
+ dpopRequired: z.ZodLiteral<true>;
125
+ policyDecision: z.ZodLiteral<"allow">;
126
+ ledgerValid: z.ZodLiteral<true>;
127
+ appendedRecords: z.ZodNumber;
128
+ lastLedgerHash: z.ZodString;
129
+ }, z.core.$strip>;
130
+ driftProbe: z.ZodObject<{
131
+ kind: z.ZodLiteral<"synthetic_pin_mismatch">;
132
+ toolName: z.ZodString;
133
+ blocked: z.ZodLiteral<true>;
134
+ reason: z.ZodLiteral<"definition_drifted">;
135
+ }, z.core.$strip>;
136
+ attestation: z.ZodObject<{
137
+ valid: z.ZodLiteral<true>;
138
+ bundlePath: z.ZodString;
139
+ exportDigest: z.ZodString;
140
+ keyId: z.ZodString;
141
+ }, z.core.$strip>;
142
+ }, z.core.$strip>>>;
143
+ }, z.core.$strip>;
144
+ export type McpConformanceRegistry = z.infer<typeof McpConformanceRegistrySchema>;
145
+ export declare function emptyMcpConformanceRegistry(): McpConformanceRegistry;
146
+ export declare function parseMcpConformanceRegistry(input: unknown): McpConformanceRegistry;
147
+ export declare function loadMcpConformanceRegistry(path: string): Promise<McpConformanceRegistry>;
148
+ export declare function saveMcpConformanceRegistry(path: string, registry: McpConformanceRegistry): Promise<void>;
149
+ export declare function upsertMcpConformanceReceipt(registry: McpConformanceRegistry, receiptInput: McpConformanceReceipt): McpConformanceRegistry;
150
+ //# sourceMappingURL=conformance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gCAAgC,uCACP,CAAC;AACvC,eAAO,MAAM,+BAA+B,sCACP,CAAC;AAqBtC,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+CtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CACzC,OAAO,2BAA2B,CACnC,CAAC;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGvC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,sBAAsB,CAKpE;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,sBAAsB,CAExB;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,sBAAsB,CAAC,CAcjC;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,sBAAsB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,sBAAsB,EAChC,YAAY,EAAE,qBAAqB,GAClC,sBAAsB,CAaxB"}
@@ -0,0 +1,131 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { dirname } from "node:path";
3
+ import { z } from "zod";
4
+ export const MCP_CONFORMANCE_REGISTRY_VERSION = "axtary.mcp_conformance_registry.v0";
5
+ export const MCP_CONFORMANCE_RECEIPT_VERSION = "axtary.mcp_conformance_receipt.v0";
6
+ const DefinitionHashSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
7
+ const PublisherEvidenceSchema = z.object({
8
+ trust: z.enum(["verified", "unsigned", "untrusted", "invalid"]),
9
+ publisher: z.string().min(1).nullable(),
10
+ kid: z.string().min(1).nullable(),
11
+ semver: z.string().min(1).nullable(),
12
+ priorDefinitionHash: DefinitionHashSchema.nullable(),
13
+ chainVerdict: z
14
+ .enum([
15
+ "first_pin",
16
+ "unchanged",
17
+ "continuous",
18
+ "version_not_incremented",
19
+ "broken_chain",
20
+ ])
21
+ .nullable(),
22
+ reason: z.string().min(1).nullable(),
23
+ });
24
+ export const McpConformanceReceiptSchema = z.object({
25
+ schemaVersion: z.literal(MCP_CONFORMANCE_RECEIPT_VERSION),
26
+ receiptId: z.string().min(1),
27
+ checkedAt: z.string().datetime(),
28
+ source: z.literal("live"),
29
+ target: z.object({
30
+ transport: z.enum(["stdio", "streamable-http"]),
31
+ endpoint: z.string().url().nullable(),
32
+ }),
33
+ server: z.object({
34
+ identity: z.string().min(1),
35
+ version: z.string().min(1),
36
+ protocolVersion: z.string().min(1),
37
+ }),
38
+ tools: z.array(z.object({
39
+ name: z.string().min(1),
40
+ definitionHash: DefinitionHashSchema,
41
+ pinStatus: z.literal("pinned"),
42
+ publisherEvidence: PublisherEvidenceSchema.optional(),
43
+ })),
44
+ governedCall: z.object({
45
+ toolName: z.string().min(1),
46
+ succeeded: z.literal(true),
47
+ responseDigest: DefinitionHashSchema,
48
+ }),
49
+ authorization: z.object({
50
+ actionPassProfile: z.literal("axtary.actionpass.v1"),
51
+ dpopRequired: z.literal(true),
52
+ policyDecision: z.literal("allow"),
53
+ ledgerValid: z.literal(true),
54
+ appendedRecords: z.number().int().positive(),
55
+ lastLedgerHash: DefinitionHashSchema,
56
+ }),
57
+ driftProbe: z.object({
58
+ kind: z.literal("synthetic_pin_mismatch"),
59
+ toolName: z.string().min(1),
60
+ blocked: z.literal(true),
61
+ reason: z.literal("definition_drifted"),
62
+ }),
63
+ attestation: z.object({
64
+ valid: z.literal(true),
65
+ bundlePath: z.string().min(1),
66
+ exportDigest: DefinitionHashSchema,
67
+ keyId: z.string().min(1),
68
+ }),
69
+ });
70
+ export const McpConformanceRegistrySchema = z.object({
71
+ schemaVersion: z.literal(MCP_CONFORMANCE_REGISTRY_VERSION),
72
+ receipts: z.array(McpConformanceReceiptSchema).default([]),
73
+ });
74
+ export function emptyMcpConformanceRegistry() {
75
+ return {
76
+ schemaVersion: MCP_CONFORMANCE_REGISTRY_VERSION,
77
+ receipts: [],
78
+ };
79
+ }
80
+ export function parseMcpConformanceRegistry(input) {
81
+ return McpConformanceRegistrySchema.parse(input);
82
+ }
83
+ export async function loadMcpConformanceRegistry(path) {
84
+ let raw;
85
+ try {
86
+ raw = await readFile(path, "utf8");
87
+ }
88
+ catch (error) {
89
+ if (error.code === "ENOENT") {
90
+ return emptyMcpConformanceRegistry();
91
+ }
92
+ throw error;
93
+ }
94
+ return parseMcpConformanceRegistry(JSON.parse(raw));
95
+ }
96
+ export async function saveMcpConformanceRegistry(path, registry) {
97
+ await mkdir(dirname(path), { recursive: true });
98
+ await writeFile(path, `${JSON.stringify(normalizeRegistry(registry), null, 2)}\n`, {
99
+ encoding: "utf8",
100
+ mode: 0o600,
101
+ });
102
+ }
103
+ export function upsertMcpConformanceReceipt(registry, receiptInput) {
104
+ const receipt = McpConformanceReceiptSchema.parse(receiptInput);
105
+ const targetKey = receiptTargetKey(receipt);
106
+ const receipts = registry.receipts.filter((entry) => receiptTargetKey(entry) !== targetKey);
107
+ receipts.push(receipt);
108
+ return normalizeRegistry({
109
+ schemaVersion: MCP_CONFORMANCE_REGISTRY_VERSION,
110
+ receipts,
111
+ });
112
+ }
113
+ function receiptTargetKey(receipt) {
114
+ return [
115
+ receipt.server.identity,
116
+ receipt.target.transport,
117
+ receipt.target.endpoint ?? "stdio",
118
+ ].join(" ");
119
+ }
120
+ function normalizeRegistry(registry) {
121
+ return McpConformanceRegistrySchema.parse({
122
+ schemaVersion: MCP_CONFORMANCE_REGISTRY_VERSION,
123
+ receipts: [...registry.receipts].sort((left, right) => {
124
+ const identity = left.server.identity.localeCompare(right.server.identity);
125
+ if (identity !== 0)
126
+ return identity;
127
+ return left.checkedAt.localeCompare(right.checkedAt);
128
+ }),
129
+ });
130
+ }
131
+ //# sourceMappingURL=conformance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance.js","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,gCAAgC,GAC3C,oCAAoC,CAAC;AACvC,MAAM,CAAC,MAAM,+BAA+B,GAC1C,mCAAmC,CAAC;AAEtC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;AACvE,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAC/D,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACvC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,mBAAmB,EAAE,oBAAoB,CAAC,QAAQ,EAAE;IACpD,YAAY,EAAE,CAAC;SACZ,IA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