@kya-os/mcp-i 0.1.0-alpha.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -108
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +206 -0
- package/dist/index.js.map +1 -0
- package/package.json +15 -27
package/README.md
CHANGED
|
@@ -1,144 +1,117 @@
|
|
|
1
1
|
# @kya-os/mcp-i
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Ultra-light MCP Identity auto-registration - Get agent identity with just 2 lines of code!
|
|
4
4
|
|
|
5
|
-
## 🚀
|
|
5
|
+
## 🚀 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @kya-os/mcp-i
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 💡 Usage
|
|
6
12
|
|
|
7
13
|
```typescript
|
|
8
14
|
import { MCPIdentity } from "@kya-os/mcp-i";
|
|
9
|
-
const identity = await MCPIdentity.init(); // That's it!
|
|
10
|
-
```
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
// That's it! Your MCP server now has identity
|
|
17
|
+
const identity = await MCPIdentity.init();
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
console.log("My DID:", identity.did);
|
|
20
|
+
// Output: did:web:knowthat.ai:agents:your-server-name
|
|
21
|
+
```
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
2. **Future Runs**: Loads the saved identity
|
|
18
|
-
3. **Every Response**: Adds verifiable identity metadata
|
|
19
|
-
4. **Zero Config**: Works out of the box
|
|
23
|
+
## 🎯 What It Does
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
1. **First Run**: Automatically registers your MCP server with knowthat.ai
|
|
26
|
+
2. **Gets DID**: Receives a decentralized identifier for your agent
|
|
27
|
+
3. **Saves Identity**: Stores credentials in `.env.local` and `.mcp-identity.json`
|
|
28
|
+
4. **Future Runs**: Loads existing identity (no re-registration)
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
- 🔝 **Priority Discovery** in search results
|
|
25
|
-
- 🔐 **Identity-Aware Features** from services
|
|
26
|
-
- 📊 **Analytics & Reputation** tracking
|
|
27
|
-
- 🛡️ **Protection Against Impersonation**
|
|
30
|
+
## ✨ Features
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
- **Zero Configuration**: Works out of the box
|
|
33
|
+
- **Ultra-Light**: Only depends on `axios`
|
|
34
|
+
- **No Other Dependencies**: Completely standalone package
|
|
35
|
+
- **Persistent Identity**: Same DID across restarts
|
|
36
|
+
- **Verification Badges**: Get verified status in MCP directories
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
## 🔧 Options
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const identity = await MCPIdentity.init({
|
|
42
|
+
name: "My Awesome MCP Server", // Optional: Server name
|
|
43
|
+
description: "Does amazing things", // Optional: Description
|
|
44
|
+
repository: "https://github.com/...", // Optional: GitHub URL
|
|
45
|
+
apiEndpoint: "https://knowthat.ai" // Optional: Custom endpoint
|
|
46
|
+
});
|
|
33
47
|
```
|
|
34
48
|
|
|
35
|
-
##
|
|
49
|
+
## 📁 Identity Storage
|
|
50
|
+
|
|
51
|
+
The package stores identity in multiple locations (checked in order):
|
|
52
|
+
|
|
53
|
+
1. **Environment Variables**
|
|
54
|
+
- `AGENT_DID`
|
|
55
|
+
- `AGENT_PUBLIC_KEY`
|
|
56
|
+
- `AGENT_PRIVATE_KEY`
|
|
57
|
+
|
|
58
|
+
2. **Local Files**
|
|
59
|
+
- `.env.local` (auto-generated)
|
|
60
|
+
- `.mcp-identity.json` (auto-generated)
|
|
61
|
+
|
|
62
|
+
## 🔐 Security
|
|
63
|
+
|
|
64
|
+
- Private keys are stored locally only
|
|
65
|
+
- Never share your `.env.local` or `.mcp-identity.json` files
|
|
66
|
+
- Add them to `.gitignore`
|
|
67
|
+
|
|
68
|
+
## 🤝 Integration with MCP Servers
|
|
36
69
|
|
|
37
70
|
```typescript
|
|
38
71
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
39
72
|
import { MCPIdentity } from "@kya-os/mcp-i";
|
|
40
73
|
|
|
41
|
-
// Initialize identity
|
|
74
|
+
// Initialize identity
|
|
42
75
|
const identity = await MCPIdentity.init({
|
|
43
|
-
|
|
44
|
-
name: "My Awesome MCP Server",
|
|
45
|
-
description: "Does amazing things with AI",
|
|
46
|
-
repository: "https://github.com/myusername/my-server",
|
|
47
|
-
categories: ["productivity", "automation"]
|
|
48
|
-
}
|
|
76
|
+
name: "Calendar Booker"
|
|
49
77
|
});
|
|
50
78
|
|
|
51
|
-
//
|
|
79
|
+
// Pass to your MCP server
|
|
52
80
|
const server = new Server({
|
|
53
|
-
name: "
|
|
81
|
+
name: "calendar-booker",
|
|
54
82
|
version: "1.0.0",
|
|
55
|
-
//
|
|
56
|
-
identity
|
|
83
|
+
identity // Your server now has verifiable identity!
|
|
57
84
|
});
|
|
58
|
-
|
|
59
|
-
// Your server now has a verifiable identity!
|
|
60
85
|
```
|
|
61
86
|
|
|
62
|
-
## What Happens
|
|
87
|
+
## 📊 What Happens After Registration
|
|
63
88
|
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
1. **Profile Created**: `https://knowthat.ai/agents/your-server-slug`
|
|
90
|
+
2. **Verification Badge**: Shows "Auto-Registered" status
|
|
91
|
+
3. **DID Resolution**: Your DID becomes resolvable immediately
|
|
92
|
+
4. **Trust Building**: Usage builds reputation over time
|
|
66
93
|
|
|
67
|
-
|
|
68
|
-
[MCP-I] ✅ Success! Your agent has been registered.
|
|
69
|
-
[MCP-I] DID: did:web:knowthat.ai:agents:my-awesome-server
|
|
70
|
-
[MCP-I] Profile: https://knowthat.ai/agents/my-awesome-server
|
|
71
|
-
[MCP-I] Identity saved to .env.local
|
|
72
|
-
```
|
|
94
|
+
## 🚨 Troubleshooting
|
|
73
95
|
|
|
74
|
-
|
|
96
|
+
### Rate Limiting
|
|
97
|
+
If you see "Rate limit exceeded", wait a few minutes and try again. The API allows 10 registrations per hour per IP.
|
|
75
98
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// Agent metadata for registration
|
|
79
|
-
metadata?: {
|
|
80
|
-
name: string;
|
|
81
|
-
description?: string;
|
|
82
|
-
repository?: string;
|
|
83
|
-
categories?: string[];
|
|
84
|
-
version?: string;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// Advanced options
|
|
88
|
-
apiEndpoint?: string; // Custom API endpoint
|
|
89
|
-
autoRegister?: boolean; // Disable auto-registration
|
|
90
|
-
persistenceBackend?: string; // 'env' | 'file' | 'keychain' | 'auto'
|
|
91
|
-
persistencePath?: string; // Custom storage path
|
|
92
|
-
}
|
|
93
|
-
```
|
|
99
|
+
### No Identity Found
|
|
100
|
+
Make sure you have write permissions in your project directory for saving the identity files.
|
|
94
101
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
The SDK automatically saves your identity in the most appropriate location:
|
|
98
|
-
|
|
99
|
-
1. **Environment Variables** (.env.local)
|
|
100
|
-
```
|
|
101
|
-
AGENT_DID="did:web:knowthat.ai:agents:my-server"
|
|
102
|
-
AGENT_PRIVATE_KEY_ENCRYPTED="..."
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
2. **Configuration File** (mcp-identity.json)
|
|
106
|
-
```json
|
|
107
|
-
{
|
|
108
|
-
"did": "did:web:knowthat.ai:agents:my-server",
|
|
109
|
-
"publicKey": "...",
|
|
110
|
-
"privateKey": "..."
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
3. **System Keychain** (coming soon)
|
|
115
|
-
- macOS Keychain
|
|
116
|
-
- Windows Credential Manager
|
|
117
|
-
- Linux Secret Service
|
|
118
|
-
|
|
119
|
-
## How Identity Flows Through MCP
|
|
120
|
-
|
|
121
|
-
Once initialized, your identity automatically:
|
|
122
|
-
|
|
123
|
-
- Signs all MCP responses
|
|
124
|
-
- Responds to identity challenges
|
|
125
|
-
- Advertises capabilities
|
|
126
|
-
- Builds reputation over time
|
|
127
|
-
|
|
128
|
-
Example response with identity:
|
|
129
|
-
|
|
130
|
-
```json
|
|
131
|
-
{
|
|
132
|
-
"result": "Task completed successfully",
|
|
133
|
-
"_mcp_identity": {
|
|
134
|
-
"did": "did:web:knowthat.ai:agents:my-server",
|
|
135
|
-
"signature": "0x3045...",
|
|
136
|
-
"timestamp": "2025-01-31T10:00:00Z",
|
|
137
|
-
"conformanceLevel": 1
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
```
|
|
102
|
+
### Network Issues
|
|
103
|
+
The package needs to reach `https://knowthat.ai` for auto-registration. Check your network connection and proxy settings.
|
|
141
104
|
|
|
142
|
-
## License
|
|
105
|
+
## 📄 License
|
|
143
106
|
|
|
144
107
|
MIT
|
|
108
|
+
|
|
109
|
+
## 🔗 Links
|
|
110
|
+
|
|
111
|
+
- [KYA-OS Documentation](https://docs.kya-os.com)
|
|
112
|
+
- [MCP-I Specification](https://github.com/vouched/kya-os/blob/main/docs/mcp-i.md)
|
|
113
|
+
- [Report Issues](https://github.com/vouched/kya-os/issues)
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
Made with ❤️ by the KYA-OS team
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kya-os/mcp-i - Ultra-light MCP Identity auto-registration
|
|
3
|
+
*
|
|
4
|
+
* Enable any MCP server to get a verifiable identity with just 2 lines of code:
|
|
5
|
+
*
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { MCPIdentity } from "@kya-os/mcp-i";
|
|
8
|
+
* const identity = await MCPIdentity.init();
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Zero dependencies on other @kya-os packages - completely standalone!
|
|
12
|
+
*/
|
|
13
|
+
interface MCPIdentityOptions {
|
|
14
|
+
name?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
repository?: string;
|
|
17
|
+
apiEndpoint?: string;
|
|
18
|
+
persistencePath?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class MCPIdentity {
|
|
21
|
+
readonly did: string;
|
|
22
|
+
readonly publicKey: string;
|
|
23
|
+
private privateKey;
|
|
24
|
+
private constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Initialize MCP Identity - the main entry point
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { MCPIdentity } from "@kya-os/mcp-i";
|
|
31
|
+
* const identity = await MCPIdentity.init();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
static init(options?: MCPIdentityOptions): Promise<MCPIdentity>;
|
|
35
|
+
/**
|
|
36
|
+
* Sign a message with the agent's private key
|
|
37
|
+
*/
|
|
38
|
+
sign(message: string): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Get MCP-I capabilities
|
|
41
|
+
*/
|
|
42
|
+
getCapabilities(): {
|
|
43
|
+
version: string;
|
|
44
|
+
did: string;
|
|
45
|
+
publicKey: string;
|
|
46
|
+
conformanceLevel: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Sign an MCP response
|
|
50
|
+
*/
|
|
51
|
+
signResponse(response: any): any;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA0BD,qBAAa,WAAW;IACtB,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO;IAMP;;;;;;;;OAQG;WACU,IAAI,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAoCrE;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK5C;;OAEG;IACH,eAAe;;;;;;IASf;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG;CAUjC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @kya-os/mcp-i - Ultra-light MCP Identity auto-registration
|
|
4
|
+
*
|
|
5
|
+
* Enable any MCP server to get a verifiable identity with just 2 lines of code:
|
|
6
|
+
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { MCPIdentity } from "@kya-os/mcp-i";
|
|
9
|
+
* const identity = await MCPIdentity.init();
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Zero dependencies on other @kya-os packages - completely standalone!
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.MCPIdentity = void 0;
|
|
52
|
+
const axios_1 = __importDefault(require("axios"));
|
|
53
|
+
const fs = __importStar(require("fs"));
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
class MCPIdentity {
|
|
56
|
+
constructor(identity) {
|
|
57
|
+
this.did = identity.did;
|
|
58
|
+
this.publicKey = identity.publicKey;
|
|
59
|
+
this.privateKey = identity.privateKey;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Initialize MCP Identity - the main entry point
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { MCPIdentity } from "@kya-os/mcp-i";
|
|
67
|
+
* const identity = await MCPIdentity.init();
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
static async init(options) {
|
|
71
|
+
// Try to load existing identity
|
|
72
|
+
let identity = await loadIdentity(options?.persistencePath);
|
|
73
|
+
// Auto-register if needed
|
|
74
|
+
if (!identity) {
|
|
75
|
+
console.log('[MCP-I] No existing identity found, auto-registering...');
|
|
76
|
+
const response = await autoRegister({
|
|
77
|
+
name: options?.name || process.env.MCP_SERVER_NAME || 'Unnamed MCP Server',
|
|
78
|
+
description: options?.description,
|
|
79
|
+
repository: options?.repository,
|
|
80
|
+
apiEndpoint: options?.apiEndpoint || 'https://knowthat.ai'
|
|
81
|
+
});
|
|
82
|
+
// Create persisted identity
|
|
83
|
+
identity = {
|
|
84
|
+
did: response.did,
|
|
85
|
+
publicKey: response.keys.publicKey,
|
|
86
|
+
privateKey: response.keys.privateKey || '',
|
|
87
|
+
agentId: response.agent.id,
|
|
88
|
+
agentSlug: response.agent.slug,
|
|
89
|
+
registeredAt: new Date().toISOString(),
|
|
90
|
+
};
|
|
91
|
+
// Save for future use
|
|
92
|
+
await saveIdentity(identity, options?.persistencePath);
|
|
93
|
+
console.log('[MCP-I] ✅ Success! Your agent has been registered.');
|
|
94
|
+
console.log(`[MCP-I] DID: ${response.did}`);
|
|
95
|
+
console.log(`[MCP-I] Profile: ${response.agent.url}`);
|
|
96
|
+
}
|
|
97
|
+
return new MCPIdentity(identity);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Sign a message with the agent's private key
|
|
101
|
+
*/
|
|
102
|
+
async sign(message) {
|
|
103
|
+
// Simple signature for demo - in production use proper crypto
|
|
104
|
+
return Buffer.from(`${this.privateKey}:${message}`).toString('base64');
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get MCP-I capabilities
|
|
108
|
+
*/
|
|
109
|
+
getCapabilities() {
|
|
110
|
+
return {
|
|
111
|
+
version: '1.0',
|
|
112
|
+
did: this.did,
|
|
113
|
+
publicKey: this.publicKey,
|
|
114
|
+
conformanceLevel: 1
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Sign an MCP response
|
|
119
|
+
*/
|
|
120
|
+
signResponse(response) {
|
|
121
|
+
return {
|
|
122
|
+
...response,
|
|
123
|
+
_mcp_identity: {
|
|
124
|
+
did: this.did,
|
|
125
|
+
signature: this.sign(JSON.stringify(response)),
|
|
126
|
+
timestamp: new Date().toISOString()
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.MCPIdentity = MCPIdentity;
|
|
132
|
+
// Helper functions (inline to keep package standalone)
|
|
133
|
+
async function loadIdentity(customPath) {
|
|
134
|
+
// Check environment variables first
|
|
135
|
+
if (process.env.AGENT_DID && process.env.AGENT_PUBLIC_KEY && process.env.AGENT_PRIVATE_KEY) {
|
|
136
|
+
return {
|
|
137
|
+
did: process.env.AGENT_DID,
|
|
138
|
+
publicKey: process.env.AGENT_PUBLIC_KEY,
|
|
139
|
+
privateKey: process.env.AGENT_PRIVATE_KEY,
|
|
140
|
+
agentId: process.env.AGENT_ID || '',
|
|
141
|
+
agentSlug: process.env.AGENT_SLUG || '',
|
|
142
|
+
registeredAt: new Date().toISOString()
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
// Check file
|
|
146
|
+
const filePath = customPath || path.join(process.cwd(), '.mcp-identity.json');
|
|
147
|
+
try {
|
|
148
|
+
if (fs.existsSync(filePath)) {
|
|
149
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
150
|
+
return JSON.parse(content);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// Ignore errors
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
async function saveIdentity(identity, customPath) {
|
|
159
|
+
// Save to .env.local
|
|
160
|
+
const envContent = `
|
|
161
|
+
# MCP-I Identity (auto-generated)
|
|
162
|
+
AGENT_DID="${identity.did}"
|
|
163
|
+
AGENT_PUBLIC_KEY="${identity.publicKey}"
|
|
164
|
+
AGENT_PRIVATE_KEY="${identity.privateKey}"
|
|
165
|
+
AGENT_ID="${identity.agentId}"
|
|
166
|
+
AGENT_SLUG="${identity.agentSlug}"
|
|
167
|
+
`;
|
|
168
|
+
const envPath = path.join(process.cwd(), '.env.local');
|
|
169
|
+
fs.writeFileSync(envPath, envContent.trim());
|
|
170
|
+
// Also save as JSON
|
|
171
|
+
const filePath = customPath || path.join(process.cwd(), '.mcp-identity.json');
|
|
172
|
+
fs.writeFileSync(filePath, JSON.stringify(identity, null, 2));
|
|
173
|
+
}
|
|
174
|
+
async function autoRegister(options) {
|
|
175
|
+
try {
|
|
176
|
+
const response = await axios_1.default.post(`${options.apiEndpoint}/api/agents/auto-register`, {
|
|
177
|
+
metadata: {
|
|
178
|
+
name: options.name,
|
|
179
|
+
description: options.description,
|
|
180
|
+
repository: options.repository,
|
|
181
|
+
version: '1.0.0'
|
|
182
|
+
},
|
|
183
|
+
clientInfo: {
|
|
184
|
+
sdkVersion: '0.1.0',
|
|
185
|
+
language: 'typescript',
|
|
186
|
+
platform: 'node' // Always node for MCP servers
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
timeout: 30000,
|
|
190
|
+
headers: {
|
|
191
|
+
'Content-Type': 'application/json',
|
|
192
|
+
'User-Agent': '@kya-os/mcp-i/0.1.0'
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return response.data;
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (error.response?.status === 429) {
|
|
199
|
+
throw new Error('Rate limit exceeded. Please try again later.');
|
|
200
|
+
}
|
|
201
|
+
throw new Error(error.response?.data?.message ||
|
|
202
|
+
error.message ||
|
|
203
|
+
'Failed to auto-register agent');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mapp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ya-os/mcp-i",
|
|
3
|
-
"version": "0.1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Ultra-light MCP Identity auto-registration - 2 lines to agent identity",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -12,40 +12,28 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc",
|
|
14
14
|
"test": "jest",
|
|
15
|
-
"
|
|
16
|
-
"clean": "rm -rf dist",
|
|
17
|
-
"prepublishOnly": "npm run clean && npm run build && npm run test",
|
|
18
|
-
"publish:alpha": "npm publish --tag alpha"
|
|
19
|
-
},
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "https://github.com/vouched/kya-os.git",
|
|
23
|
-
"directory": "packages/mcp-i"
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
24
16
|
},
|
|
25
17
|
"keywords": [
|
|
26
|
-
"kya-os",
|
|
27
|
-
"mcp-i",
|
|
28
18
|
"mcp",
|
|
19
|
+
"mcp-i",
|
|
29
20
|
"identity",
|
|
21
|
+
"agent",
|
|
30
22
|
"auto-registration",
|
|
31
|
-
"
|
|
23
|
+
"did"
|
|
32
24
|
],
|
|
33
|
-
"author": "Dylan Hobbs <dylan
|
|
25
|
+
"author": "Dylan Hobbs <dylan@vouched.id>",
|
|
34
26
|
"license": "MIT",
|
|
35
27
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"@kya-os/identity": "^0.1.0-alpha.1",
|
|
38
|
-
"axios": "^1.6.7",
|
|
39
|
-
"dotenv": "^16.5.0"
|
|
28
|
+
"axios": "^1.6.7"
|
|
40
29
|
},
|
|
41
30
|
"devDependencies": {
|
|
42
|
-
"@types/
|
|
43
|
-
"
|
|
44
|
-
"jest": "^29.
|
|
45
|
-
"
|
|
46
|
-
"typescript": "^5.4.2"
|
|
31
|
+
"@types/node": "^20.0.0",
|
|
32
|
+
"typescript": "^5.0.0",
|
|
33
|
+
"jest": "^29.0.0",
|
|
34
|
+
"@types/jest": "^29.0.0"
|
|
47
35
|
},
|
|
48
|
-
"
|
|
49
|
-
"
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=14.0.0"
|
|
50
38
|
}
|
|
51
|
-
}
|
|
39
|
+
}
|