@uvrn/mcp 1.0.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.
Files changed (42) hide show
  1. package/README.md +446 -0
  2. package/dist/__tests__/fixtures/bundles.d.ts +4 -0
  3. package/dist/__tests__/fixtures/bundles.d.ts.map +1 -0
  4. package/dist/__tests__/fixtures/bundles.js +75 -0
  5. package/dist/__tests__/fixtures/bundles.js.map +1 -0
  6. package/dist/config.d.ts +8 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +26 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/index.d.ts +7 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +33 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/logger.d.ts +17 -0
  15. package/dist/logger.d.ts.map +1 -0
  16. package/dist/logger.js +45 -0
  17. package/dist/logger.js.map +1 -0
  18. package/dist/prompts/templates.d.ts +34 -0
  19. package/dist/prompts/templates.d.ts.map +1 -0
  20. package/dist/prompts/templates.js +102 -0
  21. package/dist/prompts/templates.js.map +1 -0
  22. package/dist/resources/handlers.d.ts +33 -0
  23. package/dist/resources/handlers.d.ts.map +1 -0
  24. package/dist/resources/handlers.js +94 -0
  25. package/dist/resources/handlers.js.map +1 -0
  26. package/dist/server.d.ts +14 -0
  27. package/dist/server.d.ts.map +1 -0
  28. package/dist/server.js +256 -0
  29. package/dist/server.js.map +1 -0
  30. package/dist/tools/handlers.d.ts +21 -0
  31. package/dist/tools/handlers.d.ts.map +1 -0
  32. package/dist/tools/handlers.js +141 -0
  33. package/dist/tools/handlers.js.map +1 -0
  34. package/dist/tools/schemas.d.ts +147 -0
  35. package/dist/tools/schemas.d.ts.map +1 -0
  36. package/dist/tools/schemas.js +109 -0
  37. package/dist/tools/schemas.js.map +1 -0
  38. package/dist/types.d.ts +70 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/types.js +43 -0
  41. package/dist/types.js.map +1 -0
  42. package/package.json +50 -0
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Tool Handlers
4
+ * Implements the three core tools for Delta Engine MCP server
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.handleRunEngine = handleRunEngine;
8
+ exports.handleValidateBundle = handleValidateBundle;
9
+ exports.handleVerifyReceipt = handleVerifyReceipt;
10
+ const core_1 = require("@uvrn/core");
11
+ const types_1 = require("../types");
12
+ const logger_1 = require("../logger");
13
+ const config_1 = require("../config");
14
+ /**
15
+ * Tool: delta_run_engine
16
+ * Executes the Delta Engine on a provided bundle
17
+ */
18
+ async function handleRunEngine(input) {
19
+ logger_1.logger.debug('handleRunEngine called', { bundleId: input.bundle?.bundleId });
20
+ try {
21
+ // Validate input structure
22
+ if (!input.bundle || typeof input.bundle !== 'object') {
23
+ throw new types_1.ValidationError('Invalid input: bundle must be an object');
24
+ }
25
+ const bundle = input.bundle;
26
+ // Enforce MAX_BUNDLE_SIZE if configured
27
+ if (config_1.config.maxBundleSize) {
28
+ const bundleSize = JSON.stringify(bundle).length;
29
+ if (bundleSize > config_1.config.maxBundleSize) {
30
+ throw new types_1.ValidationError(`Bundle size (${bundleSize} bytes) exceeds maximum allowed size (${config_1.config.maxBundleSize} bytes)`, { bundleSize, maxBundleSize: config_1.config.maxBundleSize });
31
+ }
32
+ }
33
+ // Explicitly validate bundle structure before execution
34
+ const validationResult = (0, core_1.validateBundle)(bundle);
35
+ if (!validationResult.valid) {
36
+ throw new types_1.ValidationError(`Bundle validation failed: ${validationResult.error}`, { validationResult });
37
+ }
38
+ // Run the engine
39
+ const receipt = (0, core_1.runDeltaEngine)(bundle, {
40
+ timestamp: input.options?.timestamp,
41
+ });
42
+ logger_1.logger.info('Engine executed successfully', {
43
+ bundleId: bundle.bundleId,
44
+ outcome: receipt.outcome,
45
+ });
46
+ return {
47
+ receipt,
48
+ success: true,
49
+ };
50
+ }
51
+ catch (error) {
52
+ // Preserve validation errors as-is
53
+ if (error instanceof types_1.ValidationError) {
54
+ throw error;
55
+ }
56
+ const message = error instanceof Error ? error.message : String(error);
57
+ const errorDetails = config_1.config.verboseErrors ? { originalError: error } : undefined;
58
+ logger_1.logger.error('Engine execution failed', { error: message });
59
+ throw new types_1.ExecutionError(`Engine execution failed: ${message}`, errorDetails);
60
+ }
61
+ }
62
+ /**
63
+ * Tool: delta_validate_bundle
64
+ * Validates bundle structure without executing
65
+ */
66
+ async function handleValidateBundle(input) {
67
+ logger_1.logger.debug('handleValidateBundle called');
68
+ try {
69
+ // Validate input structure
70
+ if (!input.bundle || typeof input.bundle !== 'object') {
71
+ return {
72
+ valid: false,
73
+ error: 'Invalid input: bundle must be an object',
74
+ details: 'The provided bundle is not a valid object',
75
+ };
76
+ }
77
+ const bundle = input.bundle;
78
+ const result = (0, core_1.validateBundle)(bundle);
79
+ logger_1.logger.info('Bundle validation completed', {
80
+ valid: result.valid,
81
+ bundleId: bundle.bundleId,
82
+ });
83
+ return {
84
+ valid: result.valid,
85
+ error: result.error,
86
+ details: result.valid
87
+ ? `Bundle "${bundle.bundleId}" is valid with ${bundle.dataSpecs.length} data specs`
88
+ : result.error,
89
+ };
90
+ }
91
+ catch (error) {
92
+ const message = error instanceof Error ? error.message : String(error);
93
+ logger_1.logger.error('Bundle validation error', { error: message });
94
+ return {
95
+ valid: false,
96
+ error: 'Validation error',
97
+ details: message,
98
+ };
99
+ }
100
+ }
101
+ /**
102
+ * Tool: delta_verify_receipt
103
+ * Verifies receipt integrity and hash chain
104
+ */
105
+ async function handleVerifyReceipt(input) {
106
+ logger_1.logger.debug('handleVerifyReceipt called');
107
+ try {
108
+ // Validate input structure
109
+ if (!input.receipt || typeof input.receipt !== 'object') {
110
+ return {
111
+ verified: false,
112
+ error: 'Invalid input: receipt must be an object',
113
+ details: 'The provided receipt is not a valid object',
114
+ };
115
+ }
116
+ const receipt = input.receipt;
117
+ const result = (0, core_1.verifyReceipt)(receipt);
118
+ logger_1.logger.info('Receipt verification completed', {
119
+ verified: result.verified,
120
+ bundleId: receipt.bundleId,
121
+ });
122
+ return {
123
+ verified: result.verified,
124
+ recomputedHash: result.recomputedHash,
125
+ error: result.error,
126
+ details: result.verified
127
+ ? `Receipt for bundle "${receipt.bundleId}" is valid. Hash verified: ${receipt.hash}`
128
+ : result.error,
129
+ };
130
+ }
131
+ catch (error) {
132
+ const message = error instanceof Error ? error.message : String(error);
133
+ logger_1.logger.error('Receipt verification error', { error: message });
134
+ return {
135
+ verified: false,
136
+ error: 'Verification error',
137
+ details: message,
138
+ };
139
+ }
140
+ }
141
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/tools/handlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA0BH,0CAyDC;AAMD,oDAwCC;AAMD,kDAyCC;AA9KD,qCAMoB;AACpB,oCASkB;AAClB,sCAAmC;AACnC,sCAAmC;AAEnC;;;GAGG;AACI,KAAK,UAAU,eAAe,CAAC,KAAqB;IACzD,eAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE7E,IAAI,CAAC;QACH,2BAA2B;QAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACtD,MAAM,IAAI,uBAAe,CAAC,yCAAyC,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAqB,CAAC;QAE3C,wCAAwC;QACxC,IAAI,eAAM,CAAC,aAAa,EAAE,CAAC;YACzB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;YACjD,IAAI,UAAU,GAAG,eAAM,CAAC,aAAa,EAAE,CAAC;gBACtC,MAAM,IAAI,uBAAe,CACvB,gBAAgB,UAAU,yCAAyC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B,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * MCP Tool Schemas
3
+ * JSON Schema definitions for tool inputs
4
+ */
5
+ export declare const runEngineSchema: {
6
+ type: string;
7
+ properties: {
8
+ bundle: {
9
+ type: string;
10
+ description: string;
11
+ properties: {
12
+ bundleId: {
13
+ type: string;
14
+ description: string;
15
+ };
16
+ claim: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ dataSpecs: {
21
+ type: string;
22
+ description: string;
23
+ minItems: number;
24
+ items: {
25
+ type: string;
26
+ properties: {
27
+ id: {
28
+ type: string;
29
+ };
30
+ label: {
31
+ type: string;
32
+ };
33
+ sourceKind: {
34
+ type: string;
35
+ enum: string[];
36
+ };
37
+ originDocIds: {
38
+ type: string;
39
+ items: {
40
+ type: string;
41
+ };
42
+ };
43
+ metrics: {
44
+ type: string;
45
+ items: {
46
+ type: string;
47
+ properties: {
48
+ key: {
49
+ type: string;
50
+ };
51
+ value: {
52
+ type: string;
53
+ };
54
+ unit: {
55
+ type: string;
56
+ };
57
+ ts: {
58
+ type: string;
59
+ };
60
+ };
61
+ required: string[];
62
+ };
63
+ };
64
+ };
65
+ required: string[];
66
+ };
67
+ };
68
+ thresholdPct: {
69
+ type: string;
70
+ description: string;
71
+ minimum: number;
72
+ exclusiveMinimum: boolean;
73
+ maximum: number;
74
+ };
75
+ maxRounds: {
76
+ type: string;
77
+ description: string;
78
+ };
79
+ };
80
+ required: string[];
81
+ };
82
+ options: {
83
+ type: string;
84
+ description: string;
85
+ properties: {
86
+ timestamp: {
87
+ type: string;
88
+ description: string;
89
+ };
90
+ };
91
+ };
92
+ };
93
+ required: string[];
94
+ };
95
+ export declare const validateBundleSchema: {
96
+ type: string;
97
+ properties: {
98
+ bundle: {
99
+ type: string;
100
+ description: string;
101
+ };
102
+ };
103
+ required: string[];
104
+ };
105
+ export declare const verifyReceiptSchema: {
106
+ type: string;
107
+ properties: {
108
+ receipt: {
109
+ type: string;
110
+ description: string;
111
+ properties: {
112
+ bundleId: {
113
+ type: string;
114
+ };
115
+ deltaFinal: {
116
+ type: string;
117
+ };
118
+ sources: {
119
+ type: string;
120
+ items: {
121
+ type: string;
122
+ };
123
+ };
124
+ rounds: {
125
+ type: string;
126
+ };
127
+ suggestedFixes: {
128
+ type: string;
129
+ };
130
+ outcome: {
131
+ type: string;
132
+ enum: string[];
133
+ };
134
+ ts: {
135
+ type: string;
136
+ };
137
+ hash: {
138
+ type: string;
139
+ description: string;
140
+ };
141
+ };
142
+ required: string[];
143
+ };
144
+ };
145
+ required: string[];
146
+ };
147
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkE3B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;CAShC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuB/B,CAAC"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Tool Schemas
4
+ * JSON Schema definitions for tool inputs
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.verifyReceiptSchema = exports.validateBundleSchema = exports.runEngineSchema = void 0;
8
+ exports.runEngineSchema = {
9
+ type: 'object',
10
+ properties: {
11
+ bundle: {
12
+ type: 'object',
13
+ description: 'DeltaBundle to process',
14
+ properties: {
15
+ bundleId: { type: 'string', description: 'Unique bundle identifier' },
16
+ claim: { type: 'string', description: 'Claim being verified' },
17
+ dataSpecs: {
18
+ type: 'array',
19
+ description: 'Array of data specifications (minimum 2)',
20
+ minItems: 2,
21
+ items: {
22
+ type: 'object',
23
+ properties: {
24
+ id: { type: 'string' },
25
+ label: { type: 'string' },
26
+ sourceKind: {
27
+ type: 'string',
28
+ enum: ['report', 'metric', 'chart', 'meta']
29
+ },
30
+ originDocIds: { type: 'array', items: { type: 'string' } },
31
+ metrics: {
32
+ type: 'array',
33
+ items: {
34
+ type: 'object',
35
+ properties: {
36
+ key: { type: 'string' },
37
+ value: { type: 'number' },
38
+ unit: { type: 'string' },
39
+ ts: { type: 'string' },
40
+ },
41
+ required: ['key', 'value'],
42
+ },
43
+ },
44
+ },
45
+ required: ['id', 'label', 'sourceKind', 'originDocIds', 'metrics'],
46
+ },
47
+ },
48
+ thresholdPct: {
49
+ type: 'number',
50
+ description: 'Threshold percentage (must be > 0 and <= 1.0)',
51
+ minimum: 0.001,
52
+ exclusiveMinimum: true,
53
+ maximum: 1,
54
+ },
55
+ maxRounds: {
56
+ type: 'number',
57
+ description: 'Maximum rounds (default: 5)',
58
+ },
59
+ },
60
+ required: ['bundleId', 'claim', 'dataSpecs', 'thresholdPct'],
61
+ },
62
+ options: {
63
+ type: 'object',
64
+ description: 'Optional execution options',
65
+ properties: {
66
+ timestamp: {
67
+ type: 'string',
68
+ description: 'ISO timestamp for receipt envelope',
69
+ },
70
+ },
71
+ },
72
+ },
73
+ required: ['bundle'],
74
+ };
75
+ exports.validateBundleSchema = {
76
+ type: 'object',
77
+ properties: {
78
+ bundle: {
79
+ type: 'object',
80
+ description: 'DeltaBundle to validate (same structure as runEngine)',
81
+ },
82
+ },
83
+ required: ['bundle'],
84
+ };
85
+ exports.verifyReceiptSchema = {
86
+ type: 'object',
87
+ properties: {
88
+ receipt: {
89
+ type: 'object',
90
+ description: 'DeltaReceipt to verify',
91
+ properties: {
92
+ bundleId: { type: 'string' },
93
+ deltaFinal: { type: 'number' },
94
+ sources: { type: 'array', items: { type: 'string' } },
95
+ rounds: { type: 'array' },
96
+ suggestedFixes: { type: 'array' },
97
+ outcome: {
98
+ type: 'string',
99
+ enum: ['consensus', 'indeterminate']
100
+ },
101
+ ts: { type: 'string' },
102
+ hash: { type: 'string', description: 'SHA-256 hash of canonical payload' },
103
+ },
104
+ required: ['bundleId', 'deltaFinal', 'sources', 'rounds', 'outcome', 'hash'],
105
+ },
106
+ },
107
+ required: ['receipt'],
108
+ };
109
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wBAAwB;YACrC,UAAU,EAAE;gBACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0BAA0B,EAAE;gBACrE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;gBAC9D,SAAS,EAAE;oBACT,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,0CAA0C;oBACvD,QAAQ,EAAE,CAAC;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;4BACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;4BACzB,UAAU,EAAE;gCACV,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;6BAC5C;4BACD,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;4BAC1D,OAAO,EAAE;gCACP,IAAI,EAAE,OAAO;gCACb,KAAK,EAAE;oCACL,IAAI,EAAE,QAAQ;oCACd,UAAU,EAAE;w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,EAAE,wBAAwB;YACrC,UAAU,EAAE;gBACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC5B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC9B,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;gBACrD,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;gBACzB,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;gBACjC,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC;iBACrC;gBACD,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACtB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mCAAmC,EAAE;aAC3E;YACD,QAAQ,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;SAC7E;KACF;IACD,QAAQ,EAAE,CAAC,SAAS,CAAC;CACtB,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * MCP Server Type Definitions
3
+ * Extends uvrn-core types with MCP-specific interfaces
4
+ */
5
+ import type { DeltaBundle, DeltaReceipt, DeltaRound, DataSpec, MetricPoint, ValidationResult, VerifyResult, Outcome, EngineOpts } from '@uvrn/core';
6
+ export type { DeltaBundle, DeltaReceipt, DeltaRound, DataSpec, MetricPoint, ValidationResult, VerifyResult, Outcome, EngineOpts, };
7
+ /**
8
+ * MCP Tool Input/Output Types
9
+ */
10
+ export interface RunEngineInput {
11
+ bundle: DeltaBundle;
12
+ options?: {
13
+ timestamp?: string;
14
+ };
15
+ }
16
+ export interface RunEngineOutput {
17
+ receipt: DeltaReceipt;
18
+ success: true;
19
+ }
20
+ export interface ValidateBundleInput {
21
+ bundle: DeltaBundle;
22
+ }
23
+ export interface ValidateBundleOutput {
24
+ valid: boolean;
25
+ error?: string;
26
+ details?: string;
27
+ }
28
+ export interface VerifyReceiptInput {
29
+ receipt: DeltaReceipt;
30
+ }
31
+ export interface VerifyReceiptOutput {
32
+ verified: boolean;
33
+ recomputedHash?: string;
34
+ error?: string;
35
+ details?: string;
36
+ }
37
+ /**
38
+ * MCP Resource Types
39
+ */
40
+ export interface ResourceUriParams {
41
+ uvrn?: string;
42
+ id?: string;
43
+ }
44
+ /**
45
+ * MCP Error Types
46
+ */
47
+ export declare class MCPError extends Error {
48
+ code: string;
49
+ details?: unknown | undefined;
50
+ constructor(message: string, code: string, details?: unknown | undefined);
51
+ }
52
+ export declare class ValidationError extends MCPError {
53
+ constructor(message: string, details?: unknown);
54
+ }
55
+ export declare class ExecutionError extends MCPError {
56
+ constructor(message: string, details?: unknown);
57
+ }
58
+ export declare class ResourceNotFoundError extends MCPError {
59
+ constructor(resourceId: string);
60
+ }
61
+ /**
62
+ * Configuration Types
63
+ */
64
+ export interface ServerConfig {
65
+ logLevel: 'debug' | 'info' | 'warn' | 'error';
66
+ storagePath?: string;
67
+ maxBundleSize?: number;
68
+ verboseErrors?: boolean;
69
+ }
70
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,UAAU,EACX,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,UAAU,GACX,CAAC;AAEF;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE;QACR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;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
package/dist/types.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Server Type Definitions
4
+ * Extends uvrn-core types with MCP-specific interfaces
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ResourceNotFoundError = exports.ExecutionError = exports.ValidationError = exports.MCPError = void 0;
8
+ /**
9
+ * MCP Error Types
10
+ */
11
+ class MCPError extends Error {
12
+ code;
13
+ details;
14
+ constructor(message, code, details) {
15
+ super(message);
16
+ this.code = code;
17
+ this.details = details;
18
+ this.name = 'MCPError';
19
+ }
20
+ }
21
+ exports.MCPError = MCPError;
22
+ class ValidationError extends MCPError {
23
+ constructor(message, details) {
24
+ super(message, 'VALIDATION_ERROR', details);
25
+ this.name = 'ValidationError';
26
+ }
27
+ }
28
+ exports.ValidationError = ValidationError;
29
+ class ExecutionError extends MCPError {
30
+ constructor(message, details) {
31
+ super(message, 'EXECUTION_ERROR', details);
32
+ this.name = 'ExecutionError';
33
+ }
34
+ }
35
+ exports.ExecutionError = ExecutionError;
36
+ class ResourceNotFoundError extends MCPError {
37
+ constructor(resourceId) {
38
+ super(`Resource not found: ${resourceId}`, 'RESOURCE_NOT_FOUND', { resourceId });
39
+ this.name = 'ResourceNotFoundError';
40
+ }
41
+ }
42
+ exports.ResourceNotFoundError = ResourceNotFoundError;
43
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA0EH;;GAEG;AAEH,MAAa,QAAS,SAAQ,KAAK;IAGxB;IACA;IAHT,YACE,OAAe,EACR,IAAY,EACZ,OAAiB;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAU;QAGxB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AATD,4BASC;AAED,MAAa,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,cAAe,SAAQ,QAAQ;IAC1C,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC;AAED,MAAa,qBAAsB,SAAQ,QAAQ;IACjD,YAAY,UAAkB;QAC5B,KAAK,CAAC,uBAAuB,UAAU,EAAE,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@uvrn/mcp",
3
+ "version": "1.0.0",
4
+ "description": "UVRN MCP server — AI-native bundle processing",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "uvrn-mcp": "dist/index.js"
9
+ },
10
+ "keywords": [
11
+ "uvrn",
12
+ "mcp",
13
+ "verification",
14
+ "receipt",
15
+ "ai"
16
+ ],
17
+ "author": "UVRN",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "@modelcontextprotocol/sdk": "^1.0.0",
21
+ "@uvrn/core": "1.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^20.0.0",
25
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
26
+ "@typescript-eslint/parser": "^6.0.0",
27
+ "eslint": "^8.0.0",
28
+ "prettier": "^3.0.0",
29
+ "tsx": "^4.0.0",
30
+ "typescript": "^5.3.0",
31
+ "vitest": "^1.0.0"
32
+ },
33
+ "engines": {
34
+ "node": ">=18.0.0"
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "README.md"
39
+ ],
40
+ "scripts": {
41
+ "build": "tsc",
42
+ "dev": "tsc --watch",
43
+ "test": "vitest",
44
+ "test:coverage": "vitest --coverage",
45
+ "start": "node dist/index.js",
46
+ "clean": "rm -rf dist",
47
+ "lint": "eslint src --ext .ts",
48
+ "format": "prettier --write \"src/**/*.ts\""
49
+ }
50
+ }