@kya-os/mcp-i 0.1.0-alpha.2.0 → 0.1.0-alpha.2.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.
- package/README.md +61 -181
- package/dist/__tests__/challenge-response.test.js +12 -11
- package/dist/__tests__/challenge-response.test.js.map +1 -1
- package/dist/auto-enhance.d.ts +41 -0
- package/dist/auto-enhance.d.ts.map +1 -0
- package/dist/auto-enhance.js +193 -0
- package/dist/auto-enhance.js.map +1 -0
- package/dist/auto-init.d.ts +12 -0
- package/dist/auto-init.d.ts.map +1 -0
- package/dist/auto-init.js +166 -0
- package/dist/auto-init.js.map +1 -0
- package/dist/auto.d.ts +13 -0
- package/dist/auto.d.ts.map +1 -0
- package/dist/auto.js +24 -0
- package/dist/auto.js.map +1 -0
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -17
- package/dist/index.js.map +1 -1
- package/dist/patch.d.ts +22 -0
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +164 -0
- package/dist/patch.js.map +1 -0
- package/dist/transparent.d.ts +40 -0
- package/dist/transparent.d.ts.map +1 -0
- package/dist/transparent.js +167 -0
- package/dist/transparent.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Auto-initialization module for @kya-os/mcp-i
|
|
4
|
+
*
|
|
5
|
+
* This file provides automatic enhancement of MCP servers when imported.
|
|
6
|
+
* Just add: import '@kya-os/mcp-i/auto-init'
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.initializeMCPIdentity = initialize;
|
|
43
|
+
const auto_enhance_1 = require("./auto-enhance");
|
|
44
|
+
// Track if we've already hooked into the module system
|
|
45
|
+
let isInitialized = false;
|
|
46
|
+
/**
|
|
47
|
+
* Hook into CommonJS require to automatically enhance MCP servers
|
|
48
|
+
*/
|
|
49
|
+
function hookRequire() {
|
|
50
|
+
const Module = require('module');
|
|
51
|
+
const originalRequire = Module.prototype.require;
|
|
52
|
+
Module.prototype.require = function (id) {
|
|
53
|
+
const exports = originalRequire.apply(this, arguments);
|
|
54
|
+
// Check if this is an MCP SDK module
|
|
55
|
+
if (id === '@modelcontextprotocol/sdk' ||
|
|
56
|
+
id === '@modelcontextprotocol/sdk/server' ||
|
|
57
|
+
id === '@modelcontextprotocol/sdk/server/index.js' ||
|
|
58
|
+
id === '@modelcontextprotocol/sdk/server/mcp.js') {
|
|
59
|
+
// Wrap Server constructor if it exists
|
|
60
|
+
if (exports.Server && !exports.Server._mcpIdentityWrapped) {
|
|
61
|
+
const OriginalServer = exports.Server;
|
|
62
|
+
exports.Server = class extends OriginalServer {
|
|
63
|
+
constructor(...args) {
|
|
64
|
+
super(...args);
|
|
65
|
+
// Enhance after construction
|
|
66
|
+
setImmediate(async () => {
|
|
67
|
+
await (0, auto_enhance_1.enhanceMCPServer)(this);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.Server._mcpIdentityWrapped = true;
|
|
72
|
+
}
|
|
73
|
+
// Wrap McpServer constructor if it exists
|
|
74
|
+
if (exports.McpServer && !exports.McpServer._mcpIdentityWrapped) {
|
|
75
|
+
const OriginalMcpServer = exports.McpServer;
|
|
76
|
+
exports.McpServer = class extends OriginalMcpServer {
|
|
77
|
+
constructor(...args) {
|
|
78
|
+
super(...args);
|
|
79
|
+
// Enhance after construction
|
|
80
|
+
setImmediate(async () => {
|
|
81
|
+
await (0, auto_enhance_1.enhanceMCPServer)(this);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.McpServer._mcpIdentityWrapped = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return exports;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Hook into ES module imports
|
|
93
|
+
*/
|
|
94
|
+
async function hookESModules() {
|
|
95
|
+
// This requires Node.js experimental loader API
|
|
96
|
+
// Users would need to run with: node --loader @kya-os/mcp-i/loader
|
|
97
|
+
// For now, we'll use a different approach - monkey-patching the global
|
|
98
|
+
if (typeof globalThis !== 'undefined') {
|
|
99
|
+
// Store original import
|
|
100
|
+
const globalAny = globalThis;
|
|
101
|
+
const originalImport = globalAny.import || (async (id) => Promise.resolve(`${id}`).then(s => __importStar(require(s))));
|
|
102
|
+
// Override dynamic import
|
|
103
|
+
globalAny.import = async function (id) {
|
|
104
|
+
const module = await originalImport(id);
|
|
105
|
+
// Check if this is an MCP SDK module
|
|
106
|
+
if (id === '@modelcontextprotocol/sdk' ||
|
|
107
|
+
id === '@modelcontextprotocol/sdk/server' ||
|
|
108
|
+
id.includes('@modelcontextprotocol/sdk')) {
|
|
109
|
+
// Wrap constructors
|
|
110
|
+
if (module.Server && !module.Server._mcpIdentityWrapped) {
|
|
111
|
+
const OriginalServer = module.Server;
|
|
112
|
+
module.Server = class extends OriginalServer {
|
|
113
|
+
constructor(...args) {
|
|
114
|
+
super(...args);
|
|
115
|
+
setImmediate(async () => {
|
|
116
|
+
await (0, auto_enhance_1.enhanceMCPServer)(this);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
module.Server._mcpIdentityWrapped = true;
|
|
121
|
+
}
|
|
122
|
+
if (module.McpServer && !module.McpServer._mcpIdentityWrapped) {
|
|
123
|
+
const OriginalMcpServer = module.McpServer;
|
|
124
|
+
module.McpServer = class extends OriginalMcpServer {
|
|
125
|
+
constructor(...args) {
|
|
126
|
+
super(...args);
|
|
127
|
+
setImmediate(async () => {
|
|
128
|
+
await (0, auto_enhance_1.enhanceMCPServer)(this);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
module.McpServer._mcpIdentityWrapped = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return module;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Initialize auto-enhancement
|
|
141
|
+
*/
|
|
142
|
+
async function initialize() {
|
|
143
|
+
if (isInitialized)
|
|
144
|
+
return;
|
|
145
|
+
isInitialized = true;
|
|
146
|
+
// Initialize identity immediately
|
|
147
|
+
(0, auto_enhance_1.initializeIdentity)().catch(err => {
|
|
148
|
+
console.error('[MCP-I] Failed to initialize identity:', err.message);
|
|
149
|
+
});
|
|
150
|
+
// Hook into module loading systems
|
|
151
|
+
try {
|
|
152
|
+
hookRequire();
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
// CommonJS might not be available
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
await hookESModules();
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
// ES modules hooks might fail
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Auto-initialize when this module is imported
|
|
165
|
+
initialize();
|
|
166
|
+
//# sourceMappingURL=auto-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-init.js","sourceRoot":"","sources":["../src/auto-init.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+IoB,2CAAqB;AA7I5C,iDAAsE;AAEtE,uDAAuD;AACvD,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B;;GAEG;AACH,SAAS,WAAW;IAClB,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;IAEjD,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,UAAS,EAAU;QAC5C,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAEvD,qCAAqC;QACrC,IAAI,EAAE,KAAK,2BAA2B;YAClC,EAAE,KAAK,kCAAkC;YACzC,EAAE,KAAK,2CAA2C;YAClD,EAAE,KAAK,yCAAyC,EAAE,CAAC;YAErD,uCAAuC;YACvC,IAAI,OAAO,CAAC,MAAM,IAAI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M,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC;gBAC9C,CAAC;YACH,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,UAAU;IACvB,IAAI,aAAa;QAAE,OAAO;IAC1B,aAAa,GAAG,IAAI,CAAC;IAErB,kCAAkC;IAClC,IAAA,iCAAkB,GAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,mCAAmC;IACnC,IAAI,CAAC;QACH,WAAW,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,kCAAkC;IACpC,CAAC;IAED,IAAI,CAAC;QACH,MAAM,aAAa,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,8BAA8B;IAChC,CAAC;AACH,CAAC;AAED,+CAA+C;AAC/C,UAAU,EAAE,CAAC"}
|
package/dist/auto.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-initialization for MCP Identity
|
|
3
|
+
*
|
|
4
|
+
* Just import this file to automatically enable MCP-I for any MCP server:
|
|
5
|
+
*
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import "@kya-os/mcp-i/auto";
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* That's it! Your MCP server now has identity.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=auto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto.d.ts","sourceRoot":"","sources":["../src/auto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/dist/auto.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Auto-initialization for MCP Identity
|
|
4
|
+
*
|
|
5
|
+
* Just import this file to automatically enable MCP-I for any MCP server:
|
|
6
|
+
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import "@kya-os/mcp-i/auto";
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* That's it! Your MCP server now has identity.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const index_1 = require("./index");
|
|
15
|
+
// Auto-initialize on import
|
|
16
|
+
(async () => {
|
|
17
|
+
try {
|
|
18
|
+
await (0, index_1.enableMCPIdentity)();
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('[MCP-I] Failed to auto-initialize:', error);
|
|
22
|
+
}
|
|
23
|
+
})();
|
|
24
|
+
//# sourceMappingURL=auto.js.map
|
package/dist/auto.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto.js","sourceRoot":"","sources":["../src/auto.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAEH,mCAA4C;AAE5C,4BAA4B;AAC5B,CAAC,KAAK,IAAI,EAAE;IACV,IAAI,CAAC;QACH,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @kya-os/mcp-i - Ultra-light MCP Identity auto-registration
|
|
2
|
+
* @kya-os/mcp-i - Ultra-light MCP Identity auto-registration
|
|
3
3
|
*
|
|
4
4
|
* Enable any MCP server to get a verifiable identity with just 2 lines of code:
|
|
5
5
|
*
|
|
6
6
|
* ```typescript
|
|
7
|
-
* import
|
|
8
|
-
* const identity = await MCPIdentity.init();
|
|
7
|
+
* import "@kya-os/mcp-i/auto"; // That's it! Your server now has identity
|
|
9
8
|
* ```
|
|
10
9
|
*
|
|
11
|
-
*
|
|
10
|
+
* Or with configuration:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { enableMCPIdentity } from "@kya-os/mcp-i";
|
|
13
|
+
* await enableMCPIdentity({ name: "My Amazing Agent" });
|
|
14
|
+
* ```
|
|
12
15
|
*/
|
|
13
16
|
import { MCPIdentityOptions, Challenge, ChallengeResponse, MCPICapabilities, SignedResponse } from './types';
|
|
14
17
|
export * from './types';
|
|
@@ -23,12 +26,6 @@ export declare class MCPIdentity {
|
|
|
23
26
|
private constructor();
|
|
24
27
|
/**
|
|
25
28
|
* Initialize MCP Identity - the main entry point
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import { MCPIdentity } from "@kya-os/mcp-i";
|
|
30
|
-
* const identity = await MCPIdentity.init();
|
|
31
|
-
* ```
|
|
32
29
|
*/
|
|
33
30
|
static init(options?: MCPIdentityOptions): Promise<MCPIdentity>;
|
|
34
31
|
/**
|
|
@@ -41,7 +38,6 @@ export declare class MCPIdentity {
|
|
|
41
38
|
verify(message: string | Buffer, signature: string, publicKey?: string): Promise<boolean>;
|
|
42
39
|
/**
|
|
43
40
|
* Respond to an MCP-I challenge
|
|
44
|
-
* This is the core of the challenge-response authentication system
|
|
45
41
|
*/
|
|
46
42
|
respondToChallenge(challenge: Challenge): Promise<ChallengeResponse>;
|
|
47
43
|
/**
|
|
@@ -65,4 +61,9 @@ export declare class MCPIdentity {
|
|
|
65
61
|
*/
|
|
66
62
|
destroy(): void;
|
|
67
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Enable MCP Identity for any MCP server
|
|
66
|
+
* This is the main integration point that patches the MCP Server
|
|
67
|
+
*/
|
|
68
|
+
export declare function enableMCPIdentity(options?: MCPIdentityOptions): Promise<MCPIdentity>;
|
|
68
69
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EACL,kBAAkB,EAGlB,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACf,MAAM,SAAS,CAAC;AAGjB,cAAc,SAAS,CAAC;AAKxB,qBAAa,WAAW;IACtB,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,mBAAmB,CAAU;IACrC,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,oBAAoB,CAAC,CAAiB;IAE9C,OAAO;IAgBP;;OAEG;WACU,IAAI,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAkDrE;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD;;OAEG;IACG,MAAM,CACV,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC;IAQnB;;OAEG;IACG,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA4C1E;;OAEG;IACH,eAAe,IAAI,gBAAgB;IAYnC;;OAEG;IACG,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IA2BpE;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,MAAM;IAI9B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;OAEG;IACH,OAAO;CAMR;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAW1F"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @kya-os/mcp-i - Ultra-light MCP Identity auto-registration
|
|
3
|
+
* @kya-os/mcp-i - Ultra-light MCP Identity auto-registration
|
|
4
4
|
*
|
|
5
5
|
* Enable any MCP server to get a verifiable identity with just 2 lines of code:
|
|
6
6
|
*
|
|
7
7
|
* ```typescript
|
|
8
|
-
* import
|
|
9
|
-
* const identity = await MCPIdentity.init();
|
|
8
|
+
* import "@kya-os/mcp-i/auto"; // That's it! Your server now has identity
|
|
10
9
|
* ```
|
|
11
10
|
*
|
|
12
|
-
*
|
|
11
|
+
* Or with configuration:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { enableMCPIdentity } from "@kya-os/mcp-i";
|
|
14
|
+
* await enableMCPIdentity({ name: "My Amazing Agent" });
|
|
15
|
+
* ```
|
|
13
16
|
*/
|
|
14
17
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
18
|
if (k2 === undefined) k2 = k;
|
|
@@ -52,12 +55,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
55
|
};
|
|
53
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
57
|
exports.MCPIdentity = void 0;
|
|
58
|
+
exports.enableMCPIdentity = enableMCPIdentity;
|
|
55
59
|
const axios_1 = __importDefault(require("axios"));
|
|
56
60
|
const fs = __importStar(require("fs"));
|
|
57
61
|
const path = __importStar(require("path"));
|
|
58
62
|
const crypto = __importStar(require("./crypto"));
|
|
59
63
|
// Re-export types for convenience
|
|
60
64
|
__exportStar(require("./types"), exports);
|
|
65
|
+
// Global identity instance
|
|
66
|
+
let globalIdentity = null;
|
|
61
67
|
class MCPIdentity {
|
|
62
68
|
constructor(identity, options = {}) {
|
|
63
69
|
this.usedNonces = new Set();
|
|
@@ -73,14 +79,12 @@ class MCPIdentity {
|
|
|
73
79
|
}
|
|
74
80
|
/**
|
|
75
81
|
* Initialize MCP Identity - the main entry point
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* import { MCPIdentity } from "@kya-os/mcp-i";
|
|
80
|
-
* const identity = await MCPIdentity.init();
|
|
81
|
-
* ```
|
|
82
82
|
*/
|
|
83
83
|
static async init(options) {
|
|
84
|
+
// Return existing global identity if already initialized (unless forced)
|
|
85
|
+
if (globalIdentity && !options?.forceNew) {
|
|
86
|
+
return globalIdentity;
|
|
87
|
+
}
|
|
84
88
|
// Try to load existing identity
|
|
85
89
|
let identity = await loadIdentity(options?.persistencePath);
|
|
86
90
|
// Auto-register if needed
|
|
@@ -114,7 +118,8 @@ class MCPIdentity {
|
|
|
114
118
|
console.log(`[MCP-I] DID: ${response.did}`);
|
|
115
119
|
console.log(`[MCP-I] Profile: ${response.agent.url}`);
|
|
116
120
|
}
|
|
117
|
-
|
|
121
|
+
globalIdentity = new MCPIdentity(identity, options);
|
|
122
|
+
return globalIdentity;
|
|
118
123
|
}
|
|
119
124
|
/**
|
|
120
125
|
* Sign a message with the agent's private key using Ed25519
|
|
@@ -130,7 +135,6 @@ class MCPIdentity {
|
|
|
130
135
|
}
|
|
131
136
|
/**
|
|
132
137
|
* Respond to an MCP-I challenge
|
|
133
|
-
* This is the core of the challenge-response authentication system
|
|
134
138
|
*/
|
|
135
139
|
async respondToChallenge(challenge) {
|
|
136
140
|
// Validate timestamp to prevent replay attacks
|
|
@@ -239,6 +243,67 @@ class MCPIdentity {
|
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
exports.MCPIdentity = MCPIdentity;
|
|
246
|
+
/**
|
|
247
|
+
* Enable MCP Identity for any MCP server
|
|
248
|
+
* This is the main integration point that patches the MCP Server
|
|
249
|
+
*/
|
|
250
|
+
async function enableMCPIdentity(options) {
|
|
251
|
+
const identity = await MCPIdentity.init(options);
|
|
252
|
+
// Try to patch MCP Server if available
|
|
253
|
+
try {
|
|
254
|
+
patchMCPServer(identity);
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
console.log('[MCP-I] MCP Server not found, identity initialized for manual use');
|
|
258
|
+
}
|
|
259
|
+
return identity;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Patch the MCP Server to automatically add identity
|
|
263
|
+
*/
|
|
264
|
+
function patchMCPServer(identity) {
|
|
265
|
+
try {
|
|
266
|
+
// Try to import the MCP SDK
|
|
267
|
+
const MCPModule = require('@modelcontextprotocol/sdk/server/index.js');
|
|
268
|
+
const OriginalServer = MCPModule.Server;
|
|
269
|
+
if (!OriginalServer) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
// Store original methods
|
|
273
|
+
const originalSetRequestHandler = OriginalServer.prototype.setRequestHandler;
|
|
274
|
+
const originalConnect = OriginalServer.prototype.connect;
|
|
275
|
+
// Patch setRequestHandler to wrap all responses
|
|
276
|
+
OriginalServer.prototype.setRequestHandler = function (method, handler) {
|
|
277
|
+
const wrappedHandler = async (...args) => {
|
|
278
|
+
const result = await handler(...args);
|
|
279
|
+
// If result has content, sign it
|
|
280
|
+
if (result && typeof result === 'object' && 'content' in result) {
|
|
281
|
+
const signed = await identity.signResponse(result);
|
|
282
|
+
return signed;
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
};
|
|
286
|
+
return originalSetRequestHandler.call(this, method, wrappedHandler);
|
|
287
|
+
};
|
|
288
|
+
// Patch connect to advertise MCP-I capabilities
|
|
289
|
+
OriginalServer.prototype.connect = async function (transport) {
|
|
290
|
+
// Add MCP-I capabilities to server info
|
|
291
|
+
if (this.serverInfo && this.serverInfo.capabilities) {
|
|
292
|
+
this.serverInfo.capabilities['mcp-i'] = identity.getCapabilities();
|
|
293
|
+
}
|
|
294
|
+
// Set up MCP-I handshake handler
|
|
295
|
+
this.setRequestHandler('mcp-i/challenge', async (request) => {
|
|
296
|
+
return identity.respondToChallenge(request.params);
|
|
297
|
+
});
|
|
298
|
+
// Call original connect
|
|
299
|
+
return originalConnect.call(this, transport);
|
|
300
|
+
};
|
|
301
|
+
console.log('[MCP-I] ✨ MCP Server patched - all responses will be automatically signed');
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
// MCP SDK not available, that's okay
|
|
305
|
+
}
|
|
306
|
+
}
|
|
242
307
|
// Helper functions (inline to keep package standalone)
|
|
243
308
|
async function loadIdentity(customPath) {
|
|
244
309
|
// Check environment variables first (already loaded by process)
|
|
@@ -263,9 +328,6 @@ async function loadIdentity(customPath) {
|
|
|
263
328
|
catch {
|
|
264
329
|
// Ignore errors
|
|
265
330
|
}
|
|
266
|
-
// Note: We don't manually load .env or .env.local files here
|
|
267
|
-
// because that should be handled by the application's environment
|
|
268
|
-
// loading strategy (dotenv, framework, etc.)
|
|
269
331
|
return null;
|
|
270
332
|
}
|
|
271
333
|
async function saveIdentity(identity, customPath) {
|
|
@@ -299,7 +361,7 @@ async function autoRegister(options) {
|
|
|
299
361
|
version: '1.0.0'
|
|
300
362
|
},
|
|
301
363
|
clientInfo: {
|
|
302
|
-
sdkVersion: '0.2.0',
|
|
364
|
+
sdkVersion: '0.1.0-alpha.2.0',
|
|
303
365
|
language: 'typescript',
|
|
304
366
|
platform: 'node' // Always node for MCP servers
|
|
305
367
|
}
|
|
@@ -307,7 +369,7 @@ async function autoRegister(options) {
|
|
|
307
369
|
timeout: 30000,
|
|
308
370
|
headers: {
|
|
309
371
|
'Content-Type': 'application/json',
|
|
310
|
-
'User-Agent': '@kya-os/mcp-i/0.2.0'
|
|
372
|
+
'User-Agent': '@kya-os/mcp-i/0.1.0-alpha.2.0'
|
|
311
373
|
}
|
|
312
374
|
});
|
|
313
375
|
return response.data;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0PH,8CAWC;AAnQD,kDAA0B;AAC1B,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAmC;AAWnC,kCAAkC;AAClC,0CAAwB;AAExB,2BAA2B;AAC3B,IAAI,cAAc,GAAuB,IAAI,CAAC;AAE9C,MAAa,WAAW;IAStB,YACE,QAA2B,EAC3B,UAA8B,EAAE;QAL1B,eAAU,GAAgB,IAAI,GAAG,EAAE,CAAC;QAO1C,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACtC,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,KAAK,CAAC,CAAC,aAAa;QAC5E,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,KAAK,KAAK,CAAC;QAEjE,6CAA6C;QAC7C,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAA4B;QAC5C,yEAAyE;QACzE,IAAI,cAAc,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACzC,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,gCA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C;AACpF,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,OAK3B;IACC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,GAAG,OAAO,CAAC,WAAW,2BAA2B,EACjD;YACE,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,OAAO,EAAE,OAAO;aACjB;YACD,UAAU,EAAE;gBACV,UAAU,EAAE,iBAAiB;gBAC7B,QAAQ,EAAE,YAAY;gBACtB,QAAQ,EAAE,MAAM,CAAC,8BAA8B;aAChD;SACF,EACD;YACE,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,YAAY,EAAE,+BAA+B;aAC9C;SACF,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,IAAI,KAAK,CACb,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO;YAC7B,KAAK,CAAC,OAAO;YACb,+BAA+B,CAChC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/patch.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monkey-patch approach for zero-code integration
|
|
3
|
+
*
|
|
4
|
+
* This can be loaded before any MCP server code to automatically
|
|
5
|
+
* add identity to all servers without any code changes.
|
|
6
|
+
*
|
|
7
|
+
* Usage: node -r @kya-os/mcp-i/patch your-server.js
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Wrap a response to add identity without changing its type
|
|
11
|
+
*/
|
|
12
|
+
declare function addIdentityToResponse(response: any): Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Wrap a handler function to add identity to its responses
|
|
15
|
+
*/
|
|
16
|
+
declare function wrapHandler(handler: Function): Function;
|
|
17
|
+
/**
|
|
18
|
+
* Patch a server instance to wrap all its handler methods
|
|
19
|
+
*/
|
|
20
|
+
declare function patchServerInstance(instance: any): any;
|
|
21
|
+
export { addIdentityToResponse, wrapHandler, patchServerInstance };
|
|
22
|
+
//# sourceMappingURL=patch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../src/patch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH;;GAEG;AACH,iBAAe,qBAAqB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CA8DhE;AAED;;GAEG;AACH,iBAAS,WAAW,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAKhD;AAED;;GAEG;AACH,iBAAS,mBAAmB,CAAC,QAAQ,EAAE,GAAG,OAmBzC;AAgED,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC"}
|