@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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
- import { ACSPClient, randomNonceHex, ACSPError } from '@neiracore/acsp';
3
+ import { ACSPClient, ACSPError } from '@neiracore/acsp';
4
4
  import * as fs from 'fs';
5
5
  import * as path from 'path';
6
6
  import * as os from 'os';
@@ -492,34 +492,50 @@ function registerSendMessageTool(server, ctx) {
492
492
  );
493
493
  }
494
494
  var InputSchema6 = {
495
- name: z.string().min(1, "Group name is required").max(128, "Group name must be 128 characters or less"),
495
+ name: z.string().min(1, "Group name is required").max(64, "Group name must be 64 characters or less"),
496
496
  description: z.string().max(1024, "Description must be 1024 characters or less").optional()
497
497
  };
498
498
  function registerCreateGroupTool(server, ctx) {
499
499
  server.tool(
500
500
  "neiracore_create_group",
501
- "Create a new privacy group on the Neiracore network. You become the first member automatically. Other agents can join via group ID.",
501
+ "Create a new group on the Neiracore network. You become the first member automatically. Other agents can join via the invite code.",
502
502
  InputSchema6,
503
503
  async (args) => {
504
504
  try {
505
- const client = ctx.requireAuth();
505
+ ctx.requireAuth();
506
+ const creds = ctx.credentials;
506
507
  ctx.log("info", `Creating group: ${args.name}`);
507
- const result = await client.group.create({
508
- name: args.name,
509
- description: args.description
508
+ const res = await fetch(`${ctx.getBaseUrl()}/api/acsp/groups`, {
509
+ method: "POST",
510
+ headers: {
511
+ "Content-Type": "application/json",
512
+ Authorization: `Bearer ${creds.login_key}`
513
+ },
514
+ body: JSON.stringify({
515
+ aid: creds.aid,
516
+ name: args.name,
517
+ description: args.description ?? void 0
518
+ })
510
519
  });
511
- ctx.log("info", `Group created: ${result.group_id}`);
520
+ if (!res.ok) {
521
+ const errBody = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
522
+ throw new Error(errBody.message ?? errBody.error ?? `HTTP ${res.status}`);
523
+ }
524
+ const result = await res.json();
525
+ const group = result;
526
+ const groupId = String(group.group_id ?? group.id ?? "(unknown)");
527
+ ctx.log("info", `Group created: ${groupId}`);
512
528
  const output = [
513
529
  "\u{1F3D8}\uFE0F Group created!\n",
514
530
  formatSection("", [
515
- ["Group ID", result.group_id],
516
- ["Name", result.name],
517
- ["Description", result.description ?? "(none)"],
518
- ["Created by", result.created_by.slice(0, 8) + "..."],
519
- ["Created at", result.created_at]
531
+ ["Group ID", groupId],
532
+ ["Name", String(group.name ?? args.name)],
533
+ ["Description", String(group.description ?? args.description ?? "(none)")],
534
+ ["Invite Code", String(group.invite_code ?? "(none)")],
535
+ ["Members", "1"]
520
536
  ]),
521
537
  "",
522
- `Share the Group ID with other agents so they can use neiracore_join_group.`
538
+ `Share the invite code with other agents so they can join.`
523
539
  ].join("\n");
524
540
  return textResult(output);
525
541
  } catch (err) {
@@ -530,33 +546,54 @@ function registerCreateGroupTool(server, ctx) {
530
546
  );
531
547
  }
532
548
  var InputSchema7 = {
533
- group_id: z.string().regex(/^grp_[A-Za-z0-9_-]{21}$/, "Group ID must match format grp_XXXXXXXXXXXXXXXXXXXXX")
549
+ group_id: z.string().optional().describe("UUID of the group/channel to join"),
550
+ group_name: z.string().optional().describe("Name of the group/channel to join (alternative to group_id)")
534
551
  };
535
552
  function registerJoinGroupTool(server, ctx) {
536
553
  server.tool(
537
554
  "neiracore_join_group",
538
- "Join an existing privacy group on the Neiracore network. Provide the group ID shared by another agent.",
555
+ "Join a public group or channel on the Neiracore network. Provide either a group_id or group_name.",
539
556
  InputSchema7,
540
557
  async (args) => {
541
558
  try {
542
- const client = ctx.requireAuth();
559
+ ctx.requireAuth();
543
560
  const creds = ctx.credentials;
544
- ctx.log("info", `Joining group: ${args.group_id}`);
545
- const commitment = randomNonceHex();
546
- const result = await client.group.join({
547
- groupId: args.group_id,
548
- commitment
561
+ if (!args.group_id && !args.group_name) {
562
+ return {
563
+ content: [{ type: "text", text: "\u274C Provide either group_id or group_name." }],
564
+ isError: true
565
+ };
566
+ }
567
+ const target = args.group_id ?? args.group_name;
568
+ ctx.log("info", `Joining group: ${target}`);
569
+ const res = await fetch(`${ctx.getBaseUrl()}/api/acsp/channels/join`, {
570
+ method: "POST",
571
+ headers: {
572
+ "Content-Type": "application/json",
573
+ Authorization: `Bearer ${creds.login_key}`
574
+ },
575
+ body: JSON.stringify({
576
+ aid: creds.aid,
577
+ channel_id: args.group_id ?? void 0,
578
+ channel_name: args.group_name ?? void 0
579
+ })
549
580
  });
550
- ctx.log("info", `Joined group: ${result.group_id}`);
551
- return textResult(
552
- `\u2705 Joined group!
553
-
554
- Group ID: ${result.group_id}
555
- Agent: ${creds.agent_name} (${result.aid.slice(0, 8)}...)
556
- Joined at: ${result.joined_at}
557
-
558
- You can now collaborate with other group members.`
559
- );
581
+ if (!res.ok) {
582
+ const errBody = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
583
+ throw new Error(errBody.message ?? errBody.error ?? `HTTP ${res.status}`);
584
+ }
585
+ const result = await res.json();
586
+ const ch = result.channel ?? result;
587
+ ctx.log("info", `Joined: ${String(ch.name ?? target)}`);
588
+ const output = [
589
+ "\u2705 Joined group!\n",
590
+ formatSection("", [
591
+ ["Group", String(ch.name ?? target)],
592
+ ["ID", String(ch.id ?? args.group_id ?? "(unknown)")],
593
+ ["Members", String(ch.member_count ?? "unknown")]
594
+ ])
595
+ ].join("\n");
596
+ return textResult(output);
560
597
  } catch (err) {
561
598
  ctx.log("error", `Join group failed: ${String(err)}`);
562
599
  return handleToolError(err);
@@ -573,46 +610,42 @@ var InputSchema8 = {
573
610
  function registerProposeTool(server, ctx) {
574
611
  server.tool(
575
612
  "neiracore_propose",
576
- "Start a knowledge exchange negotiation with another agent. Describe what you offer and optionally what you want in return. Creates a secure negotiation thread.",
613
+ "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.",
577
614
  InputSchema8,
578
615
  async (args) => {
579
616
  try {
580
617
  const client = ctx.requireAuth();
581
618
  const creds = ctx.credentials;
582
619
  ctx.log("info", `Proposing to ${args.to.slice(0, 8)}...: "${truncate(args.topic, 40)}"`);
583
- const proposalBody = [
584
- `[PROPOSAL] ${args.topic}`,
585
- "",
586
- `OFFER: ${args.offer}`,
587
- args.request ? `REQUEST: ${args.request}` : "",
588
- "",
589
- `From: ${creds.agent_name} (${creds.aid})`
590
- ].filter(Boolean).join("\n");
591
- const nonce = randomNonceHex();
592
- const result = await client.thread.create({
593
- responderAid: args.to,
594
- encryptedBody: proposalBody,
595
- msgNonce: nonce,
596
- ephX25519Pub: "0".repeat(64),
597
- // Placeholder — v1 uses plaintext
598
- subject: args.topic,
599
- tags: ["proposal", "mcp"],
600
- ttlHours: 72
620
+ const proposal = {
621
+ type: "proposal",
622
+ version: "1.0",
623
+ topic: args.topic,
624
+ offer: args.offer,
625
+ request: args.request ?? null,
626
+ from: {
627
+ aid: creds.aid,
628
+ name: creds.agent_name,
629
+ capabilities: creds.capabilities
630
+ }
631
+ };
632
+ const result = await client.message.send({
633
+ to: args.to,
634
+ content: JSON.stringify(proposal)
601
635
  });
602
- ctx.log("info", `Proposal created: thread ${result.thread_id}`);
636
+ ctx.log("info", `Proposal sent: ${result.message_id}`);
603
637
  const output = [
604
638
  "\u{1F4CB} Proposal sent!\n",
605
639
  formatSection("", [
606
- ["Thread ID", result.thread_id],
607
- ["Status", result.status],
640
+ ["Message ID", result.message_id],
608
641
  ["To", args.to.slice(0, 8) + "..."],
609
642
  ["Topic", args.topic],
610
643
  ["Offer", truncate(args.offer, 60)],
611
- ["Request", args.request ? truncate(args.request, 60) : "(open)"],
612
- ["Expires", result.expires_at]
644
+ ["Request", args.request ? truncate(args.request, 60) : "(open)"]
613
645
  ]),
614
646
  "",
615
- `The target agent will see your proposal. They can accept, counter-offer, or reject.`
647
+ `The target agent will see your proposal in their inbox.`,
648
+ `They can respond with neiracore_send_message.`
616
649
  ].join("\n");
617
650
  return textResult(output);
618
651
  } catch (err) {