@hashgraphonline/standards-sdk 0.0.120 → 0.0.122
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/dist/cjs/hcs-11/client.d.ts +18 -1
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-11/index.d.ts +1 -0
- package/dist/cjs/hcs-11/index.d.ts.map +1 -1
- package/dist/cjs/hcs-11/mcp-server-builder.d.ts +118 -0
- package/dist/cjs/hcs-11/mcp-server-builder.d.ts.map +1 -0
- package/dist/cjs/hcs-11/types.d.ts +77 -18
- package/dist/cjs/hcs-11/types.d.ts.map +1 -1
- package/dist/cjs/{index-CHar8dVv-B2IK-7-2.cjs → index-CHar8dVv-BkACF223.cjs} +2 -2
- package/dist/cjs/{index-CHar8dVv-B2IK-7-2.cjs.map → index-CHar8dVv-BkACF223.cjs.map} +1 -1
- package/dist/cjs/index-DjDDRcKz.cjs +11 -0
- package/dist/cjs/index-DjDDRcKz.cjs.map +1 -0
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/es/hcs-11/client.d.ts +18 -1
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-11/index.d.ts +1 -0
- package/dist/es/hcs-11/index.d.ts.map +1 -1
- package/dist/es/hcs-11/mcp-server-builder.d.ts +118 -0
- package/dist/es/hcs-11/mcp-server-builder.d.ts.map +1 -0
- package/dist/es/hcs-11/types.d.ts +77 -18
- package/dist/es/hcs-11/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +17 -12
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es10.js +1 -1
- package/dist/es/standards-sdk.es11.js +2 -2
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es13.js +226 -639
- package/dist/es/standards-sdk.es13.js.map +1 -1
- package/dist/es/standards-sdk.es14.js +770 -85
- package/dist/es/standards-sdk.es14.js.map +1 -1
- package/dist/es/standards-sdk.es15.js +132 -68
- package/dist/es/standards-sdk.es15.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +66 -19
- package/dist/es/standards-sdk.es16.js.map +1 -1
- package/dist/es/standards-sdk.es17.js +18 -156
- package/dist/es/standards-sdk.es17.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +150 -146
- package/dist/es/standards-sdk.es18.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +134 -561
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es2.js +1 -1
- package/dist/es/standards-sdk.es20.js +577 -24
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +23 -400
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +381 -1507
- package/dist/es/standards-sdk.es22.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +1511 -133
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +155 -7
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +7 -7190
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +7190 -2
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +2 -501
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +456 -64
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +79 -36
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es3.js +1 -1
- package/dist/es/standards-sdk.es30.js +32 -222
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +183 -100
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +167 -5
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +8 -7132
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +7138 -0
- package/dist/es/standards-sdk.es35.js.map +1 -0
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es5.js +4 -4
- package/dist/es/standards-sdk.es7.js +7 -7
- package/dist/es/standards-sdk.es8.js +5 -5
- package/dist/es/standards-sdk.es9.js +2 -2
- package/dist/umd/hcs-11/client.d.ts +18 -1
- package/dist/umd/hcs-11/client.d.ts.map +1 -1
- package/dist/umd/hcs-11/index.d.ts +1 -0
- package/dist/umd/hcs-11/index.d.ts.map +1 -1
- package/dist/umd/hcs-11/mcp-server-builder.d.ts +118 -0
- package/dist/umd/hcs-11/mcp-server-builder.d.ts.map +1 -0
- package/dist/umd/hcs-11/types.d.ts +77 -18
- package/dist/umd/hcs-11/types.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +12 -12
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/index-CHS2J8pS.cjs +0 -11
- package/dist/cjs/index-CHS2J8pS.cjs.map +0 -1
|
@@ -1,690 +1,277 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import "ethers";
|
|
10
|
-
import { detectKeyTypeFromString } from "./standards-sdk.es20.js";
|
|
11
|
-
import * as mime from "mime-types";
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
import { AIAgentCapability, AIAgentType, ProfileType, capabilityNameToCapabilityMap } from "./standards-sdk.es14.js";
|
|
14
|
-
const SocialLinkSchema = z.object({
|
|
15
|
-
platform: z.string().min(1),
|
|
16
|
-
handle: z.string().min(1)
|
|
17
|
-
});
|
|
18
|
-
const AIAgentDetailsSchema = z.object({
|
|
19
|
-
type: z.nativeEnum(AIAgentType),
|
|
20
|
-
capabilities: z.array(z.nativeEnum(AIAgentCapability)).min(1),
|
|
21
|
-
model: z.string().min(1),
|
|
22
|
-
creator: z.string().optional()
|
|
23
|
-
});
|
|
24
|
-
const BaseProfileSchema = z.object({
|
|
25
|
-
version: z.string().min(1),
|
|
26
|
-
type: z.nativeEnum(ProfileType),
|
|
27
|
-
display_name: z.string().min(1),
|
|
28
|
-
alias: z.string().optional(),
|
|
29
|
-
bio: z.string().optional(),
|
|
30
|
-
socials: z.array(SocialLinkSchema).optional(),
|
|
31
|
-
profileImage: z.string().optional(),
|
|
32
|
-
properties: z.record(z.any()).optional(),
|
|
33
|
-
inboundTopicId: z.string().optional(),
|
|
34
|
-
outboundTopicId: z.string().optional()
|
|
35
|
-
});
|
|
36
|
-
const PersonalProfileSchema = BaseProfileSchema.extend({
|
|
37
|
-
type: z.literal(ProfileType.PERSONAL),
|
|
38
|
-
language: z.string().optional(),
|
|
39
|
-
timezone: z.string().optional()
|
|
40
|
-
});
|
|
41
|
-
const AIAgentProfileSchema = BaseProfileSchema.extend({
|
|
42
|
-
type: z.literal(ProfileType.AI_AGENT),
|
|
43
|
-
aiAgent: AIAgentDetailsSchema
|
|
44
|
-
});
|
|
45
|
-
const HCS11ProfileSchema = z.union([
|
|
46
|
-
PersonalProfileSchema,
|
|
47
|
-
AIAgentProfileSchema
|
|
48
|
-
]);
|
|
49
|
-
class HCS11Client {
|
|
50
|
-
constructor(config) {
|
|
51
|
-
this.client = config.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
|
|
52
|
-
this.auth = config.auth;
|
|
53
|
-
this.network = config.network;
|
|
54
|
-
this.operatorId = config.auth.operatorId;
|
|
1
|
+
import { VerificationType } from "./standards-sdk.es15.js";
|
|
2
|
+
import { Logger } from "./standards-sdk.es16.js";
|
|
3
|
+
class MCPServerBuilder {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.config = {
|
|
6
|
+
mcpServer: {}
|
|
7
|
+
};
|
|
8
|
+
this.socials = [];
|
|
55
9
|
this.logger = Logger.getInstance({
|
|
56
|
-
|
|
57
|
-
module: "HCS-11",
|
|
58
|
-
silent: config.silent
|
|
10
|
+
module: "MCPServerBuilder"
|
|
59
11
|
});
|
|
60
|
-
this.mirrorNode = new HederaMirrorNode(
|
|
61
|
-
this.network,
|
|
62
|
-
this.logger
|
|
63
|
-
);
|
|
64
|
-
if (this.auth.privateKey) {
|
|
65
|
-
if (config.keyType) {
|
|
66
|
-
this.keyType = config.keyType;
|
|
67
|
-
this.initializeOperatorWithKeyType();
|
|
68
|
-
} else {
|
|
69
|
-
try {
|
|
70
|
-
const keyDetection = detectKeyTypeFromString(this.auth.privateKey);
|
|
71
|
-
this.keyType = keyDetection.detectedType;
|
|
72
|
-
this.client.setOperator(this.operatorId, keyDetection.privateKey);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
this.logger.warn("Failed to detect key type from private key format, will query mirror node");
|
|
75
|
-
this.keyType = "ed25519";
|
|
76
|
-
}
|
|
77
|
-
this.initializeOperator();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
12
|
}
|
|
81
|
-
|
|
82
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Sets the display name of the MCP server
|
|
15
|
+
*/
|
|
16
|
+
setName(name) {
|
|
17
|
+
this.config.name = name;
|
|
18
|
+
return this;
|
|
83
19
|
}
|
|
84
|
-
|
|
85
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Sets the alias for the MCP server
|
|
22
|
+
*/
|
|
23
|
+
setAlias(alias) {
|
|
24
|
+
this.config.alias = alias;
|
|
25
|
+
return this;
|
|
86
26
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.keyType = "ed25519";
|
|
94
|
-
} else {
|
|
95
|
-
this.keyType = "ed25519";
|
|
96
|
-
}
|
|
97
|
-
this.initializeOperatorWithKeyType();
|
|
27
|
+
/**
|
|
28
|
+
* Sets the bio/description for the MCP server profile
|
|
29
|
+
*/
|
|
30
|
+
setBio(bio) {
|
|
31
|
+
this.config.bio = bio;
|
|
32
|
+
return this;
|
|
98
33
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.client.setOperator(this.operatorId, PK);
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use setBio instead
|
|
36
|
+
*/
|
|
37
|
+
setDescription(description) {
|
|
38
|
+
return this.setBio(description);
|
|
105
39
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
properties: options?.properties,
|
|
116
|
-
inboundTopicId: options?.inboundTopicId,
|
|
117
|
-
outboundTopicId: options?.outboundTopicId
|
|
118
|
-
};
|
|
40
|
+
/**
|
|
41
|
+
* Sets the version of the MCP server
|
|
42
|
+
*/
|
|
43
|
+
setVersion(version) {
|
|
44
|
+
if (!this.config.mcpServer) {
|
|
45
|
+
this.config.mcpServer = {};
|
|
46
|
+
}
|
|
47
|
+
this.config.mcpServer.version = version;
|
|
48
|
+
return this;
|
|
119
49
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
bio: options?.bio,
|
|
127
|
-
socials: options?.socials,
|
|
128
|
-
profileImage: options?.profileImage,
|
|
129
|
-
properties: options?.properties,
|
|
130
|
-
inboundTopicId: options?.inboundTopicId,
|
|
131
|
-
outboundTopicId: options?.outboundTopicId,
|
|
132
|
-
aiAgent: {
|
|
133
|
-
type: agentType,
|
|
134
|
-
capabilities,
|
|
135
|
-
model,
|
|
136
|
-
creator: options?.creator
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
if (!validation.valid) {
|
|
140
|
-
throw new Error(
|
|
141
|
-
`Invalid AI Agent Profile: ${validation.errors.join(", ")}`
|
|
142
|
-
);
|
|
50
|
+
/**
|
|
51
|
+
* Sets the connection information for the MCP server
|
|
52
|
+
*/
|
|
53
|
+
setConnectionInfo(url, transport) {
|
|
54
|
+
if (!this.config.mcpServer) {
|
|
55
|
+
this.config.mcpServer = {};
|
|
143
56
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
display_name: displayName,
|
|
148
|
-
alias: options?.alias,
|
|
149
|
-
bio: options?.bio,
|
|
150
|
-
socials: options?.socials,
|
|
151
|
-
profileImage: options?.profileImage,
|
|
152
|
-
properties: options?.properties,
|
|
153
|
-
inboundTopicId: options?.inboundTopicId,
|
|
154
|
-
outboundTopicId: options?.outboundTopicId,
|
|
155
|
-
aiAgent: {
|
|
156
|
-
type: agentType,
|
|
157
|
-
capabilities,
|
|
158
|
-
model,
|
|
159
|
-
creator: options?.creator
|
|
160
|
-
}
|
|
57
|
+
this.config.mcpServer.connectionInfo = {
|
|
58
|
+
url,
|
|
59
|
+
transport
|
|
161
60
|
};
|
|
61
|
+
return this;
|
|
162
62
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Sets the detailed description for the MCP server capabilities
|
|
65
|
+
*/
|
|
66
|
+
setServerDescription(description) {
|
|
67
|
+
if (!this.config.mcpServer) {
|
|
68
|
+
this.config.mcpServer = {};
|
|
167
69
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
let message = err.message;
|
|
171
|
-
if (err.code === "invalid_type") {
|
|
172
|
-
message = `Expected ${err.expected}, got ${err.received}`;
|
|
173
|
-
} else if (err.code === "invalid_enum_value") {
|
|
174
|
-
const validOptions = err.options?.join(", ");
|
|
175
|
-
message = `Invalid value. Valid options are: ${validOptions}`;
|
|
176
|
-
} else if (err.code === "too_small" && err.type === "string") {
|
|
177
|
-
message = "Cannot be empty";
|
|
178
|
-
}
|
|
179
|
-
return `${path}: ${message}`;
|
|
180
|
-
});
|
|
181
|
-
return { valid: false, errors: formattedErrors };
|
|
70
|
+
this.config.mcpServer.description = description;
|
|
71
|
+
return this;
|
|
182
72
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const validation = this.validateProfile(parsedProfile);
|
|
190
|
-
if (!validation.valid) {
|
|
191
|
-
this.logger.error("Invalid profile format:", validation.errors);
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
return parsedProfile;
|
|
195
|
-
} catch (error) {
|
|
196
|
-
this.logger.error("Error parsing profile:");
|
|
197
|
-
return null;
|
|
73
|
+
/**
|
|
74
|
+
* Sets the services/capabilities provided by the MCP server
|
|
75
|
+
*/
|
|
76
|
+
setServices(services) {
|
|
77
|
+
if (!this.config.mcpServer) {
|
|
78
|
+
this.config.mcpServer = {};
|
|
198
79
|
}
|
|
80
|
+
this.config.mcpServer.services = services;
|
|
81
|
+
return this;
|
|
199
82
|
}
|
|
200
|
-
|
|
201
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Sets the minimum host version requirements
|
|
85
|
+
*/
|
|
86
|
+
setHostRequirements(minVersion) {
|
|
87
|
+
if (!this.config.mcpServer) {
|
|
88
|
+
this.config.mcpServer = {};
|
|
89
|
+
}
|
|
90
|
+
this.config.mcpServer.host = { minVersion };
|
|
91
|
+
return this;
|
|
202
92
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (receipt2.status.toString() !== Status.Success.toString()) {
|
|
210
|
-
return {
|
|
211
|
-
success: false,
|
|
212
|
-
error: `Transaction failed: ${receipt2.status.toString()}`
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
success: true,
|
|
217
|
-
result: receipt2
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
if (!this.auth.signer) {
|
|
221
|
-
throw new Error("No valid authentication method provided");
|
|
222
|
-
}
|
|
223
|
-
const signer = this.auth.signer;
|
|
224
|
-
const frozenTransaction = await transaction.freezeWithSigner(signer);
|
|
225
|
-
const response = await frozenTransaction.executeWithSigner(signer);
|
|
226
|
-
const receipt = await response.getReceiptWithSigner(signer);
|
|
227
|
-
if (receipt.status.toString() !== Status.Success.toString()) {
|
|
228
|
-
return {
|
|
229
|
-
success: false,
|
|
230
|
-
error: `Transaction failed: ${receipt.status.toString()}: ${Status.Success.toString()}`
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
return {
|
|
234
|
-
success: true,
|
|
235
|
-
result: receipt
|
|
236
|
-
};
|
|
237
|
-
} catch (error) {
|
|
238
|
-
return {
|
|
239
|
-
success: false,
|
|
240
|
-
error: error instanceof Error ? error.message : "Unknown error during transaction execution"
|
|
241
|
-
};
|
|
93
|
+
/**
|
|
94
|
+
* Sets the MCP capabilities supported by the server
|
|
95
|
+
*/
|
|
96
|
+
setCapabilities(capabilities) {
|
|
97
|
+
if (!this.config.mcpServer) {
|
|
98
|
+
this.config.mcpServer = {};
|
|
242
99
|
}
|
|
100
|
+
this.config.mcpServer.capabilities = capabilities;
|
|
101
|
+
return this;
|
|
243
102
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const mimeType = mime.lookup(fileName) || "application/octet-stream";
|
|
254
|
-
const waitForConfirmation = options?.waitForConfirmation ?? true;
|
|
255
|
-
let inscriptionResponse;
|
|
256
|
-
if (this.auth.signer) {
|
|
257
|
-
if ("accountId" in this.auth.signer) {
|
|
258
|
-
progressReporter.preparing("Using signer for inscription", 10);
|
|
259
|
-
inscriptionResponse = await inscribeWithSigner(
|
|
260
|
-
{
|
|
261
|
-
type: "buffer",
|
|
262
|
-
buffer,
|
|
263
|
-
fileName,
|
|
264
|
-
mimeType
|
|
265
|
-
},
|
|
266
|
-
this.auth.signer,
|
|
267
|
-
{
|
|
268
|
-
network: this.network,
|
|
269
|
-
waitForConfirmation,
|
|
270
|
-
waitMaxAttempts: 150,
|
|
271
|
-
waitIntervalMs: 4e3,
|
|
272
|
-
logging: {
|
|
273
|
-
level: "debug"
|
|
274
|
-
},
|
|
275
|
-
progressCallback: (data) => {
|
|
276
|
-
const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;
|
|
277
|
-
progressReporter.report({
|
|
278
|
-
stage: data.stage,
|
|
279
|
-
message: data.message,
|
|
280
|
-
progressPercent: adjustedPercent,
|
|
281
|
-
details: data.details
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
);
|
|
286
|
-
} else {
|
|
287
|
-
progressReporter.failed(
|
|
288
|
-
"Signer must be a DAppSigner for inscription"
|
|
289
|
-
);
|
|
290
|
-
throw new Error("Signer must be a DAppSigner for inscription");
|
|
291
|
-
}
|
|
292
|
-
} else {
|
|
293
|
-
if (!this.auth.privateKey) {
|
|
294
|
-
progressReporter.failed("Private key is required for inscription");
|
|
295
|
-
this.logger.error("Private key is required for inscription");
|
|
296
|
-
throw new Error("Private key is required for inscription");
|
|
297
|
-
}
|
|
298
|
-
progressReporter.preparing("Using private key for inscription", 10);
|
|
299
|
-
inscriptionResponse = await inscribe(
|
|
300
|
-
{
|
|
301
|
-
type: "buffer",
|
|
302
|
-
buffer,
|
|
303
|
-
fileName,
|
|
304
|
-
mimeType
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
accountId: this.auth.operatorId,
|
|
308
|
-
privateKey: this.auth.privateKey,
|
|
309
|
-
network: this.network
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
waitForConfirmation,
|
|
313
|
-
waitMaxAttempts: 150,
|
|
314
|
-
waitIntervalMs: 2e3,
|
|
315
|
-
logging: {
|
|
316
|
-
level: "debug"
|
|
317
|
-
},
|
|
318
|
-
progressCallback: (data) => {
|
|
319
|
-
const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;
|
|
320
|
-
progressReporter.report({
|
|
321
|
-
stage: data.stage,
|
|
322
|
-
message: data.message,
|
|
323
|
-
progressPercent: adjustedPercent,
|
|
324
|
-
details: data.details
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
if (inscriptionResponse.confirmed) {
|
|
331
|
-
progressReporter.completed("Image inscription completed", {
|
|
332
|
-
topic_id: inscriptionResponse.inscription.topic_id
|
|
333
|
-
});
|
|
334
|
-
return {
|
|
335
|
-
imageTopicId: inscriptionResponse.inscription.topic_id || "",
|
|
336
|
-
transactionId: inscriptionResponse.result.jobId,
|
|
337
|
-
success: true
|
|
338
|
-
};
|
|
339
|
-
} else {
|
|
340
|
-
progressReporter.verifying("Waiting for inscription confirmation", 50, {
|
|
341
|
-
jobId: inscriptionResponse.result.jobId
|
|
342
|
-
});
|
|
343
|
-
return {
|
|
344
|
-
imageTopicId: "",
|
|
345
|
-
transactionId: inscriptionResponse.result.jobId,
|
|
346
|
-
success: false,
|
|
347
|
-
error: "Inscription not confirmed"
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
} catch (error) {
|
|
351
|
-
this.logger.error("Error inscribing image:", error);
|
|
352
|
-
return {
|
|
353
|
-
imageTopicId: "",
|
|
354
|
-
transactionId: "",
|
|
355
|
-
success: false,
|
|
356
|
-
error: error.message || "Error inscribing image"
|
|
357
|
-
};
|
|
103
|
+
/**
|
|
104
|
+
* Adds a resource that the MCP server exposes
|
|
105
|
+
*/
|
|
106
|
+
addResource(name, description) {
|
|
107
|
+
if (!this.config.mcpServer) {
|
|
108
|
+
this.config.mcpServer = {};
|
|
109
|
+
}
|
|
110
|
+
if (!this.config.mcpServer.resources) {
|
|
111
|
+
this.config.mcpServer.resources = [];
|
|
358
112
|
}
|
|
113
|
+
this.config.mcpServer.resources.push({ name, description });
|
|
114
|
+
return this;
|
|
359
115
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
callback: progressCallback
|
|
367
|
-
});
|
|
368
|
-
progressReporter.preparing("Validating profile data", 5);
|
|
369
|
-
const validation = this.validateProfile(profile);
|
|
370
|
-
if (!validation.valid) {
|
|
371
|
-
progressReporter.failed(
|
|
372
|
-
`Invalid profile: ${validation.errors.join(", ")}`
|
|
373
|
-
);
|
|
374
|
-
return {
|
|
375
|
-
profileTopicId: "",
|
|
376
|
-
transactionId: "",
|
|
377
|
-
success: false,
|
|
378
|
-
error: `Invalid profile: ${validation.errors.join(", ")}`
|
|
379
|
-
};
|
|
116
|
+
/**
|
|
117
|
+
* Adds a tool that the MCP server provides
|
|
118
|
+
*/
|
|
119
|
+
addTool(name, description) {
|
|
120
|
+
if (!this.config.mcpServer) {
|
|
121
|
+
this.config.mcpServer = {};
|
|
380
122
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const fileName = `profile-${profile.display_name.toLowerCase().replace(/\s+/g, "-")}.json`;
|
|
384
|
-
try {
|
|
385
|
-
const contentBuffer = Buffer.from(profileJson, "utf-8");
|
|
386
|
-
const contentType = "application/json";
|
|
387
|
-
progressReporter.preparing("Preparing profile for inscription", 20);
|
|
388
|
-
const input = {
|
|
389
|
-
type: "buffer",
|
|
390
|
-
buffer: contentBuffer,
|
|
391
|
-
fileName,
|
|
392
|
-
mimeType: contentType
|
|
393
|
-
};
|
|
394
|
-
const inscriptionOptions = {
|
|
395
|
-
waitForConfirmation: true,
|
|
396
|
-
mode: "file",
|
|
397
|
-
network: this.network,
|
|
398
|
-
waitMaxAttempts: 100,
|
|
399
|
-
waitIntervalMs: 2e3,
|
|
400
|
-
progressCallback: (data) => {
|
|
401
|
-
const adjustedPercent = 20 + Number(data?.progressPercent || 0) * 0.75;
|
|
402
|
-
progressReporter?.report({
|
|
403
|
-
stage: data.stage,
|
|
404
|
-
message: data.message,
|
|
405
|
-
progressPercent: adjustedPercent,
|
|
406
|
-
details: data.details
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
progressReporter.submitting("Submitting profile to Hedera network", 30);
|
|
411
|
-
const inscriptionResponse = this.auth.privateKey ? await inscribe(
|
|
412
|
-
input,
|
|
413
|
-
{
|
|
414
|
-
accountId: this.auth.operatorId,
|
|
415
|
-
privateKey: this.auth.privateKey,
|
|
416
|
-
network: this.network
|
|
417
|
-
},
|
|
418
|
-
inscriptionOptions
|
|
419
|
-
) : await inscribeWithSigner(
|
|
420
|
-
input,
|
|
421
|
-
this.auth.signer,
|
|
422
|
-
inscriptionOptions
|
|
423
|
-
);
|
|
424
|
-
if (!inscriptionResponse.confirmed || !inscriptionResponse.inscription.topic_id) {
|
|
425
|
-
progressReporter.failed("Failed to inscribe profile content");
|
|
426
|
-
return {
|
|
427
|
-
profileTopicId: "",
|
|
428
|
-
transactionId: "",
|
|
429
|
-
success: false,
|
|
430
|
-
error: "Failed to inscribe profile content"
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
const topicId = inscriptionResponse.inscription.topic_id;
|
|
434
|
-
progressReporter.completed("Profile inscription completed", {
|
|
435
|
-
topicId,
|
|
436
|
-
transactionId: inscriptionResponse.result.transactionId
|
|
437
|
-
});
|
|
438
|
-
return {
|
|
439
|
-
profileTopicId: topicId,
|
|
440
|
-
transactionId: inscriptionResponse.result.transactionId,
|
|
441
|
-
success: true
|
|
442
|
-
};
|
|
443
|
-
} catch (error) {
|
|
444
|
-
progressReporter.failed(
|
|
445
|
-
`Error inscribing profile: ${error.message || "Unknown error"}`
|
|
446
|
-
);
|
|
447
|
-
return {
|
|
448
|
-
profileTopicId: "",
|
|
449
|
-
transactionId: "",
|
|
450
|
-
success: false,
|
|
451
|
-
error: error.message || "Unknown error during inscription"
|
|
452
|
-
};
|
|
123
|
+
if (!this.config.mcpServer.tools) {
|
|
124
|
+
this.config.mcpServer.tools = [];
|
|
453
125
|
}
|
|
126
|
+
this.config.mcpServer.tools.push({ name, description });
|
|
127
|
+
return this;
|
|
454
128
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const transaction = new AccountUpdateTransaction().setAccountMemo(memo).setAccountId(accountId);
|
|
462
|
-
return this.executeTransaction(transaction);
|
|
463
|
-
} catch (error) {
|
|
464
|
-
this.logger.error(
|
|
465
|
-
`Error updating account memo: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
466
|
-
);
|
|
467
|
-
return {
|
|
468
|
-
success: false,
|
|
469
|
-
error: error instanceof Error ? error.message : "Unknown error updating account memo"
|
|
470
|
-
};
|
|
129
|
+
/**
|
|
130
|
+
* Sets information about who maintains the MCP server
|
|
131
|
+
*/
|
|
132
|
+
setMaintainer(maintainer) {
|
|
133
|
+
if (!this.config.mcpServer) {
|
|
134
|
+
this.config.mcpServer = {};
|
|
471
135
|
}
|
|
136
|
+
this.config.mcpServer.maintainer = maintainer;
|
|
137
|
+
return this;
|
|
472
138
|
}
|
|
473
139
|
/**
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
* @param profile - The profile to create and inscribe.
|
|
477
|
-
* @param updateAccountMemo - Whether to update the account memo with the profile.
|
|
478
|
-
* @param options - Optional configuration options.
|
|
479
|
-
* @returns A promise that resolves to the inscription result.
|
|
140
|
+
* Sets the URL to the source code repository
|
|
480
141
|
*/
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
module: "HCS11-ProfileCreation",
|
|
485
|
-
logger: this.logger,
|
|
486
|
-
callback: progressCallback
|
|
487
|
-
});
|
|
488
|
-
progressReporter.preparing("Starting profile creation process", 0);
|
|
489
|
-
const inscriptionProgress = progressReporter.createSubProgress({
|
|
490
|
-
minPercent: 0,
|
|
491
|
-
maxPercent: 80,
|
|
492
|
-
logPrefix: "Inscription"
|
|
493
|
-
});
|
|
494
|
-
const inscriptionResult = await this.inscribeProfile(profile, {
|
|
495
|
-
...options,
|
|
496
|
-
progressCallback: (data) => {
|
|
497
|
-
inscriptionProgress.report({
|
|
498
|
-
stage: data.stage,
|
|
499
|
-
message: data.message,
|
|
500
|
-
progressPercent: data.progressPercent,
|
|
501
|
-
details: data.details
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
if (!inscriptionResult?.success) {
|
|
506
|
-
progressReporter.failed("Profile inscription failed", {
|
|
507
|
-
error: inscriptionResult?.error
|
|
508
|
-
});
|
|
509
|
-
return inscriptionResult;
|
|
142
|
+
setRepository(repository) {
|
|
143
|
+
if (!this.config.mcpServer) {
|
|
144
|
+
this.config.mcpServer = {};
|
|
510
145
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
});
|
|
521
|
-
return {
|
|
522
|
-
...inscriptionResult,
|
|
523
|
-
success: false,
|
|
524
|
-
error: memoResult?.error
|
|
525
|
-
};
|
|
526
|
-
}
|
|
146
|
+
this.config.mcpServer.repository = repository;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Sets the URL to the server documentation
|
|
151
|
+
*/
|
|
152
|
+
setDocs(docs) {
|
|
153
|
+
if (!this.config.mcpServer) {
|
|
154
|
+
this.config.mcpServer = {};
|
|
527
155
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
transactionId: inscriptionResult.transactionId
|
|
531
|
-
});
|
|
532
|
-
return inscriptionResult;
|
|
156
|
+
this.config.mcpServer.docs = docs;
|
|
157
|
+
return this;
|
|
533
158
|
}
|
|
534
159
|
/**
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
* @param capabilityNames - The capability names to get the capabilities for.
|
|
538
|
-
* @returns The capabilities.
|
|
160
|
+
* Adds DNS-based verification of endpoint ownership
|
|
539
161
|
*/
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return [AIAgentCapability.TEXT_GENERATION];
|
|
162
|
+
addVerificationDNS(domain, dnsField) {
|
|
163
|
+
if (!this.config.mcpServer) {
|
|
164
|
+
this.config.mcpServer = {};
|
|
544
165
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
166
|
+
this.config.mcpServer.verification = {
|
|
167
|
+
type: VerificationType.DNS,
|
|
168
|
+
value: domain,
|
|
169
|
+
dns_field: dnsField
|
|
170
|
+
};
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Adds signature-based verification of endpoint ownership
|
|
175
|
+
*/
|
|
176
|
+
addVerificationSignature(signature) {
|
|
177
|
+
if (!this.config.mcpServer) {
|
|
178
|
+
this.config.mcpServer = {};
|
|
550
179
|
}
|
|
551
|
-
|
|
552
|
-
|
|
180
|
+
this.config.mcpServer.verification = {
|
|
181
|
+
type: VerificationType.SIGNATURE,
|
|
182
|
+
value: signature
|
|
183
|
+
};
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Adds challenge-based verification of endpoint ownership
|
|
188
|
+
*/
|
|
189
|
+
addVerificationChallenge(challengePath) {
|
|
190
|
+
if (!this.config.mcpServer) {
|
|
191
|
+
this.config.mcpServer = {};
|
|
553
192
|
}
|
|
554
|
-
|
|
193
|
+
this.config.mcpServer.verification = {
|
|
194
|
+
type: VerificationType.CHALLENGE,
|
|
195
|
+
value: "",
|
|
196
|
+
challenge_path: challengePath
|
|
197
|
+
};
|
|
198
|
+
return this;
|
|
555
199
|
}
|
|
556
200
|
/**
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
* @param metadata - The metadata of the agent.
|
|
560
|
-
* @returns The agent type.
|
|
201
|
+
* Adds a social media link to the profile
|
|
561
202
|
*/
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
203
|
+
addSocial(platform, handle) {
|
|
204
|
+
const existingSocial = this.socials.find((s) => s.platform === platform);
|
|
205
|
+
if (!existingSocial) {
|
|
206
|
+
this.socials.push({ platform, handle });
|
|
565
207
|
} else {
|
|
566
|
-
|
|
208
|
+
existingSocial.handle = handle;
|
|
567
209
|
}
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Sets the profile picture for the MCP server
|
|
214
|
+
*/
|
|
215
|
+
setProfilePicture(pfpBuffer, pfpFileName) {
|
|
216
|
+
this.config.pfpBuffer = pfpBuffer;
|
|
217
|
+
this.config.pfpFileName = pfpFileName;
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Sets a reference to an existing profile picture
|
|
222
|
+
*/
|
|
223
|
+
setExistingProfilePicture(pfpTopicId) {
|
|
224
|
+
this.config.existingPfpTopicId = pfpTopicId;
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Sets the network type (mainnet or testnet)
|
|
229
|
+
*/
|
|
230
|
+
setNetworkType(network) {
|
|
231
|
+
this.config.network = network;
|
|
232
|
+
return this;
|
|
568
233
|
}
|
|
569
234
|
/**
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* @param accountId - The account ID of the agent to fetch the profile for.
|
|
573
|
-
* @param network - The network to use for the fetch.
|
|
574
|
-
* @returns A promise that resolves to the profile.
|
|
235
|
+
* Builds and validates the MCP server configuration
|
|
575
236
|
*/
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
try {
|
|
606
|
-
const response = await fetch(cdnUrl);
|
|
607
|
-
if (!response.ok) {
|
|
608
|
-
return {
|
|
609
|
-
success: false,
|
|
610
|
-
error: `Failed to fetch profile from Kiloscribe CDN: ${response.statusText}`
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
const profileData = await response.json();
|
|
614
|
-
if (!profileData) {
|
|
615
|
-
return {
|
|
616
|
-
success: false,
|
|
617
|
-
error: `No profile data found for topic ${profileTopicId}`
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
return {
|
|
621
|
-
success: true,
|
|
622
|
-
profile: profileData,
|
|
623
|
-
topicInfo: {
|
|
624
|
-
inboundTopic: profileData.inboundTopicId,
|
|
625
|
-
outboundTopic: profileData.outboundTopicId,
|
|
626
|
-
profileTopicId
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
} catch (cdnError) {
|
|
630
|
-
this.logger.error(
|
|
631
|
-
`Error retrieving from Kiloscribe CDN: ${cdnError.message}`
|
|
632
|
-
);
|
|
633
|
-
return {
|
|
634
|
-
success: false,
|
|
635
|
-
error: `Error retrieving from Kiloscribe CDN: ${cdnError.message}`
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
} else if (protocolReference.startsWith("ipfs://")) {
|
|
639
|
-
this.logger.warn("IPFS protocol references are not fully supported");
|
|
640
|
-
const response = await fetch(
|
|
641
|
-
`https://ipfs.io/ipfs/${protocolReference.replace("ipfs://", "")}`
|
|
642
|
-
);
|
|
643
|
-
const profileData = await response.json();
|
|
644
|
-
return {
|
|
645
|
-
success: true,
|
|
646
|
-
profile: profileData,
|
|
647
|
-
topicInfo: {
|
|
648
|
-
inboundTopic: profileData.inboundTopicId,
|
|
649
|
-
outboundTopic: profileData.outboundTopicId,
|
|
650
|
-
profileTopicId: profileData.profileTopicId
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
} else if (protocolReference.startsWith("ar://")) {
|
|
654
|
-
const arTxId = protocolReference.replace("ar://", "");
|
|
655
|
-
const response = await fetch(`https://arweave.net/${arTxId}`);
|
|
656
|
-
if (!response.ok) {
|
|
657
|
-
return {
|
|
658
|
-
success: false,
|
|
659
|
-
error: `Failed to fetch profile from Arweave ${arTxId}: ${response.statusText}`
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
const profileData = await response.json();
|
|
663
|
-
return {
|
|
664
|
-
success: true,
|
|
665
|
-
profile: profileData,
|
|
666
|
-
topicInfo: {
|
|
667
|
-
inboundTopic: profileData.inboundTopicId,
|
|
668
|
-
outboundTopic: profileData.outboundTopicId,
|
|
669
|
-
profileTopicId: profileData.profileTopicId
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
} else {
|
|
673
|
-
return {
|
|
674
|
-
success: false,
|
|
675
|
-
error: `Invalid protocol reference format: ${protocolReference}`
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
} catch (error) {
|
|
679
|
-
this.logger.error(`Error fetching profile: ${error.message}`);
|
|
237
|
+
build() {
|
|
238
|
+
if (!this.config.name) {
|
|
239
|
+
throw new Error("MCP server name is required");
|
|
240
|
+
}
|
|
241
|
+
if (!this.config.network) {
|
|
242
|
+
throw new Error("Network type is required");
|
|
243
|
+
}
|
|
244
|
+
if (!this.config.mcpServer) {
|
|
245
|
+
throw new Error("MCP server details are required");
|
|
246
|
+
}
|
|
247
|
+
if (!this.config.mcpServer.version) {
|
|
248
|
+
throw new Error("MCP server version is required");
|
|
249
|
+
}
|
|
250
|
+
if (!this.config.mcpServer.connectionInfo) {
|
|
251
|
+
throw new Error("MCP server connection info is required");
|
|
252
|
+
}
|
|
253
|
+
if (!this.config.mcpServer.services || this.config.mcpServer.services.length === 0) {
|
|
254
|
+
throw new Error("At least one MCP service type is required");
|
|
255
|
+
}
|
|
256
|
+
if (!this.config.mcpServer.description) {
|
|
257
|
+
throw new Error("MCP server description is required");
|
|
258
|
+
}
|
|
259
|
+
if (!this.config.bio) {
|
|
260
|
+
this.logger.warn("No bio provided for MCP server profile");
|
|
261
|
+
}
|
|
262
|
+
if (!this.config.pfpBuffer && !this.config.existingPfpTopicId) {
|
|
263
|
+
this.logger.warn("No profile picture provided or referenced");
|
|
264
|
+
}
|
|
265
|
+
if (this.socials.length > 0) {
|
|
680
266
|
return {
|
|
681
|
-
|
|
682
|
-
|
|
267
|
+
...this.config,
|
|
268
|
+
socials: this.socials
|
|
683
269
|
};
|
|
684
270
|
}
|
|
271
|
+
return this.config;
|
|
685
272
|
}
|
|
686
273
|
}
|
|
687
274
|
export {
|
|
688
|
-
|
|
275
|
+
MCPServerBuilder
|
|
689
276
|
};
|
|
690
277
|
//# sourceMappingURL=standards-sdk.es13.js.map
|