@attested-intelligence/aga-mcp-server 0.1.1 → 2.0.1

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 (197) hide show
  1. package/README.md +106 -24
  2. package/dist/context.d.ts +39 -0
  3. package/dist/context.d.ts.map +1 -0
  4. package/dist/context.js +113 -0
  5. package/dist/context.js.map +1 -0
  6. package/dist/core/identity.d.ts +14 -0
  7. package/dist/core/identity.d.ts.map +1 -0
  8. package/dist/core/identity.js +16 -0
  9. package/dist/core/identity.js.map +1 -0
  10. package/dist/core/index.d.ts +3 -0
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/index.js +3 -0
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/core/measurement.d.ts +16 -0
  15. package/dist/core/measurement.d.ts.map +1 -0
  16. package/dist/core/measurement.js +18 -0
  17. package/dist/core/measurement.js.map +1 -0
  18. package/dist/core/portal.d.ts +1 -1
  19. package/dist/core/portal.d.ts.map +1 -1
  20. package/dist/core/portal.js +10 -5
  21. package/dist/core/portal.js.map +1 -1
  22. package/dist/core/types.d.ts +2 -3
  23. package/dist/core/types.d.ts.map +1 -1
  24. package/dist/crypto/canonicalize.d.ts +7 -0
  25. package/dist/crypto/canonicalize.d.ts.map +1 -0
  26. package/dist/crypto/canonicalize.js +21 -0
  27. package/dist/crypto/canonicalize.js.map +1 -0
  28. package/dist/crypto/hash.d.ts +1 -1
  29. package/dist/crypto/hash.d.ts.map +1 -1
  30. package/dist/crypto/hash.js +1 -1
  31. package/dist/crypto/hash.js.map +1 -1
  32. package/dist/crypto/index.d.ts +6 -5
  33. package/dist/crypto/index.d.ts.map +1 -1
  34. package/dist/crypto/index.js +6 -5
  35. package/dist/crypto/index.js.map +1 -1
  36. package/dist/crypto/keys.d.ts +10 -0
  37. package/dist/crypto/keys.d.ts.map +1 -0
  38. package/dist/crypto/keys.js +19 -0
  39. package/dist/crypto/keys.js.map +1 -0
  40. package/dist/index.js +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/middleware/governance.d.ts +1 -7
  43. package/dist/middleware/governance.d.ts.map +1 -1
  44. package/dist/middleware/governance.js +11 -18
  45. package/dist/middleware/governance.js.map +1 -1
  46. package/dist/prompts/drift-analysis.d.ts +13 -0
  47. package/dist/prompts/drift-analysis.d.ts.map +1 -0
  48. package/dist/prompts/drift-analysis.js +43 -0
  49. package/dist/prompts/drift-analysis.js.map +1 -0
  50. package/dist/prompts/governance-report.d.ts +7 -0
  51. package/dist/prompts/governance-report.d.ts.map +1 -0
  52. package/dist/prompts/governance-report.js +26 -0
  53. package/dist/prompts/governance-report.js.map +1 -0
  54. package/dist/prompts/nccoe-demo.d.ts +14 -0
  55. package/dist/prompts/nccoe-demo.d.ts.map +1 -0
  56. package/dist/prompts/nccoe-demo.js +47 -0
  57. package/dist/prompts/nccoe-demo.js.map +1 -0
  58. package/dist/resources/cosai-mapping.d.ts +24 -0
  59. package/dist/resources/cosai-mapping.d.ts.map +1 -0
  60. package/dist/resources/cosai-mapping.js +127 -0
  61. package/dist/resources/cosai-mapping.js.map +1 -0
  62. package/dist/resources/crypto-primitives.d.ts +3 -0
  63. package/dist/resources/crypto-primitives.d.ts.map +1 -0
  64. package/dist/resources/crypto-primitives.js +52 -0
  65. package/dist/resources/crypto-primitives.js.map +1 -0
  66. package/dist/resources/sample-bundle.d.ts +6 -0
  67. package/dist/resources/sample-bundle.d.ts.map +1 -0
  68. package/dist/resources/sample-bundle.js +58 -0
  69. package/dist/resources/sample-bundle.js.map +1 -0
  70. package/dist/resources/specification.d.ts +3 -0
  71. package/dist/resources/specification.d.ts.map +1 -0
  72. package/dist/resources/specification.js +161 -0
  73. package/dist/resources/specification.js.map +1 -0
  74. package/dist/server.d.ts +3 -7
  75. package/dist/server.d.ts.map +1 -1
  76. package/dist/server.js +214 -343
  77. package/dist/server.js.map +1 -1
  78. package/dist/storage/sqlite.js +1 -1
  79. package/dist/tools/create-artifact.d.ts +25 -0
  80. package/dist/tools/create-artifact.d.ts.map +1 -0
  81. package/dist/tools/create-artifact.js +85 -0
  82. package/dist/tools/create-artifact.js.map +1 -0
  83. package/dist/tools/delegate-subagent.d.ts +18 -0
  84. package/dist/tools/delegate-subagent.d.ts.map +1 -0
  85. package/dist/tools/delegate-subagent.js +50 -0
  86. package/dist/tools/delegate-subagent.js.map +1 -0
  87. package/dist/tools/disclose-claim.d.ts +14 -0
  88. package/dist/tools/disclose-claim.d.ts.map +1 -0
  89. package/dist/tools/disclose-claim.js +23 -0
  90. package/dist/tools/disclose-claim.js.map +1 -0
  91. package/dist/tools/export-bundle.d.ts +8 -0
  92. package/dist/tools/export-bundle.d.ts.map +1 -0
  93. package/dist/tools/export-bundle.js +25 -0
  94. package/dist/tools/export-bundle.js.map +1 -0
  95. package/dist/tools/full-lifecycle.d.ts +16 -0
  96. package/dist/tools/full-lifecycle.d.ts.map +1 -0
  97. package/dist/tools/full-lifecycle.js +121 -0
  98. package/dist/tools/full-lifecycle.js.map +1 -0
  99. package/dist/tools/generate-receipt.d.ts +16 -0
  100. package/dist/tools/generate-receipt.d.ts.map +1 -0
  101. package/dist/tools/generate-receipt.js +31 -0
  102. package/dist/tools/generate-receipt.js.map +1 -0
  103. package/dist/tools/get-chain.d.ts +14 -0
  104. package/dist/tools/get-chain.d.ts.map +1 -0
  105. package/dist/tools/get-chain.js +45 -0
  106. package/dist/tools/get-chain.js.map +1 -0
  107. package/dist/tools/get-portal-state.d.ts +8 -0
  108. package/dist/tools/get-portal-state.d.ts.map +1 -0
  109. package/dist/tools/get-portal-state.js +15 -0
  110. package/dist/tools/get-portal-state.js.map +1 -0
  111. package/dist/tools/init-chain.d.ts +10 -0
  112. package/dist/tools/init-chain.d.ts.map +1 -0
  113. package/dist/tools/init-chain.js +13 -0
  114. package/dist/tools/init-chain.js.map +1 -0
  115. package/dist/tools/measure-behavior.d.ts +12 -0
  116. package/dist/tools/measure-behavior.d.ts.map +1 -0
  117. package/dist/tools/measure-behavior.js +29 -0
  118. package/dist/tools/measure-behavior.js.map +1 -0
  119. package/dist/tools/measure-subject.d.ts +15 -0
  120. package/dist/tools/measure-subject.d.ts.map +1 -0
  121. package/dist/tools/measure-subject.js +106 -0
  122. package/dist/tools/measure-subject.js.map +1 -0
  123. package/dist/tools/quarantine-status.d.ts +8 -0
  124. package/dist/tools/quarantine-status.d.ts.map +1 -0
  125. package/dist/tools/quarantine-status.js +16 -0
  126. package/dist/tools/quarantine-status.js.map +1 -0
  127. package/dist/tools/revoke-artifact.d.ts +13 -0
  128. package/dist/tools/revoke-artifact.d.ts.map +1 -0
  129. package/dist/tools/revoke-artifact.js +24 -0
  130. package/dist/tools/revoke-artifact.js.map +1 -0
  131. package/dist/tools/rotate-keys.d.ts +13 -0
  132. package/dist/tools/rotate-keys.d.ts.map +1 -0
  133. package/dist/tools/rotate-keys.js +39 -0
  134. package/dist/tools/rotate-keys.js.map +1 -0
  135. package/dist/tools/server-info.d.ts +8 -0
  136. package/dist/tools/server-info.d.ts.map +1 -0
  137. package/dist/tools/server-info.js +23 -0
  138. package/dist/tools/server-info.js.map +1 -0
  139. package/dist/tools/set-verification-tier.d.ts +11 -0
  140. package/dist/tools/set-verification-tier.d.ts.map +1 -0
  141. package/dist/tools/set-verification-tier.js +31 -0
  142. package/dist/tools/set-verification-tier.js.map +1 -0
  143. package/dist/tools/start-monitoring.d.ts +12 -0
  144. package/dist/tools/start-monitoring.d.ts.map +1 -0
  145. package/dist/tools/start-monitoring.js +17 -0
  146. package/dist/tools/start-monitoring.js.map +1 -0
  147. package/dist/tools/trigger-measurement.d.ts +15 -0
  148. package/dist/tools/trigger-measurement.d.ts.map +1 -0
  149. package/dist/tools/trigger-measurement.js +86 -0
  150. package/dist/tools/trigger-measurement.js.map +1 -0
  151. package/dist/tools/verify-artifact.d.ts +13 -0
  152. package/dist/tools/verify-artifact.d.ts.map +1 -0
  153. package/dist/tools/verify-artifact.js +6 -0
  154. package/dist/tools/verify-artifact.js.map +1 -0
  155. package/dist/tools/verify-bundle.d.ts +13 -0
  156. package/dist/tools/verify-bundle.d.ts.map +1 -0
  157. package/dist/tools/verify-bundle.js +6 -0
  158. package/dist/tools/verify-bundle.js.map +1 -0
  159. package/dist/types.d.ts +261 -0
  160. package/dist/types.d.ts.map +1 -0
  161. package/dist/types.js +8 -0
  162. package/dist/types.js.map +1 -0
  163. package/package.json +18 -3
  164. package/AGA_MCP_SERVER_SPEC.md +0 -632
  165. package/src/core/artifact.ts +0 -45
  166. package/src/core/attestation.ts +0 -33
  167. package/src/core/behavioral.ts +0 -132
  168. package/src/core/bundle.ts +0 -31
  169. package/src/core/chain.ts +0 -72
  170. package/src/core/checkpoint.ts +0 -22
  171. package/src/core/delegation.ts +0 -146
  172. package/src/core/disclosure.ts +0 -32
  173. package/src/core/index.ts +0 -11
  174. package/src/core/portal.ts +0 -96
  175. package/src/core/quarantine.ts +0 -16
  176. package/src/core/receipt.ts +0 -33
  177. package/src/core/subject.ts +0 -11
  178. package/src/core/types.ts +0 -244
  179. package/src/crypto/hash.ts +0 -33
  180. package/src/crypto/index.ts +0 -5
  181. package/src/crypto/merkle.ts +0 -43
  182. package/src/crypto/salt.ts +0 -18
  183. package/src/crypto/sign.ts +0 -35
  184. package/src/crypto/types.ts +0 -19
  185. package/src/index.ts +0 -12
  186. package/src/middleware/governance.ts +0 -95
  187. package/src/middleware/index.ts +0 -1
  188. package/src/server.ts +0 -436
  189. package/src/storage/index.ts +0 -3
  190. package/src/storage/interface.ts +0 -21
  191. package/src/storage/memory.ts +0 -27
  192. package/src/storage/sqlite.ts +0 -45
  193. package/src/tools/README.md +0 -13
  194. package/src/utils/canonical.ts +0 -14
  195. package/src/utils/constants.ts +0 -3
  196. package/src/utils/timestamp.ts +0 -12
  197. package/src/utils/uuid.ts +0 -2
package/dist/server.js CHANGED
@@ -1,137 +1,77 @@
1
1
  /**
2
- * AGA MCP Server. The Portal (ref 150) as an MCP service.
2
+ * AGA MCP Server V2.0.0 - The Portal (ref 150) as an MCP service.
3
3
  *
4
- * V3 NIST-aligned behaviors:
5
- * 1. Every measurement generates a receipt (match OR mismatch)
6
- * 2. TTL checked on every measurement (fail-closed)
7
- * 3. Mid-session revocation via revoke_artifact tool
8
- * 4. Governance middleware: portal state checked before tool execution
9
- * 5. Auto-chaining: every operation writes to continuity chain
4
+ * 20 tools, 3 resources, 3 prompts.
5
+ * NIST-2025-0035, NCCoE AI Agent Identity and Authorization
10
6
  */
11
7
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
12
8
  import { z } from 'zod';
13
- import { generateKeyPair, pkToHex } from './crypto/sign.js';
14
- import { sha256Str } from './crypto/hash.js';
15
- import { computeSubjectIdFromString } from './core/subject.js';
16
- import { performAttestation } from './core/attestation.js';
17
- import { generateArtifact, hashArtifact } from './core/artifact.js';
18
- import { Portal } from './core/portal.js';
19
- import { generateReceipt } from './core/receipt.js';
20
- import { createGenesisEvent, appendEvent, verifyChainIntegrity } from './core/chain.js';
21
- import { createCheckpoint, eventInclusionProof } from './core/checkpoint.js';
22
- import { generateBundle, verifyBundleOffline } from './core/bundle.js';
23
- import { processDisclosure } from './core/disclosure.js';
24
- import { initQuarantine } from './core/quarantine.js';
25
- import { MemoryStorage } from './storage/index.js';
26
- import { utcNow } from './utils/timestamp.js';
27
- import { deriveArtifact } from './core/delegation.js';
9
+ import { createContext } from './context.js';
28
10
  import { createGovernanceWrapper } from './middleware/governance.js';
29
- import { BehavioralMonitor } from './core/behavioral.js';
30
- // ── Default Policies ────────────────────────────────────────────
31
- const DEFAULT_ENFORCEMENT = {
32
- measurement_cadence_ms: 1000, ttl_seconds: 3600,
33
- enforcement_triggers: ['QUARANTINE', 'TERMINATE'],
34
- re_attestation_required: true,
35
- measurement_types: ['FILE_SYSTEM_STATE', 'CONFIG_MANIFEST'],
36
- };
37
- const DEFAULT_CLAIMS = {
38
- claims_taxonomy: [
39
- { claim_id: 'identity.name', sensitivity: 'S3_HIGH', substitutes: ['identity.pseudonym', 'identity.org'], inference_risks: [], permitted_modes: ['PROOF_ONLY'] },
40
- { claim_id: 'identity.pseudonym', sensitivity: 'S2_MODERATE', substitutes: ['identity.org'], inference_risks: [], permitted_modes: ['PROOF_ONLY', 'REVEAL_MIN'] },
41
- { claim_id: 'identity.org', sensitivity: 'S1_LOW', substitutes: [], inference_risks: [], permitted_modes: ['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL'] },
42
- { claim_id: 'identity.age', sensitivity: 'S3_HIGH', substitutes: ['identity.age_range', 'identity.is_adult'], inference_risks: [], permitted_modes: ['PROOF_ONLY'] },
43
- { claim_id: 'identity.age_range', sensitivity: 'S2_MODERATE', substitutes: ['identity.is_adult'], inference_risks: [], permitted_modes: ['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL'] },
44
- { claim_id: 'identity.is_adult', sensitivity: 'S1_LOW', substitutes: [], inference_risks: [], permitted_modes: ['PROOF_ONLY', 'REVEAL_FULL'] },
45
- ],
46
- substitution_rules: [],
47
- };
48
- const CLAIM_VALUES = {
49
- 'identity.name': 'Alice Johnson', 'identity.pseudonym': 'AJ-7742', 'identity.org': 'Attested Intelligence',
50
- 'identity.age': 32, 'identity.age_range': '25-34', 'identity.is_adult': true,
51
- };
11
+ // ── Tool handlers ────────────────────────────────────────────────
12
+ import { handleServerInfo } from './tools/server-info.js';
13
+ import { handleInitChain } from './tools/init-chain.js';
14
+ import { handleCreateArtifact } from './tools/create-artifact.js';
15
+ import { handleMeasureSubject } from './tools/measure-subject.js';
16
+ import { handleVerifyArtifact } from './tools/verify-artifact.js';
17
+ import { handleStartMonitoring } from './tools/start-monitoring.js';
18
+ import { handleGetPortalState } from './tools/get-portal-state.js';
19
+ import { handleTriggerMeasurement } from './tools/trigger-measurement.js';
20
+ import { handleGenerateReceipt } from './tools/generate-receipt.js';
21
+ import { handleExportBundle } from './tools/export-bundle.js';
22
+ import { handleVerifyBundle } from './tools/verify-bundle.js';
23
+ import { handleDiscloseClaim } from './tools/disclose-claim.js';
24
+ import { handleGetChain } from './tools/get-chain.js';
25
+ import { handleQuarantineStatus } from './tools/quarantine-status.js';
26
+ import { handleRevokeArtifact } from './tools/revoke-artifact.js';
27
+ import { handleSetVerificationTier } from './tools/set-verification-tier.js';
28
+ import { handleFullLifecycle } from './tools/full-lifecycle.js';
29
+ import { handleMeasureBehavior } from './tools/measure-behavior.js';
30
+ import { handleDelegateSubagent } from './tools/delegate-subagent.js';
31
+ import { handleRotateKeys } from './tools/rotate-keys.js';
32
+ // ── Resources ────────────────────────────────────────────────────
33
+ import { PROTOCOL_SPECIFICATION, SPECIFICATION_URI } from './resources/specification.js';
34
+ import { generateSampleBundle, SAMPLE_BUNDLE_URI } from './resources/sample-bundle.js';
35
+ import { CRYPTO_PRIMITIVES_DOC, CRYPTO_PRIMITIVES_URI } from './resources/crypto-primitives.js';
36
+ // ── Prompts ──────────────────────────────────────────────────────
37
+ import { NCCOE_DEMO_PROMPT } from './prompts/nccoe-demo.js';
38
+ import { GOVERNANCE_REPORT_PROMPT } from './prompts/governance-report.js';
39
+ import { DRIFT_ANALYSIS_PROMPT } from './prompts/drift-analysis.js';
52
40
  // ── Server Factory ──────────────────────────────────────────────
53
41
  export async function createAGAServer() {
54
- const server = new McpServer({ name: 'aga-mcp-server', version: '0.1.0' });
55
- const storage = new MemoryStorage();
56
- await storage.initialize();
57
- const issuerKP = generateKeyPair();
58
- const portalKP = generateKeyPair();
59
- const chainKP = generateKeyPair();
60
- const portal = new Portal();
61
- let quarantine = null;
62
- let chainInitialized = false;
63
- // ── Auto-chain helper (auto-inits if needed) ──────────────────
64
- async function autoChain(type, payload) {
65
- if (!chainInitialized) {
66
- const genesis = createGenesisEvent(chainKP, sha256Str('AGA Protocol Specification v1.0.0'));
67
- await storage.storeEvent(genesis);
68
- chainInitialized = true;
69
- portal.sequenceCounter = 0;
70
- portal.lastLeafHash = genesis.leaf_hash;
71
- }
72
- const prev = await storage.getLatestEvent();
73
- if (!prev)
74
- throw new Error('Chain initialization failed');
75
- const event = appendEvent(type, payload, prev, chainKP);
76
- await storage.storeEvent(event);
77
- portal.sequenceCounter = event.sequence_number;
78
- portal.lastLeafHash = event.leaf_hash;
79
- return event;
80
- }
81
- const j = (x) => ({ content: [{ type: 'text', text: JSON.stringify(x, null, 2) }] });
82
- // ── Governance middleware (NCCoE Section 4: Portal as PEP) ────
83
- const quarantineRef = { get current() { return quarantine; } };
84
- const behavioralMonitor = new BehavioralMonitor();
42
+ const server = new McpServer({ name: 'aga-mcp-server', version: '2.0.0' });
43
+ const ctx = await createContext();
44
+ const quarantineRef = { get current() { return ctx.quarantine; } };
85
45
  function governedTool(name, description, schema, handler) {
86
- const wrap = createGovernanceWrapper(portal, quarantineRef, name, behavioralMonitor);
46
+ const wrap = createGovernanceWrapper(ctx.portal, quarantineRef, name, ctx.behavioralMonitor);
87
47
  server.tool(name, description, schema, wrap(handler));
88
48
  }
89
49
  // ══════════════════════════════════════════════════════════════
90
- // TOOL: get_server_info
91
- // ══════════════════════════════════════════════════════════════
92
- server.tool('get_server_info', 'Get AGA server info, public keys, and portal state.', {}, async () => j({
93
- server: 'AGA MCP Server', version: '0.1.0',
94
- protocol: 'Attested Governance Artifacts v1.0.0',
95
- patent: 'USPTO Application No. 19/433,835',
96
- nist_references: ['NIST-2025-0035', 'NCCoE AI Agent Identity'],
97
- issuer_public_key: pkToHex(issuerKP.publicKey),
98
- portal_public_key: pkToHex(portalKP.publicKey),
99
- chain_public_key: pkToHex(chainKP.publicKey),
100
- chain_initialized: chainInitialized,
101
- portal_state: portal.state,
102
- }));
103
- // ══════════════════════════════════════════════════════════════
104
- // TOOL: get_portal_state — V3 RESTORED (was dropped in V2)
105
- // ══════════════════════════════════════════════════════════════
106
- server.tool('get_portal_state', 'Get current portal state, loaded artifact info, and enforcement status.', {}, async () => j({
107
- state: portal.state,
108
- artifact_loaded: !!portal.artifact,
109
- sealed_hash: portal.artifact?.sealed_hash ?? null,
110
- ttl_seconds: portal.artifact?.enforcement_parameters.ttl_seconds ?? null,
111
- issued_at: portal.artifact?.issued_timestamp ?? null,
112
- enforcement_triggers: portal.artifact?.enforcement_parameters.enforcement_triggers ?? [],
113
- sequence_counter: portal.sequenceCounter,
114
- quarantine_active: quarantine?.active ?? false,
115
- }));
116
- // ══════════════════════════════════════════════════════════════
117
- // TOOL: init_chain (Claim 3a)
118
- // ══════════════════════════════════════════════════════════════
119
- server.tool('init_chain', 'Initialize continuity chain with genesis event. (Claim 3a)', { specification_hash: z.string().optional() }, async ({ specification_hash }) => {
120
- if (chainInitialized)
121
- return j({ success: false, error: 'Chain already initialized' });
122
- const genesis = createGenesisEvent(chainKP, specification_hash ?? sha256Str('AGA Protocol Specification v1.0.0'));
123
- await storage.storeEvent(genesis);
124
- chainInitialized = true;
125
- portal.sequenceCounter = 0;
126
- portal.lastLeafHash = genesis.leaf_hash;
127
- return j({ success: true, genesis_event_id: genesis.event_id, genesis_leaf_hash: genesis.leaf_hash });
128
- });
129
- // ══════════════════════════════════════════════════════════════
130
- // TOOL: attest_subject (Claims 1a-1d)
131
- // ══════════════════════════════════════════════════════════════
132
- server.tool('attest_subject', 'Attest subject, generate sealed Policy Artifact. Auto-loads into portal. (Claims 1a-1d)', {
133
- subject_content: z.string().describe('Content/bytes of the subject'),
134
- subject_metadata: z.object({ filename: z.string().optional(), version: z.string().optional(), author: z.string().optional(), content_type: z.string().optional() }),
50
+ // 20 TOOLS
51
+ // ══════════════════════════════════════════════════════════════
52
+ // 1. aga_server_info (ungoverned)
53
+ server.tool('aga_server_info', 'Get AGA server info, public keys, portal state, and framework alignment.', {}, async () => handleServerInfo({}, ctx));
54
+ // Also register as get_server_info for backward compat
55
+ server.tool('get_server_info', 'Get AGA server info (alias for aga_server_info).', {}, async () => handleServerInfo({}, ctx));
56
+ // 2. aga_init_chain (ungoverned)
57
+ server.tool('aga_init_chain', 'Initialize continuity chain with genesis event.', { specification_hash: z.string().optional() }, async (args) => handleInitChain(args, ctx));
58
+ // Also register as init_chain for backward compat
59
+ server.tool('init_chain', 'Initialize continuity chain (alias for aga_init_chain).', { specification_hash: z.string().optional() }, async (args) => handleInitChain(args, ctx));
60
+ // 3. aga_create_artifact (ungoverned)
61
+ server.tool('aga_create_artifact', 'Attest subject, generate sealed Policy Artifact, load into portal. Accepts content or pre-computed hashes.', {
62
+ subject_content: z.string().optional().describe('Content/bytes of the subject'),
63
+ subject_bytes_hash: z.string().optional().describe('Pre-computed SHA-256 bytes hash'),
64
+ subject_metadata_hash: z.string().optional().describe('Pre-computed SHA-256 metadata hash'),
65
+ subject_metadata: z.object({
66
+ filename: z.string().optional(),
67
+ version: z.string().optional(),
68
+ author: z.string().optional(),
69
+ content_type: z.string().optional(),
70
+ }).optional(),
71
+ measurement_cadence_ms: z.number().optional(),
72
+ enforcement_action: z.string().optional(),
73
+ ttl_seconds: z.number().optional(),
74
+ measurement_types: z.array(z.string()).optional(),
135
75
  evidence_items: z.array(z.object({ label: z.string(), content: z.string() })).default([]),
136
76
  behavioral_baseline: z.object({
137
77
  permitted_tools: z.array(z.string()),
@@ -139,231 +79,162 @@ export async function createAGAServer() {
139
79
  forbidden_sequences: z.array(z.array(z.string())),
140
80
  window_ms: z.number(),
141
81
  }).optional(),
142
- }, async ({ subject_content, subject_metadata, evidence_items, behavioral_baseline }) => {
143
- const subId = computeSubjectIdFromString(subject_content, subject_metadata);
144
- const policyRef = sha256Str(JSON.stringify(DEFAULT_ENFORCEMENT));
145
- const att = performAttestation({ subject_identifier: subId, policy_reference: policyRef, evidence_items });
146
- if (!att.success || !att.sealed_hash || !att.seal_salt)
147
- return j({ success: false, error: att.rejection_reason });
148
- const artifact = generateArtifact({
149
- subject_identifier: subId, policy_reference: policyRef, policy_version: 1,
150
- sealed_hash: att.sealed_hash, seal_salt: att.seal_salt,
151
- enforcement_parameters: DEFAULT_ENFORCEMENT, disclosure_policy: DEFAULT_CLAIMS,
152
- evidence_commitments: att.evidence_commitments, issuer_keypair: issuerKP,
153
- });
154
- await storage.storeArtifact(artifact);
155
- portal.reset();
156
- portal.loadArtifact(artifact, pkToHex(issuerKP.publicKey));
157
- quarantine = null;
158
- behavioralMonitor.reset();
159
- if (behavioral_baseline)
160
- behavioralMonitor.setBaseline(behavioral_baseline);
161
- await autoChain('POLICY_ISSUANCE', { artifact_hash: hashArtifact(artifact), sealed_hash: artifact.sealed_hash });
162
- return j({
163
- success: true, artifact_hash: hashArtifact(artifact), sealed_hash: artifact.sealed_hash,
164
- subject_identifier: subId, portal_state: portal.state,
165
- issuer_public_key: pkToHex(issuerKP.publicKey),
166
- });
82
+ }, async (args) => handleCreateArtifact(args, ctx));
83
+ // 4. aga_measure_subject (governed)
84
+ governedTool('aga_measure_subject', 'Measure subject state, compare to sealed reference. Generates signed receipt.', {
85
+ subject_content: z.string().optional().describe('Raw content to measure'),
86
+ subject_bytes_hash: z.string().optional().describe('Pre-computed SHA-256 bytes hash (64 hex)'),
87
+ subject_metadata_hash: z.string().optional().describe('Pre-computed SHA-256 metadata hash (64 hex)'),
88
+ subject_metadata: z.object({
89
+ filename: z.string().optional(),
90
+ version: z.string().optional(),
91
+ author: z.string().optional(),
92
+ content_type: z.string().optional(),
93
+ }).optional(),
94
+ }, async (args) => handleMeasureSubject({ ...args, subject_metadata: args.subject_metadata ?? {} }, ctx));
95
+ // 5. aga_verify_artifact (ungoverned)
96
+ server.tool('aga_verify_artifact', 'Verify an artifact signature against an issuer public key.', {
97
+ artifact: z.any().describe('The policy artifact to verify'),
98
+ issuer_public_key: z.string().optional().describe('Issuer public key (hex)'),
99
+ }, async (args) => {
100
+ const pk = args.issuer_public_key ?? (await import('./crypto/sign.js')).pkToHex(ctx.issuerKP.publicKey);
101
+ return handleVerifyArtifact({ artifact: args.artifact ?? ctx.activeArtifact, issuer_public_key: pk }, ctx);
167
102
  });
168
- // ══════════════════════════════════════════════════════════════
169
- // TOOL: measure_integrity (Claims 1e-1g)
170
- // V3: Generates receipt for EVERY measurement (match or mismatch)
171
- // V3: Checks TTL and revocation (fail-closed)
172
- // ══════════════════════════════════════════════════════════════
173
- governedTool('measure_integrity', 'Measure subject state, compare to sealed reference. Generates signed receipt for every measurement. (Claims 1e-1g)', {
174
- subject_content: z.string().describe('Current content of the subject'),
175
- subject_metadata: z.object({ filename: z.string().optional(), version: z.string().optional(), author: z.string().optional(), content_type: z.string().optional() }),
176
- }, async ({ subject_content, subject_metadata }) => {
177
- if (!portal.artifact)
178
- return j({ success: false, error: 'No artifact loaded. Call attest_subject first.' });
179
- if (portal.state === 'TERMINATED')
180
- return j({ success: false, error: 'Portal is terminated. Re-attest required.' });
181
- const result = portal.measure(new TextEncoder().encode(subject_content), subject_metadata);
182
- const artRef = hashArtifact(portal.artifact);
183
- const currentStr = result.currentBytesHash ? `${result.currentBytesHash}||${result.currentMetaHash}` : 'UNAVAILABLE';
184
- const sealedStr = `${result.expectedBytesHash}||${result.expectedMetaHash}`;
185
- // Determine enforcement action
186
- let action = null;
187
- let driftDesc = null;
188
- if (!result.ttl_ok) {
189
- driftDesc = 'TTL expired — fail-closed termination';
190
- action = 'TERMINATE';
191
- }
192
- else if (result.revoked) {
193
- driftDesc = 'Artifact revoked — fail-closed termination';
194
- action = 'TERMINATE';
195
- }
196
- else if (!result.match) {
197
- driftDesc = 'Subject modified hash mismatch';
198
- action = portal.artifact.enforcement_parameters.enforcement_triggers[0] ?? 'ALERT_ONLY';
199
- portal.enforce(action);
200
- if (action === 'QUARANTINE')
201
- quarantine = initQuarantine();
202
- }
203
- // V3: Receipt for EVERY measurement — match or mismatch
204
- const receipt = generateReceipt({
205
- subjectId: portal.artifact.subject_identifier, artifactRef: artRef,
206
- currentHash: currentStr, sealedHash: sealedStr,
207
- driftDetected: !result.match, driftDescription: driftDesc,
208
- action, measurementType: portal.artifact.enforcement_parameters.measurement_types.join(','),
209
- seq: portal.sequenceCounter + 1, prevLeaf: portal.lastLeafHash, portalKP,
210
- });
211
- await storage.storeReceipt(receipt);
212
- await autoChain('INTERACTION_RECEIPT', { receipt_id: receipt.receipt_id, drift_detected: !result.match, enforcement_action: action });
213
- return j({
214
- success: true, match: result.match, drift_detected: !result.match,
215
- ttl_ok: result.ttl_ok, revoked: result.revoked,
216
- enforcement_action: action, portal_state: portal.state,
217
- receipt_id: receipt.receipt_id,
218
- });
103
+ // 6. aga_start_monitoring (governed)
104
+ governedTool('aga_start_monitoring', 'Start or restart behavioral monitoring with a new baseline.', {
105
+ behavioral_baseline: z.object({
106
+ permitted_tools: z.array(z.string()),
107
+ rate_limits: z.record(z.number()),
108
+ forbidden_sequences: z.array(z.array(z.string())),
109
+ window_ms: z.number(),
110
+ }).optional(),
111
+ }, async (args) => handleStartMonitoring(args, ctx));
112
+ // 7. aga_get_portal_state (ungoverned)
113
+ server.tool('aga_get_portal_state', 'Get current portal state, loaded artifact info, and enforcement status.', {}, async () => handleGetPortalState({}, ctx));
114
+ // 8. aga_trigger_measurement (governed)
115
+ governedTool('aga_trigger_measurement', 'Trigger a measurement of subject content and generate a receipt.', {
116
+ subject_content: z.string().optional().describe('Raw content to measure'),
117
+ subject_bytes_hash: z.string().optional().describe('Pre-computed SHA-256 bytes hash (64 hex)'),
118
+ subject_metadata_hash: z.string().optional().describe('Pre-computed SHA-256 metadata hash (64 hex)'),
119
+ measurement_type: z.string().optional(),
120
+ subject_metadata: z.record(z.string()).optional(),
121
+ }, async (args) => handleTriggerMeasurement(args, ctx));
122
+ // 9. aga_generate_receipt (governed)
123
+ governedTool('aga_generate_receipt', 'Generate a signed measurement receipt manually.', {
124
+ subject_content: z.string().optional(),
125
+ drift_detected: z.boolean().optional(),
126
+ drift_description: z.string().optional(),
127
+ measurement_type: z.string().optional(),
128
+ action_type: z.string().optional(),
129
+ action_detail: z.string().optional(),
130
+ }, async (args) => handleGenerateReceipt(args, ctx));
131
+ // 10. aga_export_bundle (governed)
132
+ governedTool('aga_export_bundle', 'Package artifact + receipts + Merkle proofs for offline verification.', {}, async () => handleExportBundle({}, ctx));
133
+ // 11. aga_verify_bundle (ungoverned - verification is always allowed)
134
+ server.tool('aga_verify_bundle', 'Verify evidence bundle offline - 4-step verification.', {
135
+ bundle: z.any(),
136
+ pinned_public_key: z.string().optional(),
137
+ }, async (args) => {
138
+ const pk = args.pinned_public_key ?? (await import('./crypto/sign.js')).pkToHex(ctx.issuerKP.publicKey);
139
+ return handleVerifyBundle({ bundle: args.bundle, pinned_public_key: pk }, ctx);
219
140
  });
220
- // ══════════════════════════════════════════════════════════════
221
- // TOOL: revoke_artifact V3 NEW (NCCoE Phase 3b)
222
- // ══════════════════════════════════════════════════════════════
223
- governedTool('revoke_artifact', 'Revoke an active policy artifact mid-session. Portal terminates on next measurement. (NCCoE Phase 3b)', {
224
- sealed_hash: z.string().describe('Sealed hash of artifact to revoke'),
141
+ // 12. aga_disclose_claim (governed)
142
+ governedTool('aga_disclose_claim', 'Request disclosure of a claim. Auto-substitutes if sensitivity denied.', {
143
+ claim_id: z.string(),
144
+ requester_id: z.string().default('anonymous'),
145
+ mode: z.enum(['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL']).default('REVEAL_MIN'),
146
+ disclosure_mode: z.enum(['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL']).optional(),
147
+ }, async (args) => handleDiscloseClaim({
148
+ claim_id: args.claim_id,
149
+ requester_id: args.requester_id,
150
+ mode: args.disclosure_mode ?? args.mode,
151
+ }, ctx));
152
+ // 13. aga_get_chain (ungoverned)
153
+ server.tool('aga_get_chain', 'Get continuity chain events with optional verification and filtering.', {
154
+ start_seq: z.number().optional(),
155
+ end_seq: z.number().optional(),
156
+ verify: z.boolean().optional(),
157
+ filter_type: z.string().optional().describe('Filter: all, behavioral, delegations, receipts, revocations, attestations, disclosure, keys'),
158
+ }, async (args) => handleGetChain(args, ctx));
159
+ // 14. aga_quarantine_status (ungoverned)
160
+ server.tool('aga_quarantine_status', 'Get quarantine state and forensic capture status.', {}, async () => handleQuarantineStatus({}, ctx));
161
+ // 15. aga_revoke_artifact (governed)
162
+ governedTool('aga_revoke_artifact', 'Revoke an active policy artifact mid-session. Supports TERMINATED or SAFE_STATE transition.', {
163
+ sealed_hash: z.string().optional().describe('Sealed hash of artifact to revoke'),
225
164
  reason: z.string().describe('Reason for revocation'),
226
- }, async ({ sealed_hash, reason }) => {
227
- portal.revoke(sealed_hash);
228
- const record = {
229
- artifact_sealed_hash: sealed_hash, reason,
230
- revoked_by: pkToHex(issuerKP.publicKey), timestamp: utcNow(),
231
- };
232
- await autoChain('REVOCATION', record);
233
- return j({ success: true, revoked: sealed_hash, portal_state: portal.state, reason });
234
- });
235
- // ══════════════════════════════════════════════════════════════
236
- // TOOL: verify_chain (Claim 3c)
237
- // ══════════════════════════════════════════════════════════════
238
- server.tool('verify_chain', 'Verify continuity chain integrity. (Claim 3c)', {}, async () => {
239
- const events = await storage.getAllEvents();
240
- if (!events.length)
241
- return j({ success: false, error: 'No events in chain' });
242
- const result = verifyChainIntegrity(events);
243
- return j({ success: true, chain_valid: result.valid, events_verified: events.length, broken_at: result.brokenAt, error: result.error });
244
- });
245
- // ══════════════════════════════════════════════════════════════
246
- // TOOL: create_checkpoint (Claims 3d-3f)
247
- // ══════════════════════════════════════════════════════════════
248
- governedTool('create_checkpoint', 'Batch events into Merkle tree, anchor. (Claims 3d-3f)', { anchor_network: z.string().default('local') }, async ({ anchor_network }) => {
249
- const lastCP = await storage.getLatestCheckpoint();
250
- const startSeq = lastCP ? lastCP.batch_end_sequence + 1 : 0;
251
- const latest = await storage.getLatestEvent();
252
- if (!latest)
253
- return j({ success: false, error: 'No events' });
254
- const events = await storage.getEvents(startSeq, latest.sequence_number);
255
- if (!events.length)
256
- return j({ success: false, error: 'No new events since last checkpoint' });
257
- const { checkpoint, payload } = createCheckpoint(events, anchor_network);
258
- await storage.storeCheckpoint(checkpoint);
259
- await autoChain('ANCHOR_BATCH', payload);
260
- return j({ success: true, merkle_root: checkpoint.merkle_root, events_checkpointed: events.length, transaction_id: checkpoint.transaction_id });
261
- });
262
- // ══════════════════════════════════════════════════════════════
263
- // TOOL: generate_evidence_bundle (Claim 9)
264
- // ══════════════════════════════════════════════════════════════
265
- governedTool('generate_evidence_bundle', 'Package artifact + receipts + Merkle proofs for offline verification. (Claim 9)', {}, async () => {
266
- const artifact = await storage.getLatestArtifact();
267
- if (!artifact)
268
- return j({ success: false, error: 'No artifact' });
269
- const cp = await storage.getLatestCheckpoint();
270
- if (!cp)
271
- return j({ success: false, error: 'No checkpoint. Call create_checkpoint first.' });
272
- const receipts = await storage.getReceiptsByArtifact(hashArtifact(artifact));
273
- const batchEvents = await storage.getEvents(cp.batch_start_sequence, cp.batch_end_sequence);
274
- const proofs = receipts
275
- .filter(r => r.sequence_number >= cp.batch_start_sequence && r.sequence_number <= cp.batch_end_sequence)
276
- .map(r => eventInclusionProof(batchEvents, r.sequence_number));
277
- const bundle = generateBundle(artifact, receipts, proofs, cp, portalKP);
278
- return j({ success: true, bundle, offline_verifiable: true, receipt_count: receipts.length, proof_count: proofs.length });
279
- });
280
- // ══════════════════════════════════════════════════════════════
281
- // TOOL: verify_bundle_offline (Section J)
282
- // ══════════════════════════════════════════════════════════════
283
- governedTool('verify_bundle_offline', 'Verify evidence bundle offline. (Section J)', { bundle: z.any(), pinned_public_key: z.string() }, async ({ bundle, pinned_public_key }) => j({ success: true, verification: verifyBundleOffline(bundle, pinned_public_key) }));
284
- // ══════════════════════════════════════════════════════════════
285
- // TOOL: request_claim (Claim 2)
286
- // ══════════════════════════════════════════════════════════════
287
- governedTool('request_claim', 'Request disclosure of a claim. Auto-substitutes if denied. (Claim 2)', { claim_id: z.string(), requester_id: z.string().default('anonymous'), mode: z.enum(['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL']).default('REVEAL_MIN') }, async ({ claim_id, requester_id, mode }) => {
288
- const latest = await storage.getLatestEvent();
289
- const result = processDisclosure({ requested_claim_id: claim_id, requester_id, mode, timestamp: utcNow() }, DEFAULT_CLAIMS, CLAIM_VALUES, 1, latest?.sequence_number ?? 0, portalKP);
290
- if (result.substitution_receipt)
291
- await autoChain('SUBSTITUTION', result.substitution_receipt);
292
- else
293
- await autoChain('DISCLOSURE', { claim_id, mode, permitted: result.permitted });
294
- return j({ success: true, ...result });
295
- });
296
- // ══════════════════════════════════════════════════════════════
297
- // TOOL: list_claims
298
- // ══════════════════════════════════════════════════════════════
299
- server.tool('list_claims', 'List available claims with sensitivity levels.', {}, async () => {
300
- return j({ claims: DEFAULT_CLAIMS.claims_taxonomy.map(c => ({ claim_id: c.claim_id, sensitivity: c.sensitivity, substitutes: c.substitutes, permitted_modes: c.permitted_modes })) });
301
- });
302
- // ══════════════════════════════════════════════════════════════
303
- // TOOL: delegate_to_subagent (NCCoE: constrained sub-mandates)
304
- // ══════════════════════════════════════════════════════════════
305
- governedTool('delegate_to_subagent', 'Derive a constrained policy artifact for a sub-agent. Scope can only diminish, never expand. (NCCoE constrained delegation)', {
306
- enforcement_triggers: z.array(z.string()).describe('Subset of parent enforcement triggers'),
307
- measurement_types: z.array(z.string()).describe('Subset of parent measurement types'),
308
- requested_ttl_seconds: z.number().describe('Requested TTL (will be clamped to parent remaining)'),
309
- delegation_purpose: z.string().describe('Purpose of the delegation'),
310
- }, async ({ enforcement_triggers, measurement_types, requested_ttl_seconds, delegation_purpose }) => {
311
- if (!portal.artifact)
312
- return j({ success: false, error: 'No artifact loaded. Call attest_subject first.' });
313
- const result = deriveArtifact(portal.artifact, {
314
- enforcement_triggers: enforcement_triggers,
315
- measurement_types: measurement_types,
316
- requested_ttl_seconds,
317
- delegation_purpose,
318
- }, issuerKP);
319
- if (result.success) {
320
- await autoChain('ATTESTATION', {
321
- type: 'DELEGATION',
322
- parent_artifact_hash: result.parent_artifact_hash,
323
- child_artifact_hash: result.child_artifact_hash,
324
- effective_ttl: result.effective_ttl_seconds,
325
- scope_reduction: result.scope_reduction,
326
- purpose: delegation_purpose,
327
- });
328
- }
329
- return j(result);
330
- });
331
- // ══════════════════════════════════════════════════════════════
332
- // TOOL: measure_behavior (NIST-2025-0035)
333
- // ══════════════════════════════════════════════════════════════
334
- server.tool('measure_behavior', 'Measure behavioral patterns of agent tool usage. Detects unauthorized tools, rate violations, and forbidden sequences. (NIST-2025-0035)', {}, async () => {
335
- const measurement = behavioralMonitor.measure();
336
- if (measurement.drift_detected) {
337
- await autoChain('INTERACTION_RECEIPT', {
338
- type: 'BEHAVIORAL_DRIFT',
339
- violations: measurement.violations,
340
- behavioral_hash: measurement.behavioral_hash,
341
- });
342
- }
343
- return j({
344
- success: true,
345
- ...measurement,
346
- violation_count: measurement.violations.length,
347
- });
348
- });
349
- // ══════════════════════════════════════════════════════════════
350
- // TOOL: get_receipts — V3 NEW
351
- // ══════════════════════════════════════════════════════════════
352
- server.tool('get_receipts', 'Get all signed receipts, optionally filtered by artifact.', { artifact_hash: z.string().optional() }, async ({ artifact_hash }) => {
353
- const receipts = artifact_hash
354
- ? await storage.getReceiptsByArtifact(artifact_hash)
355
- : await storage.getAllReceipts();
356
- return j({ count: receipts.length, receipts: receipts.map(r => ({ receipt_id: r.receipt_id, drift_detected: r.drift_detected, enforcement_action: r.enforcement_action, measurement_type: r.measurement_type, timestamp: r.timestamp })) });
357
- });
358
- // ══════════════════════════════════════════════════════════════
359
- // TOOL: get_chain_events — V3 NEW
360
- // ══════════════════════════════════════════════════════════════
361
- server.tool('get_chain_events', 'Get continuity chain events.', { start_seq: z.number().optional(), end_seq: z.number().optional() }, async ({ start_seq, end_seq }) => {
362
- const events = (start_seq !== undefined && end_seq !== undefined)
363
- ? await storage.getEvents(start_seq, end_seq)
364
- : await storage.getAllEvents();
365
- return j({ count: events.length, events: events.map(e => ({ sequence_number: e.sequence_number, event_type: e.event_type, event_id: e.event_id, timestamp: e.timestamp, leaf_hash: e.leaf_hash.slice(0, 16) + '...' })) });
165
+ transition_to: z.enum(['TERMINATED', 'SAFE_STATE']).optional(),
166
+ }, async (args) => handleRevokeArtifact(args, ctx));
167
+ // 16. aga_set_verification_tier (ungoverned)
168
+ server.tool('aga_set_verification_tier', 'Set the verification tier (BRONZE, SILVER, GOLD).', {
169
+ tier: z.enum(['BRONZE', 'SILVER', 'GOLD']),
170
+ }, async (args) => handleSetVerificationTier(args, ctx));
171
+ // 17. aga_demonstrate_lifecycle (ungoverned)
172
+ server.tool('aga_demonstrate_lifecycle', 'Execute full AGA lifecycle demo: attest → measure → drift → revoke → bundle → verify.', {
173
+ subject_content: z.string().optional(),
174
+ subject_metadata: z.record(z.string()).optional(),
175
+ scenario: z.string().optional().describe('Scenario: drone, scada, or custom'),
176
+ include_drift: z.boolean().optional(),
177
+ include_revocation: z.boolean().optional(),
178
+ include_behavioral: z.boolean().optional(),
179
+ }, async (args) => handleFullLifecycle(args, ctx));
180
+ // 18. aga_measure_behavior (ungoverned)
181
+ server.tool('aga_measure_behavior', 'Measure behavioral patterns or record tool invocation.', {
182
+ tool_name: z.string().optional().describe('Tool name to record/test'),
183
+ record_only: z.boolean().optional().describe('If true, just record without measuring'),
184
+ }, async (args) => handleMeasureBehavior(args, ctx));
185
+ // 19. aga_delegate_to_subagent (governed)
186
+ governedTool('aga_delegate_to_subagent', 'Derive constrained policy artifact for sub-agent. Scope only diminishes.', {
187
+ sub_agent_id: z.string().optional(),
188
+ permitted_tools: z.array(z.string()).optional(),
189
+ enforcement_triggers: z.array(z.string()).optional(),
190
+ measurement_types: z.array(z.string()).optional(),
191
+ ttl_seconds: z.number().optional(),
192
+ requested_ttl_seconds: z.number().optional(),
193
+ delegation_purpose: z.string().optional(),
194
+ delegation_reason: z.string().optional(),
195
+ }, async (args) => handleDelegateSubagent(args, ctx));
196
+ // 20. aga_rotate_keys (governed)
197
+ governedTool('aga_rotate_keys', 'Rotate a keypair (issuer, portal, or chain). Old key should be revoked.', {
198
+ key_type: z.enum(['issuer', 'portal', 'chain']).optional(),
199
+ keypair: z.enum(['issuer', 'portal', 'chain']).optional(),
200
+ reason: z.string().optional(),
201
+ }, async (args) => handleRotateKeys(args, ctx));
202
+ // ══════════════════════════════════════════════════════════════
203
+ // 3 RESOURCES
204
+ // ══════════════════════════════════════════════════════════════
205
+ server.resource('protocol-specification', SPECIFICATION_URI, { mimeType: 'text/markdown', description: 'AGA Protocol Specification v2.0.0 with SPIFFE integration and framework alignment' }, async () => ({ contents: [{ uri: SPECIFICATION_URI, mimeType: 'text/markdown', text: PROTOCOL_SPECIFICATION }] }));
206
+ server.resource('sample-bundle', SAMPLE_BUNDLE_URI, { mimeType: 'application/json', description: 'Pre-generated cryptographically signed evidence bundle' }, async () => {
207
+ const { bundle, issuerPkHex } = generateSampleBundle();
208
+ const text = JSON.stringify({ issuer_public_key: issuerPkHex, bundle: JSON.parse(bundle) }, null, 2);
209
+ return { contents: [{ uri: SAMPLE_BUNDLE_URI, mimeType: 'application/json', text }] };
366
210
  });
211
+ server.resource('crypto-primitives', CRYPTO_PRIMITIVES_URI, { mimeType: 'text/markdown', description: 'AGA cryptographic primitives documentation' }, async () => ({ contents: [{ uri: CRYPTO_PRIMITIVES_URI, mimeType: 'text/markdown', text: CRYPTO_PRIMITIVES_DOC }] }));
212
+ // ══════════════════════════════════════════════════════════════
213
+ // 3 PROMPTS
214
+ // ══════════════════════════════════════════════════════════════
215
+ server.prompt(NCCOE_DEMO_PROMPT.name, NCCOE_DEMO_PROMPT.description, {
216
+ agent_code: z.string().optional().describe('The agent source code to attest'),
217
+ include_behavioral: z.string().optional().describe('Include behavioral drift detection phase'),
218
+ }, async (args) => ({
219
+ messages: [{
220
+ role: 'user',
221
+ content: { type: 'text', text: NCCOE_DEMO_PROMPT.template(args) },
222
+ }],
223
+ }));
224
+ server.prompt(GOVERNANCE_REPORT_PROMPT.name, GOVERNANCE_REPORT_PROMPT.description, {}, async () => ({
225
+ messages: [{
226
+ role: 'user',
227
+ content: { type: 'text', text: GOVERNANCE_REPORT_PROMPT.template() },
228
+ }],
229
+ }));
230
+ server.prompt(DRIFT_ANALYSIS_PROMPT.name, DRIFT_ANALYSIS_PROMPT.description, {
231
+ drift_type: z.string().optional().describe('Type of drift: binary, behavioral, or both'),
232
+ }, async (args) => ({
233
+ messages: [{
234
+ role: 'user',
235
+ content: { type: 'text', text: DRIFT_ANALYSIS_PROMPT.template(args) },
236
+ }],
237
+ }));
367
238
  return server;
368
239
  }
369
240
  //# sourceMappingURL=server.js.map