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