@hashgraphonline/standards-sdk 0.0.121 → 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.
Files changed (90) hide show
  1. package/dist/cjs/hcs-11/client.d.ts +18 -1
  2. package/dist/cjs/hcs-11/client.d.ts.map +1 -1
  3. package/dist/cjs/hcs-11/index.d.ts +1 -0
  4. package/dist/cjs/hcs-11/index.d.ts.map +1 -1
  5. package/dist/cjs/hcs-11/mcp-server-builder.d.ts +118 -0
  6. package/dist/cjs/hcs-11/mcp-server-builder.d.ts.map +1 -0
  7. package/dist/cjs/hcs-11/types.d.ts +77 -18
  8. package/dist/cjs/hcs-11/types.d.ts.map +1 -1
  9. package/dist/cjs/{index-CHar8dVv-B2IK-7-2.cjs → index-CHar8dVv-BkACF223.cjs} +2 -2
  10. package/dist/cjs/{index-CHar8dVv-B2IK-7-2.cjs.map → index-CHar8dVv-BkACF223.cjs.map} +1 -1
  11. package/dist/cjs/index-DjDDRcKz.cjs +11 -0
  12. package/dist/cjs/index-DjDDRcKz.cjs.map +1 -0
  13. package/dist/cjs/standards-sdk.cjs +1 -1
  14. package/dist/es/hcs-11/client.d.ts +18 -1
  15. package/dist/es/hcs-11/client.d.ts.map +1 -1
  16. package/dist/es/hcs-11/index.d.ts +1 -0
  17. package/dist/es/hcs-11/index.d.ts.map +1 -1
  18. package/dist/es/hcs-11/mcp-server-builder.d.ts +118 -0
  19. package/dist/es/hcs-11/mcp-server-builder.d.ts.map +1 -0
  20. package/dist/es/hcs-11/types.d.ts +77 -18
  21. package/dist/es/hcs-11/types.d.ts.map +1 -1
  22. package/dist/es/standards-sdk.es.js +17 -12
  23. package/dist/es/standards-sdk.es.js.map +1 -1
  24. package/dist/es/standards-sdk.es10.js +1 -1
  25. package/dist/es/standards-sdk.es11.js +2 -2
  26. package/dist/es/standards-sdk.es12.js +1 -1
  27. package/dist/es/standards-sdk.es13.js +226 -639
  28. package/dist/es/standards-sdk.es13.js.map +1 -1
  29. package/dist/es/standards-sdk.es14.js +770 -85
  30. package/dist/es/standards-sdk.es14.js.map +1 -1
  31. package/dist/es/standards-sdk.es15.js +132 -68
  32. package/dist/es/standards-sdk.es15.js.map +1 -1
  33. package/dist/es/standards-sdk.es16.js +66 -19
  34. package/dist/es/standards-sdk.es16.js.map +1 -1
  35. package/dist/es/standards-sdk.es17.js +18 -156
  36. package/dist/es/standards-sdk.es17.js.map +1 -1
  37. package/dist/es/standards-sdk.es18.js +150 -146
  38. package/dist/es/standards-sdk.es18.js.map +1 -1
  39. package/dist/es/standards-sdk.es19.js +134 -561
  40. package/dist/es/standards-sdk.es19.js.map +1 -1
  41. package/dist/es/standards-sdk.es2.js +1 -1
  42. package/dist/es/standards-sdk.es20.js +577 -24
  43. package/dist/es/standards-sdk.es20.js.map +1 -1
  44. package/dist/es/standards-sdk.es21.js +23 -400
  45. package/dist/es/standards-sdk.es21.js.map +1 -1
  46. package/dist/es/standards-sdk.es22.js +381 -1507
  47. package/dist/es/standards-sdk.es22.js.map +1 -1
  48. package/dist/es/standards-sdk.es23.js +1511 -133
  49. package/dist/es/standards-sdk.es23.js.map +1 -1
  50. package/dist/es/standards-sdk.es24.js +155 -7
  51. package/dist/es/standards-sdk.es24.js.map +1 -1
  52. package/dist/es/standards-sdk.es25.js +7 -7190
  53. package/dist/es/standards-sdk.es25.js.map +1 -1
  54. package/dist/es/standards-sdk.es26.js +7190 -2
  55. package/dist/es/standards-sdk.es26.js.map +1 -1
  56. package/dist/es/standards-sdk.es27.js +2 -501
  57. package/dist/es/standards-sdk.es27.js.map +1 -1
  58. package/dist/es/standards-sdk.es28.js +456 -64
  59. package/dist/es/standards-sdk.es28.js.map +1 -1
  60. package/dist/es/standards-sdk.es29.js +79 -36
  61. package/dist/es/standards-sdk.es29.js.map +1 -1
  62. package/dist/es/standards-sdk.es3.js +1 -1
  63. package/dist/es/standards-sdk.es30.js +32 -222
  64. package/dist/es/standards-sdk.es30.js.map +1 -1
  65. package/dist/es/standards-sdk.es31.js +183 -100
  66. package/dist/es/standards-sdk.es31.js.map +1 -1
  67. package/dist/es/standards-sdk.es32.js +167 -5
  68. package/dist/es/standards-sdk.es32.js.map +1 -1
  69. package/dist/es/standards-sdk.es33.js +8 -7132
  70. package/dist/es/standards-sdk.es33.js.map +1 -1
  71. package/dist/es/standards-sdk.es35.js +7138 -0
  72. package/dist/es/standards-sdk.es35.js.map +1 -0
  73. package/dist/es/standards-sdk.es4.js +1 -1
  74. package/dist/es/standards-sdk.es5.js +4 -4
  75. package/dist/es/standards-sdk.es7.js +7 -7
  76. package/dist/es/standards-sdk.es8.js +5 -5
  77. package/dist/es/standards-sdk.es9.js +2 -2
  78. package/dist/umd/hcs-11/client.d.ts +18 -1
  79. package/dist/umd/hcs-11/client.d.ts.map +1 -1
  80. package/dist/umd/hcs-11/index.d.ts +1 -0
  81. package/dist/umd/hcs-11/index.d.ts.map +1 -1
  82. package/dist/umd/hcs-11/mcp-server-builder.d.ts +118 -0
  83. package/dist/umd/hcs-11/mcp-server-builder.d.ts.map +1 -0
  84. package/dist/umd/hcs-11/types.d.ts +77 -18
  85. package/dist/umd/hcs-11/types.d.ts.map +1 -1
  86. package/dist/umd/standards-sdk.umd.js +12 -12
  87. package/dist/umd/standards-sdk.umd.js.map +1 -1
  88. package/package.json +1 -1
  89. package/dist/cjs/index-CHS2J8pS.cjs +0 -11
  90. package/dist/cjs/index-CHS2J8pS.cjs.map +0 -1
@@ -1,690 +1,277 @@
1
- import { Client, PrivateKey, Status, AccountUpdateTransaction } from "@hashgraph/sdk";
2
- import { inscribeWithSigner, inscribe } from "./standards-sdk.es21.js";
3
- import { Logger } from "./standards-sdk.es15.js";
4
- import { HederaMirrorNode } from "./standards-sdk.es22.js";
5
- import { ProgressReporter } from "./standards-sdk.es17.js";
6
- import "axios";
7
- import "@hashgraph/proto";
8
- import "buffer";
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
- level: config.logLevel || "info",
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
- getClient() {
82
- return this.client;
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
- getOperatorId() {
85
- return this.auth.operatorId;
20
+ /**
21
+ * Sets the alias for the MCP server
22
+ */
23
+ setAlias(alias) {
24
+ this.config.alias = alias;
25
+ return this;
86
26
  }
87
- async initializeOperator() {
88
- const account = await this.mirrorNode.requestAccount(this.operatorId);
89
- const keyType = account?.key?._type;
90
- if (keyType && keyType.includes("ECDSA")) {
91
- this.keyType = "ecdsa";
92
- } else if (keyType && keyType.includes("ED25519")) {
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
- initializeOperatorWithKeyType() {
100
- if (!this.auth.privateKey) {
101
- return;
102
- }
103
- const PK = this.keyType === "ecdsa" ? PrivateKey.fromStringECDSA(this.auth.privateKey) : PrivateKey.fromStringED25519(this.auth.privateKey);
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
- createPersonalProfile(displayName, options) {
107
- return {
108
- version: "1.0",
109
- type: ProfileType.PERSONAL,
110
- display_name: displayName,
111
- alias: options?.alias,
112
- bio: options?.bio,
113
- socials: options?.socials,
114
- profileImage: options?.profileImage,
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
- createAIAgentProfile(displayName, agentType, capabilities, model, options) {
121
- const validation = this.validateProfile({
122
- version: "1.0",
123
- type: ProfileType.AI_AGENT,
124
- display_name: displayName,
125
- alias: options?.alias,
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
- return {
145
- version: "1.0",
146
- type: ProfileType.AI_AGENT,
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
- validateProfile(profile) {
164
- const result = HCS11ProfileSchema.safeParse(profile);
165
- if (result.success) {
166
- return { valid: true, errors: [] };
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
- const formattedErrors = result.error.errors.map((err) => {
169
- const path = err.path.join(".");
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
- profileToJSONString(profile) {
184
- return JSON.stringify(profile);
185
- }
186
- parseProfileFromString(profileStr) {
187
- try {
188
- const parsedProfile = JSON.parse(profileStr);
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
- setProfileForAccountMemo(topicId, topicStandard = 1) {
201
- return `hcs-11:hcs://${topicStandard}/${topicId}`;
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
- async executeTransaction(transaction) {
204
- try {
205
- if (this.auth.privateKey) {
206
- const signedTx = await transaction.signWithOperator(this.client);
207
- const response2 = await signedTx.execute(this.client);
208
- const receipt2 = await response2.getReceipt(this.client);
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
- async inscribeImage(buffer, fileName, options) {
245
- try {
246
- const progressCallback = options?.progressCallback;
247
- const progressReporter = new ProgressReporter({
248
- module: "HCS11-Image",
249
- logger: this.logger,
250
- callback: progressCallback
251
- });
252
- progressReporter.preparing("Preparing to inscribe image", 0);
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
- async inscribeProfile(profile, options) {
361
- this.logger.info("Inscribing HCS-11 profile");
362
- const progressCallback = options?.progressCallback;
363
- const progressReporter = new ProgressReporter({
364
- module: "HCS11-Profile",
365
- logger: this.logger,
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
- progressReporter.preparing("Formatting profile for inscription", 15);
382
- const profileJson = this.profileToJSONString(profile);
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
- async updateAccountMemoWithProfile(accountId, profileTopicId) {
456
- try {
457
- this.logger.info(
458
- `Updating account memo for ${accountId} with profile ${profileTopicId}`
459
- );
460
- const memo = this.setProfileForAccountMemo(profileTopicId);
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
- * Creates and inscribes a profile.
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
- async createAndInscribeProfile(profile, updateAccountMemo = true, options) {
482
- const progressCallback = options?.progressCallback;
483
- const progressReporter = new ProgressReporter({
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
- progressReporter.confirming("Profile inscribed, updating account memo", 85);
512
- if (updateAccountMemo) {
513
- const memoResult = await this.updateAccountMemoWithProfile(
514
- this.auth.operatorId,
515
- inscriptionResult.profileTopicId
516
- );
517
- if (!memoResult.success) {
518
- progressReporter.failed("Failed to update account memo", {
519
- error: memoResult?.error
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
- progressReporter.completed("Profile creation completed successfully", {
529
- profileTopicId: inscriptionResult.profileTopicId,
530
- transactionId: inscriptionResult.transactionId
531
- });
532
- return inscriptionResult;
156
+ this.config.mcpServer.docs = docs;
157
+ return this;
533
158
  }
534
159
  /**
535
- * Gets the capabilities from the capability names.
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
- async getCapabilitiesFromTags(capabilityNames) {
541
- const capabilities = [];
542
- if (capabilityNames.length === 0) {
543
- return [AIAgentCapability.TEXT_GENERATION];
162
+ addVerificationDNS(domain, dnsField) {
163
+ if (!this.config.mcpServer) {
164
+ this.config.mcpServer = {};
544
165
  }
545
- for (const capabilityName of capabilityNames) {
546
- const capability = capabilityNameToCapabilityMap[capabilityName.toLowerCase()];
547
- if (capability !== void 0 && !capabilities.includes(capability)) {
548
- capabilities.push(capability);
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
- if (capabilities.length === 0) {
552
- capabilities.push(AIAgentCapability.TEXT_GENERATION);
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
- return capabilities;
193
+ this.config.mcpServer.verification = {
194
+ type: VerificationType.CHALLENGE,
195
+ value: "",
196
+ challenge_path: challengePath
197
+ };
198
+ return this;
555
199
  }
556
200
  /**
557
- * Gets the agent type from the metadata.
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
- getAgentTypeFromMetadata(metadata) {
563
- if (metadata.type === "autonomous") {
564
- return AIAgentType.AUTONOMOUS;
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
- return AIAgentType.MANUAL;
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
- * Fetches a profile from the account memo.
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
- async fetchProfileByAccountId(accountId, network) {
577
- try {
578
- this.logger.info(
579
- `Fetching profile for account ${accountId.toString()} on ${this.network}`
580
- );
581
- const memo = await this.mirrorNode.getAccountMemo(accountId.toString());
582
- this.logger.info(`Got account memo: ${memo}`);
583
- if (!memo?.startsWith("hcs-11:")) {
584
- return {
585
- success: false,
586
- error: `Account ${accountId.toString()} does not have a valid HCS-11 memo`
587
- };
588
- }
589
- this.logger.info(`Found HCS-11 memo: ${memo}`);
590
- const protocolReference = memo.substring(7);
591
- if (protocolReference?.startsWith("hcs://")) {
592
- const hcsFormat = protocolReference.match(/hcs:\/\/(\d+)\/(.+)/);
593
- if (!hcsFormat) {
594
- return {
595
- success: false,
596
- error: `Invalid HCS protocol reference format: ${protocolReference}`
597
- };
598
- }
599
- const [_, protocolId, profileTopicId] = hcsFormat;
600
- const networkParam = network || this.network || "mainnet";
601
- this.logger.info(
602
- `Retrieving profile from Kiloscribe CDN: ${profileTopicId}`
603
- );
604
- const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${profileTopicId}?network=${networkParam}`;
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
- success: false,
682
- error: `Error fetching profile: ${error.message}`
267
+ ...this.config,
268
+ socials: this.socials
683
269
  };
684
270
  }
271
+ return this.config;
685
272
  }
686
273
  }
687
274
  export {
688
- HCS11Client
275
+ MCPServerBuilder
689
276
  };
690
277
  //# sourceMappingURL=standards-sdk.es13.js.map