@kya-os/mcp-i 0.1.0-alpha.2.2 → 0.1.0-alpha.2.4
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 +258 -58
- package/dist/auto.d.ts +0 -12
- package/dist/auto.js +3 -14
- package/dist/crypto.d.ts +10 -26
- package/dist/crypto.js +117 -37
- package/dist/dev-helper.d.ts +3 -0
- package/dist/dev-helper.js +54 -0
- package/dist/encrypted-storage.d.ts +11 -0
- package/dist/encrypted-storage.js +73 -0
- package/dist/index.d.ts +33 -48
- package/dist/index.js +267 -191
- package/dist/logger.d.ts +32 -0
- package/dist/logger.js +66 -0
- package/dist/registry/index.d.ts +12 -0
- package/dist/registry/index.js +56 -0
- package/dist/registry/knowthat.d.ts +13 -0
- package/dist/registry/knowthat.js +88 -0
- package/dist/rotation.d.ts +35 -0
- package/dist/rotation.js +102 -0
- package/dist/storage.d.ts +41 -0
- package/dist/storage.js +163 -0
- package/dist/transport.d.ts +34 -0
- package/dist/transport.js +207 -0
- package/dist/types.d.ts +80 -17
- package/dist/types.js +0 -4
- package/package.json +36 -8
- package/dist/__tests__/challenge-response.test.d.ts +0 -5
- package/dist/__tests__/challenge-response.test.d.ts.map +0 -1
- package/dist/__tests__/challenge-response.test.js +0 -218
- package/dist/__tests__/challenge-response.test.js.map +0 -1
- package/dist/__tests__/crypto.test.d.ts +0 -5
- package/dist/__tests__/crypto.test.d.ts.map +0 -1
- package/dist/__tests__/crypto.test.js +0 -153
- package/dist/__tests__/crypto.test.js.map +0 -1
- package/dist/auto-enhance.d.ts +0 -41
- package/dist/auto-enhance.d.ts.map +0 -1
- package/dist/auto-enhance.js +0 -193
- package/dist/auto-enhance.js.map +0 -1
- package/dist/auto-init.d.ts +0 -12
- package/dist/auto-init.d.ts.map +0 -1
- package/dist/auto-init.js +0 -166
- package/dist/auto-init.js.map +0 -1
- package/dist/auto.d.ts.map +0 -1
- package/dist/auto.js.map +0 -1
- package/dist/crypto.d.ts.map +0 -1
- package/dist/crypto.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/patch.d.ts +0 -22
- package/dist/patch.d.ts.map +0 -1
- package/dist/patch.js +0 -164
- package/dist/patch.js.map +0 -1
- package/dist/transparent.d.ts +0 -40
- package/dist/transparent.d.ts.map +0 -1
- package/dist/transparent.js +0 -167
- package/dist/transparent.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initWithDevExperience = initWithDevExperience;
|
|
4
|
+
exports.showAgentStatus = showAgentStatus;
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
7
|
+
async function initWithDevExperience(options = {}) {
|
|
8
|
+
const logger = (0, logger_1.getLogger)();
|
|
9
|
+
if (process.env.NODE_ENV === 'development' && !options.mode) {
|
|
10
|
+
options.mode = 'development';
|
|
11
|
+
logger.info('🔧 Development mode detected - agents will be created as drafts');
|
|
12
|
+
}
|
|
13
|
+
if (!options.name && !process.env.MCP_SERVER_NAME) {
|
|
14
|
+
try {
|
|
15
|
+
const pkg = require(process.cwd() + '/package.json');
|
|
16
|
+
options.name = pkg.name || 'Unnamed MCP Server';
|
|
17
|
+
options.description = pkg.description;
|
|
18
|
+
options.repository = pkg.repository?.url || pkg.repository;
|
|
19
|
+
logger.info(`📦 Auto-detected agent name: ${options.name}`);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
options.name = 'Development MCP Server';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!options.storage) {
|
|
26
|
+
logger.info('💡 Tip: Use storage: "file" for persistent identity across restarts');
|
|
27
|
+
}
|
|
28
|
+
const identity = await index_1.MCPIdentity.init(options);
|
|
29
|
+
logger.info('✨ MCP Identity initialized successfully!');
|
|
30
|
+
logger.info(`🆔 DID: ${identity.did}`);
|
|
31
|
+
const { claimUrl } = await identity.requestEditAccess();
|
|
32
|
+
logger.info(`🔗 Claim your agent: ${claimUrl}`);
|
|
33
|
+
logger.info('💡 Your MCP server responses are now automatically signed with your agent identity');
|
|
34
|
+
return identity;
|
|
35
|
+
}
|
|
36
|
+
function showAgentStatus(identity) {
|
|
37
|
+
const logger = (0, logger_1.getLogger)();
|
|
38
|
+
const capabilities = identity.getCapabilities();
|
|
39
|
+
logger.info('📊 Agent Status:');
|
|
40
|
+
logger.info(` DID: ${identity.did}`);
|
|
41
|
+
logger.info(` Conformance Level: ${capabilities.conformanceLevel}`);
|
|
42
|
+
logger.info(` Registry: ${capabilities.registry || 'knowthat.ai'}`);
|
|
43
|
+
logger.info(` Handshake Supported: ${capabilities.handshakeSupported}`);
|
|
44
|
+
const directories = identity.getDirectories();
|
|
45
|
+
if (directories === 'none') {
|
|
46
|
+
logger.info('📋 Directories: Not listing on any directories');
|
|
47
|
+
}
|
|
48
|
+
else if (directories === 'verified') {
|
|
49
|
+
logger.info('📋 Directories: Listing on all verified directories');
|
|
50
|
+
}
|
|
51
|
+
else if (Array.isArray(directories)) {
|
|
52
|
+
logger.info(`📋 Directories: ${directories.join(', ')}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StorageProvider } from './storage';
|
|
2
|
+
import { PersistedIdentity } from './types';
|
|
3
|
+
export declare class EncryptedStorage implements StorageProvider {
|
|
4
|
+
private baseStorage;
|
|
5
|
+
private password;
|
|
6
|
+
constructor(baseStorage: StorageProvider, password: string);
|
|
7
|
+
load(): Promise<PersistedIdentity | null>;
|
|
8
|
+
save(identity: PersistedIdentity): Promise<void>;
|
|
9
|
+
exists(): Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createEncryptedStorage(baseStorage: StorageProvider, password: string): StorageProvider;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EncryptedStorage = void 0;
|
|
37
|
+
exports.createEncryptedStorage = createEncryptedStorage;
|
|
38
|
+
const crypto = __importStar(require("./crypto"));
|
|
39
|
+
class EncryptedStorage {
|
|
40
|
+
constructor(baseStorage, password) {
|
|
41
|
+
this.baseStorage = baseStorage;
|
|
42
|
+
this.password = password;
|
|
43
|
+
}
|
|
44
|
+
async load() {
|
|
45
|
+
const identity = await this.baseStorage.load();
|
|
46
|
+
if (!identity) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (identity.privateKey.startsWith('enc:')) {
|
|
50
|
+
try {
|
|
51
|
+
identity.privateKey = await crypto.decrypt(identity.privateKey, this.password);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw new Error('Failed to decrypt stored identity - invalid password');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return identity;
|
|
58
|
+
}
|
|
59
|
+
async save(identity) {
|
|
60
|
+
const encryptedIdentity = { ...identity };
|
|
61
|
+
if (!encryptedIdentity.privateKey.startsWith('enc:')) {
|
|
62
|
+
encryptedIdentity.privateKey = await crypto.encrypt(encryptedIdentity.privateKey, this.password);
|
|
63
|
+
}
|
|
64
|
+
await this.baseStorage.save(encryptedIdentity);
|
|
65
|
+
}
|
|
66
|
+
async exists() {
|
|
67
|
+
return this.baseStorage.exists();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.EncryptedStorage = EncryptedStorage;
|
|
71
|
+
function createEncryptedStorage(baseStorage, password) {
|
|
72
|
+
return new EncryptedStorage(baseStorage, password);
|
|
73
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Enable any MCP server to get a verifiable identity with just 2 lines of code:
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* import "@kya-os/mcp-i/auto"; // That's it! Your server now has identity
|
|
8
|
-
* ```
|
|
9
|
-
*
|
|
10
|
-
* Or with configuration:
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { enableMCPIdentity } from "@kya-os/mcp-i";
|
|
13
|
-
* await enableMCPIdentity({ name: "My Amazing Agent" });
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
import { MCPIdentityOptions, Challenge, ChallengeResponse, MCPICapabilities, SignedResponse } from './types';
|
|
1
|
+
import { MCPIdentityOptions, Challenge, ChallengeResponse, MCPICapabilities, SignedResponse, MCPMiddleware, DirectoryPreference } from './types';
|
|
2
|
+
import { KeyRotationResult, KeyHealth } from './rotation';
|
|
17
3
|
export * from './types';
|
|
4
|
+
export { RegistryFactory, REGISTRY_TIERS, resolveRegistries } from './registry';
|
|
5
|
+
export { LoggerFactory, ConsoleLogger, SilentLogger } from './logger';
|
|
6
|
+
export { StorageFactory, MemoryStorage, FileStorage } from './storage';
|
|
7
|
+
export { TransportFactory, RuntimeDetector } from './transport';
|
|
8
|
+
export { KeyRotationManager } from './rotation';
|
|
9
|
+
export { initWithDevExperience, showAgentStatus } from './dev-helper';
|
|
18
10
|
export declare class MCPIdentity {
|
|
19
11
|
readonly did: string;
|
|
20
12
|
readonly publicKey: string;
|
|
@@ -23,47 +15,40 @@ export declare class MCPIdentity {
|
|
|
23
15
|
private enableNonceTracking;
|
|
24
16
|
private usedNonces;
|
|
25
17
|
private nonceCleanupInterval?;
|
|
18
|
+
private encryptionPassword?;
|
|
19
|
+
private decryptedPrivateKey?;
|
|
20
|
+
private directories;
|
|
21
|
+
private storage;
|
|
22
|
+
private transport;
|
|
23
|
+
private logger;
|
|
24
|
+
private rotationManager?;
|
|
25
|
+
private precomputed;
|
|
26
26
|
private constructor();
|
|
27
|
-
/**
|
|
28
|
-
* Initialize MCP Identity - the main entry point
|
|
29
|
-
*/
|
|
30
27
|
static init(options?: MCPIdentityOptions): Promise<MCPIdentity>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
enableAutoRotation(policy?: {
|
|
29
|
+
maxAge?: number;
|
|
30
|
+
maxSignatures?: number;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
rotateKeys(reason?: string): Promise<KeyRotationResult>;
|
|
33
|
+
checkKeyHealth(): KeyHealth | null;
|
|
34
|
+
private getPrivateKey;
|
|
34
35
|
sign(message: string | Buffer): Promise<string>;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
requestEditAccess(): Promise<{
|
|
37
|
+
editUrl: string;
|
|
38
|
+
claimUrl?: string;
|
|
39
|
+
}>;
|
|
38
40
|
verify(message: string | Buffer, signature: string, publicKey?: string): Promise<boolean>;
|
|
39
|
-
/**
|
|
40
|
-
* Respond to an MCP-I challenge
|
|
41
|
-
*/
|
|
42
41
|
respondToChallenge(challenge: Challenge): Promise<ChallengeResponse>;
|
|
43
|
-
/**
|
|
44
|
-
* Get MCP-I capabilities for advertisement
|
|
45
|
-
*/
|
|
46
42
|
getCapabilities(): MCPICapabilities;
|
|
47
|
-
/**
|
|
48
|
-
* Sign an MCP response with identity metadata
|
|
49
|
-
*/
|
|
50
43
|
signResponse<T = any>(response: T): Promise<SignedResponse<T>>;
|
|
51
|
-
/**
|
|
52
|
-
* Generate a new nonce for challenges
|
|
53
|
-
*/
|
|
54
44
|
static generateNonce(): string;
|
|
55
|
-
|
|
56
|
-
* Clean up old nonces periodically to prevent memory leaks
|
|
57
|
-
*/
|
|
45
|
+
getDirectories(): DirectoryPreference;
|
|
58
46
|
private startNonceCleanup;
|
|
59
|
-
/**
|
|
60
|
-
* Clean up resources
|
|
61
|
-
*/
|
|
62
47
|
destroy(): void;
|
|
48
|
+
private extractAgentName;
|
|
49
|
+
private extractAgentId;
|
|
50
|
+
private extractAgentSlug;
|
|
51
|
+
private persistIdentity;
|
|
63
52
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Enable MCP Identity for any MCP server
|
|
66
|
-
* This is the main integration point that patches the MCP Server
|
|
67
|
-
*/
|
|
68
53
|
export declare function enableMCPIdentity(options?: MCPIdentityOptions): Promise<MCPIdentity>;
|
|
69
|
-
|
|
54
|
+
export declare function createMCPMiddleware(identity: MCPIdentity): MCPMiddleware;
|