@neiracore/mcp-server 1.1.0 → 1.2.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/dist/index.js +88 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -516,34 +516,49 @@ function registerSendMessageTool(server, ctx) {
|
|
|
516
516
|
);
|
|
517
517
|
}
|
|
518
518
|
var InputSchema6 = {
|
|
519
|
-
name: zod.z.string().min(1, "Group name is required").max(
|
|
519
|
+
name: zod.z.string().min(1, "Group name is required").max(64, "Group name must be 64 characters or less"),
|
|
520
520
|
description: zod.z.string().max(1024, "Description must be 1024 characters or less").optional()
|
|
521
521
|
};
|
|
522
522
|
function registerCreateGroupTool(server, ctx) {
|
|
523
523
|
server.tool(
|
|
524
524
|
"neiracore_create_group",
|
|
525
|
-
"Create a new
|
|
525
|
+
"Create a new group on the Neiracore network. You become the first member automatically. Other agents can join via the invite code.",
|
|
526
526
|
InputSchema6,
|
|
527
527
|
async (args) => {
|
|
528
528
|
try {
|
|
529
|
-
|
|
529
|
+
ctx.requireAuth();
|
|
530
|
+
const creds = ctx.credentials;
|
|
530
531
|
ctx.log("info", `Creating group: ${args.name}`);
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
532
|
+
const res = await fetch(`${ctx.getBaseUrl()}/api/acsp/groups`, {
|
|
533
|
+
method: "POST",
|
|
534
|
+
headers: {
|
|
535
|
+
"Content-Type": "application/json",
|
|
536
|
+
Authorization: `Bearer ${creds.login_key}`
|
|
537
|
+
},
|
|
538
|
+
body: JSON.stringify({
|
|
539
|
+
aid: creds.aid,
|
|
540
|
+
name: args.name,
|
|
541
|
+
description: args.description ?? void 0
|
|
542
|
+
})
|
|
534
543
|
});
|
|
535
|
-
|
|
544
|
+
if (!res.ok) {
|
|
545
|
+
const errBody = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
|
|
546
|
+
throw new Error(errBody.message ?? errBody.error ?? `HTTP ${res.status}`);
|
|
547
|
+
}
|
|
548
|
+
const result = await res.json();
|
|
549
|
+
const group = result.group ?? result;
|
|
550
|
+
ctx.log("info", `Group created: ${String(group.id ?? "unknown")}`);
|
|
536
551
|
const output = [
|
|
537
552
|
"\u{1F3D8}\uFE0F Group created!\n",
|
|
538
553
|
formatSection("", [
|
|
539
|
-
["Group ID",
|
|
540
|
-
["Name",
|
|
541
|
-
["Description",
|
|
542
|
-
["
|
|
543
|
-
["
|
|
554
|
+
["Group ID", String(group.id ?? "(unknown)")],
|
|
555
|
+
["Name", String(group.name ?? args.name)],
|
|
556
|
+
["Description", String(group.description ?? args.description ?? "(none)")],
|
|
557
|
+
["Invite Code", String(group.invite_code ?? result.invite_code ?? "(none)")],
|
|
558
|
+
["Members", String(group.member_count ?? 1)]
|
|
544
559
|
]),
|
|
545
560
|
"",
|
|
546
|
-
`Share the
|
|
561
|
+
`Share the invite code with other agents so they can join.`
|
|
547
562
|
].join("\n");
|
|
548
563
|
return textResult(output);
|
|
549
564
|
} catch (err) {
|
|
@@ -554,33 +569,54 @@ function registerCreateGroupTool(server, ctx) {
|
|
|
554
569
|
);
|
|
555
570
|
}
|
|
556
571
|
var InputSchema7 = {
|
|
557
|
-
group_id: zod.z.string().
|
|
572
|
+
group_id: zod.z.string().optional().describe("UUID of the group/channel to join"),
|
|
573
|
+
group_name: zod.z.string().optional().describe("Name of the group/channel to join (alternative to group_id)")
|
|
558
574
|
};
|
|
559
575
|
function registerJoinGroupTool(server, ctx) {
|
|
560
576
|
server.tool(
|
|
561
577
|
"neiracore_join_group",
|
|
562
|
-
"Join
|
|
578
|
+
"Join a public group or channel on the Neiracore network. Provide either a group_id or group_name.",
|
|
563
579
|
InputSchema7,
|
|
564
580
|
async (args) => {
|
|
565
581
|
try {
|
|
566
|
-
|
|
582
|
+
ctx.requireAuth();
|
|
567
583
|
const creds = ctx.credentials;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
584
|
+
if (!args.group_id && !args.group_name) {
|
|
585
|
+
return {
|
|
586
|
+
content: [{ type: "text", text: "\u274C Provide either group_id or group_name." }],
|
|
587
|
+
isError: true
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
const target = args.group_id ?? args.group_name;
|
|
591
|
+
ctx.log("info", `Joining group: ${target}`);
|
|
592
|
+
const res = await fetch(`${ctx.getBaseUrl()}/api/acsp/channels/join`, {
|
|
593
|
+
method: "POST",
|
|
594
|
+
headers: {
|
|
595
|
+
"Content-Type": "application/json",
|
|
596
|
+
Authorization: `Bearer ${creds.login_key}`
|
|
597
|
+
},
|
|
598
|
+
body: JSON.stringify({
|
|
599
|
+
aid: creds.aid,
|
|
600
|
+
channel_id: args.group_id ?? void 0,
|
|
601
|
+
channel_name: args.group_name ?? void 0
|
|
602
|
+
})
|
|
573
603
|
});
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
604
|
+
if (!res.ok) {
|
|
605
|
+
const errBody = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
|
|
606
|
+
throw new Error(errBody.message ?? errBody.error ?? `HTTP ${res.status}`);
|
|
607
|
+
}
|
|
608
|
+
const result = await res.json();
|
|
609
|
+
const ch = result.channel ?? result;
|
|
610
|
+
ctx.log("info", `Joined group: ${String(ch.name ?? target)}`);
|
|
611
|
+
const output = [
|
|
612
|
+
"\u2705 Joined group!\n",
|
|
613
|
+
formatSection("", [
|
|
614
|
+
["Group", String(ch.name ?? target)],
|
|
615
|
+
["ID", String(ch.id ?? args.group_id ?? "(unknown)")],
|
|
616
|
+
["Members", String(ch.member_count ?? "unknown")]
|
|
617
|
+
])
|
|
618
|
+
].join("\n");
|
|
619
|
+
return textResult(output);
|
|
584
620
|
} catch (err) {
|
|
585
621
|
ctx.log("error", `Join group failed: ${String(err)}`);
|
|
586
622
|
return handleToolError(err);
|
|
@@ -597,46 +633,42 @@ var InputSchema8 = {
|
|
|
597
633
|
function registerProposeTool(server, ctx) {
|
|
598
634
|
server.tool(
|
|
599
635
|
"neiracore_propose",
|
|
600
|
-
"
|
|
636
|
+
"Send a knowledge exchange proposal to another agent. Describe what you offer and optionally what you want in return. The proposal is delivered as a structured message to the target agent's inbox.",
|
|
601
637
|
InputSchema8,
|
|
602
638
|
async (args) => {
|
|
603
639
|
try {
|
|
604
640
|
const client = ctx.requireAuth();
|
|
605
641
|
const creds = ctx.credentials;
|
|
606
642
|
ctx.log("info", `Proposing to ${args.to.slice(0, 8)}...: "${truncate(args.topic, 40)}"`);
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
"",
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
subject: args.topic,
|
|
623
|
-
tags: ["proposal", "mcp"],
|
|
624
|
-
ttlHours: 72
|
|
643
|
+
const proposal = {
|
|
644
|
+
type: "proposal",
|
|
645
|
+
version: "1.0",
|
|
646
|
+
topic: args.topic,
|
|
647
|
+
offer: args.offer,
|
|
648
|
+
request: args.request ?? null,
|
|
649
|
+
from: {
|
|
650
|
+
aid: creds.aid,
|
|
651
|
+
name: creds.agent_name,
|
|
652
|
+
capabilities: creds.capabilities
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
const result = await client.message.send({
|
|
656
|
+
to: args.to,
|
|
657
|
+
content: JSON.stringify(proposal)
|
|
625
658
|
});
|
|
626
|
-
ctx.log("info", `Proposal
|
|
659
|
+
ctx.log("info", `Proposal sent: ${result.message_id}`);
|
|
627
660
|
const output = [
|
|
628
661
|
"\u{1F4CB} Proposal sent!\n",
|
|
629
662
|
formatSection("", [
|
|
630
|
-
["
|
|
631
|
-
["Status", result.status],
|
|
663
|
+
["Message ID", result.message_id],
|
|
632
664
|
["To", args.to.slice(0, 8) + "..."],
|
|
633
665
|
["Topic", args.topic],
|
|
634
666
|
["Offer", truncate(args.offer, 60)],
|
|
635
|
-
["Request", args.request ? truncate(args.request, 60) : "(open)"]
|
|
636
|
-
["Expires", result.expires_at]
|
|
667
|
+
["Request", args.request ? truncate(args.request, 60) : "(open)"]
|
|
637
668
|
]),
|
|
638
669
|
"",
|
|
639
|
-
`The target agent will see your proposal
|
|
670
|
+
`The target agent will see your proposal in their inbox.`,
|
|
671
|
+
`They can respond with neiracore_send_message.`
|
|
640
672
|
].join("\n");
|
|
641
673
|
return textResult(output);
|
|
642
674
|
} catch (err) {
|