@naturalpay/sdk 0.0.3 → 0.0.5

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.

Potentially problematic release.


This version of @naturalpay/sdk might be problematic. Click here for more details.

package/dist/mcp/index.js CHANGED
@@ -200,6 +200,22 @@ function logToolCall(logger3, toolName, options) {
200
200
  logger3.info(`Tool call: ${toolName}`, extra);
201
201
  }
202
202
  }
203
+ var toolCallStorage = new AsyncLocalStorage();
204
+ function getToolCallHeader() {
205
+ const data = toolCallStorage.getStore();
206
+ if (!data) return void 0;
207
+ return btoa(JSON.stringify(data));
208
+ }
209
+ function runWithToolCall(name, args, fn) {
210
+ return toolCallStorage.run(
211
+ {
212
+ tool: name,
213
+ arguments: args,
214
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
215
+ },
216
+ fn
217
+ );
218
+ }
203
219
 
204
220
  // src/http.ts
205
221
  var logger = getLogger("http");
@@ -433,9 +449,15 @@ var HTTPClient = class {
433
449
  const headers = {
434
450
  Authorization: `Bearer ${jwt}`,
435
451
  "Content-Type": "application/json",
436
- "User-Agent": `naturalpay-ts/${SDK_VERSION2}`,
437
- ...options?.headers
452
+ "User-Agent": `naturalpay-ts/${SDK_VERSION2}`
438
453
  };
454
+ const toolCallHeader = getToolCallHeader();
455
+ if (toolCallHeader) {
456
+ headers["X-Tool-Call"] = toolCallHeader;
457
+ }
458
+ if (options?.headers) {
459
+ Object.assign(headers, options.headers);
460
+ }
439
461
  const response = await fetch(url, {
440
462
  method,
441
463
  headers,
@@ -551,9 +573,16 @@ var PaymentsResource = class extends BaseResource {
551
573
  };
552
574
  if (params.memo) attributes["description"] = params.memo;
553
575
  const body = { data: { attributes } };
576
+ const headers = { "Idempotency-Key": idempotencyKey };
577
+ if (params.agentId) {
578
+ headers["X-Agent-ID"] = params.agentId;
579
+ }
580
+ if (params.instanceId) {
581
+ headers["X-Instance-ID"] = params.instanceId;
582
+ }
554
583
  const response = await this.http.post("/payments", {
555
584
  body,
556
- headers: { "Idempotency-Key": idempotencyKey }
585
+ headers
557
586
  });
558
587
  return unwrapPayment(response);
559
588
  }
@@ -563,8 +592,14 @@ var PaymentsResource = class extends BaseResource {
563
592
  * @param transferId - The transfer ID to look up
564
593
  * @returns Payment object with current status
565
594
  */
566
- async retrieve(transferId) {
567
- const response = await this.http.get(`/payments/${transferId}`);
595
+ async retrieve(transferId, options) {
596
+ const headers = {};
597
+ if (options?.instanceId) {
598
+ headers["X-Instance-ID"] = options.instanceId;
599
+ }
600
+ const response = await this.http.get(`/payments/${transferId}`, {
601
+ headers: Object.keys(headers).length > 0 ? headers : void 0
602
+ });
568
603
  return unwrapPayment(response);
569
604
  }
570
605
  };
@@ -590,14 +625,71 @@ function unwrapBalance(response) {
590
625
  pendingClaimCount: attributes.pendingClaimCount != null ? Number(attributes.pendingClaimCount) : void 0
591
626
  };
592
627
  }
628
+ function unwrapDeposit(response) {
629
+ if (!response?.data) {
630
+ throw new NaturalError('Unexpected response format: missing "data" field in deposit response');
631
+ }
632
+ const { data } = response;
633
+ if (data.type !== "deposit" || !data.attributes) {
634
+ throw new NaturalError(
635
+ `Unexpected resource format: expected type "deposit", got "${data.type}"`
636
+ );
637
+ }
638
+ const { id, attributes } = data;
639
+ return {
640
+ transferId: id ?? void 0,
641
+ status: String(attributes.status),
642
+ amount: attributes.amount != null ? String(attributes.amount) : "",
643
+ currency: String(attributes.currency),
644
+ estimatedSettlement: attributes.estimatedSettlement != null ? String(attributes.estimatedSettlement) : void 0,
645
+ error: attributes.error != null ? String(attributes.error) : void 0,
646
+ errorDetails: attributes.errorDetails != null ? String(attributes.errorDetails) : void 0
647
+ };
648
+ }
649
+ function unwrapWithdrawal(response) {
650
+ if (!response?.data) {
651
+ throw new NaturalError(
652
+ 'Unexpected response format: missing "data" field in withdrawal response'
653
+ );
654
+ }
655
+ const { data } = response;
656
+ if (data.type !== "withdrawal" || !data.attributes) {
657
+ throw new NaturalError(
658
+ `Unexpected resource format: expected type "withdrawal", got "${data.type}"`
659
+ );
660
+ }
661
+ const { id, attributes } = data;
662
+ return {
663
+ transferId: id ?? void 0,
664
+ instructionId: attributes.instructionId != null ? String(attributes.instructionId) : void 0,
665
+ status: String(attributes.status),
666
+ amount: attributes.amount != null ? String(attributes.amount) : "",
667
+ currency: String(attributes.currency),
668
+ estimatedSettlement: attributes.estimatedSettlement != null ? String(attributes.estimatedSettlement) : void 0,
669
+ kycRequired: Boolean(attributes.kycRequired),
670
+ kycStatus: attributes.kycStatus != null ? String(attributes.kycStatus) : void 0,
671
+ kycSessionUrl: attributes.kycSessionUrl != null ? String(attributes.kycSessionUrl) : void 0,
672
+ mfaRequired: Boolean(attributes.mfaRequired),
673
+ mfaChallengeId: attributes.mfaChallengeId != null ? String(attributes.mfaChallengeId) : void 0,
674
+ mfaExpiresAt: attributes.mfaExpiresAt != null ? String(attributes.mfaExpiresAt) : void 0,
675
+ error: attributes.error != null ? String(attributes.error) : void 0,
676
+ errorDetails: attributes.errorDetails != null ? String(attributes.errorDetails) : void 0
677
+ };
678
+ }
593
679
  var WalletResource = class extends BaseResource {
594
680
  /**
595
681
  * Get current wallet balance.
596
682
  *
597
683
  * @returns AccountBalance with available, current, pending amounts
598
684
  */
599
- async balance() {
600
- const response = await this.http.get("/wallet/balance");
685
+ async balance(options) {
686
+ const headers = {};
687
+ if (options?.instanceId) {
688
+ headers["X-Instance-ID"] = options.instanceId;
689
+ }
690
+ const response = await this.http.get("/wallet/balance", {
691
+ headers: Object.keys(headers).length > 0 ? headers : void 0
692
+ });
601
693
  return unwrapBalance(response);
602
694
  }
603
695
  /**
@@ -607,18 +699,20 @@ var WalletResource = class extends BaseResource {
607
699
  * @returns DepositResponse with transfer status
608
700
  */
609
701
  async deposit(params) {
610
- const body = {
702
+ const attributes = {
611
703
  amount: params.amount,
612
704
  currency: params.currency ?? "USD",
613
705
  paymentInstrumentId: params.paymentInstrumentId
614
706
  };
615
707
  if (params.description) {
616
- body["description"] = params.description;
708
+ attributes["description"] = params.description;
617
709
  }
618
- return this.http.post("/wallet/deposit", {
710
+ const body = { data: { attributes } };
711
+ const response = await this.http.post("/wallet/deposit", {
619
712
  body,
620
713
  headers: { "Idempotency-Key": params.idempotencyKey }
621
714
  });
715
+ return unwrapDeposit(response);
622
716
  }
623
717
  /**
624
718
  * Initiate a withdrawal to a linked bank account.
@@ -627,21 +721,19 @@ var WalletResource = class extends BaseResource {
627
721
  * @returns WithdrawResponse with transfer status (may require KYC/MFA)
628
722
  */
629
723
  async withdraw(params) {
630
- const body = {
724
+ const attributes = {
631
725
  amount: params.amount,
632
726
  currency: params.currency ?? "USD",
633
727
  paymentInstrumentId: params.paymentInstrumentId
634
728
  };
635
- if (params.description) {
636
- body["description"] = params.description;
637
- }
638
- if (params.walletId) {
639
- body["walletId"] = params.walletId;
640
- }
641
- return this.http.post("/wallet/withdraw", {
729
+ if (params.description) attributes["description"] = params.description;
730
+ if (params.walletId) attributes["walletId"] = params.walletId;
731
+ const body = { data: { attributes } };
732
+ const response = await this.http.post("/wallet/withdraw", {
642
733
  body,
643
734
  headers: { "Idempotency-Key": params.idempotencyKey }
644
735
  });
736
+ return unwrapWithdrawal(response);
645
737
  }
646
738
  };
647
739
 
@@ -691,6 +783,9 @@ var TransactionsResource = class extends BaseResource {
691
783
  if (params?.customerPartyId) {
692
784
  headers["X-On-Behalf-Of"] = params.customerPartyId;
693
785
  }
786
+ if (params?.instanceId) {
787
+ headers["X-Instance-ID"] = params.instanceId;
788
+ }
694
789
  const response = await this.http.get("/transactions", {
695
790
  params: {
696
791
  limit: params?.limit ?? 50,
@@ -762,13 +857,18 @@ var AgentsResource = class extends BaseResource {
762
857
  * @returns AgentListResponse with list of agents
763
858
  */
764
859
  async list(params) {
860
+ const headers = {};
861
+ if (params?.instanceId) {
862
+ headers["X-Instance-ID"] = params.instanceId;
863
+ }
765
864
  const response = await this.http.get("/agents", {
766
865
  params: {
767
866
  status: params?.status,
768
867
  partyId: params?.partyId,
769
868
  limit: params?.limit ?? 50,
770
869
  cursor: params?.cursor
771
- }
870
+ },
871
+ headers: Object.keys(headers).length > 0 ? headers : void 0
772
872
  });
773
873
  return unwrapAgentList(response);
774
874
  }
@@ -843,6 +943,52 @@ var AgentsResource = class extends BaseResource {
843
943
  };
844
944
 
845
945
  // src/resources/delegations.ts
946
+ function unwrapDelegationResource(resource) {
947
+ if (resource.type !== "delegation" || !resource.attributes) {
948
+ throw new NaturalError(
949
+ `Unexpected resource format: expected type "delegation", got "${resource.type}"`
950
+ );
951
+ }
952
+ const { id, attributes, relationships } = resource;
953
+ return {
954
+ id,
955
+ delegatingPartyId: relationships?.delegatingParty?.data?.id ?? "",
956
+ delegatedPartyId: relationships?.delegatedParty?.data?.id ?? "",
957
+ delegatingPartyName: attributes.delegatingPartyName != null ? String(attributes.delegatingPartyName) : void 0,
958
+ delegatedPartyName: attributes.delegatedPartyName != null ? String(attributes.delegatedPartyName) : void 0,
959
+ delegatingPartyEmail: attributes.delegatingPartyEmail != null ? String(attributes.delegatingPartyEmail) : void 0,
960
+ delegatedPartyEmail: attributes.delegatedPartyEmail != null ? String(attributes.delegatedPartyEmail) : void 0,
961
+ permissions: Array.isArray(attributes.permissions) ? attributes.permissions : [],
962
+ sourceType: attributes.sourceType != null ? String(attributes.sourceType) : void 0,
963
+ sourceId: attributes.sourceId != null ? String(attributes.sourceId) : void 0,
964
+ expiresAt: attributes.expiresAt != null ? String(attributes.expiresAt) : void 0,
965
+ status: String(attributes.status),
966
+ createdAt: String(attributes.createdAt),
967
+ createdBy: attributes.createdBy != null ? String(attributes.createdBy) : void 0
968
+ };
969
+ }
970
+ function unwrapDelegation(response) {
971
+ if (!response?.data) {
972
+ throw new NaturalError(
973
+ 'Unexpected response format: missing "data" field in delegation response'
974
+ );
975
+ }
976
+ return unwrapDelegationResource(response.data);
977
+ }
978
+ function unwrapDelegationList(response) {
979
+ if (!response?.data || !Array.isArray(response.data)) {
980
+ throw new NaturalError(
981
+ 'Unexpected response format: missing "data" array in delegation list response'
982
+ );
983
+ }
984
+ const delegations = response.data.map(unwrapDelegationResource);
985
+ const pagination = response.meta?.pagination ?? {};
986
+ return {
987
+ delegations,
988
+ hasMore: pagination.hasMore ?? false,
989
+ nextCursor: pagination.nextCursor ?? null
990
+ };
991
+ }
846
992
  var DelegationsResource = class extends BaseResource {
847
993
  /**
848
994
  * List delegations with optional filters.
@@ -851,7 +997,7 @@ var DelegationsResource = class extends BaseResource {
851
997
  * @returns DelegationListResponse with list of delegations
852
998
  */
853
999
  async list(params) {
854
- return this.http.get("/delegations", {
1000
+ const response = await this.http.get("/delegations", {
855
1001
  params: {
856
1002
  status: params?.status,
857
1003
  delegatingPartyId: params?.delegatingPartyId,
@@ -860,6 +1006,7 @@ var DelegationsResource = class extends BaseResource {
860
1006
  cursor: params?.cursor
861
1007
  }
862
1008
  });
1009
+ return unwrapDelegationList(response);
863
1010
  }
864
1011
  /**
865
1012
  * Get delegation by ID.
@@ -868,7 +1015,8 @@ var DelegationsResource = class extends BaseResource {
868
1015
  * @returns Delegation details
869
1016
  */
870
1017
  async get(delegationId) {
871
- return this.http.get(`/delegations/${delegationId}`);
1018
+ const response = await this.http.get(`/delegations/${delegationId}`);
1019
+ return unwrapDelegation(response);
872
1020
  }
873
1021
  /**
874
1022
  * Update an existing delegation.
@@ -878,11 +1026,15 @@ var DelegationsResource = class extends BaseResource {
878
1026
  * @returns Updated Delegation
879
1027
  */
880
1028
  async update(delegationId, params) {
881
- const body = {};
882
- if (params.status !== void 0) body["status"] = params.status;
883
- if (params.permissions !== void 0) body["permissions"] = params.permissions;
884
- if (params.expiresAt !== void 0) body["expiresAt"] = params.expiresAt;
885
- return this.http.put(`/delegations/${delegationId}`, { body });
1029
+ const attributes = {};
1030
+ if (params.status !== void 0) attributes["status"] = params.status;
1031
+ if (params.permissions !== void 0) attributes["permissions"] = params.permissions;
1032
+ if (params.expiresAt !== void 0) attributes["expiresAt"] = params.expiresAt;
1033
+ const body = { data: { attributes } };
1034
+ const response = await this.http.put(`/delegations/${delegationId}`, {
1035
+ body
1036
+ });
1037
+ return unwrapDelegation(response);
886
1038
  }
887
1039
  /**
888
1040
  * Revoke a delegation (soft delete by setting status to REVOKED).
@@ -896,6 +1048,41 @@ var DelegationsResource = class extends BaseResource {
896
1048
  };
897
1049
 
898
1050
  // src/resources/customers.ts
1051
+ function unwrapCustomerResource(resource) {
1052
+ if (resource.type !== "customer" || !resource.attributes) {
1053
+ throw new NaturalError(
1054
+ `Unexpected resource format: expected type "customer", got "${resource.type}"`
1055
+ );
1056
+ }
1057
+ const { id, attributes, relationships } = resource;
1058
+ return {
1059
+ party: {
1060
+ id,
1061
+ type: String(attributes.partyType),
1062
+ legalName: attributes.legalName != null ? String(attributes.legalName) : void 0,
1063
+ displayName: attributes.displayName != null ? String(attributes.displayName) : void 0,
1064
+ status: attributes.partyStatus != null ? String(attributes.partyStatus) : void 0
1065
+ },
1066
+ delegationId: relationships?.delegation?.data?.id ?? "",
1067
+ permissions: Array.isArray(attributes.permissions) ? attributes.permissions : [],
1068
+ delegationStatus: String(attributes.delegationStatus),
1069
+ createdAt: String(attributes.createdAt)
1070
+ };
1071
+ }
1072
+ function unwrapCustomerList(response) {
1073
+ if (!response?.data || !Array.isArray(response.data)) {
1074
+ throw new NaturalError(
1075
+ 'Unexpected response format: missing "data" array in customer list response'
1076
+ );
1077
+ }
1078
+ const items = response.data.map(unwrapCustomerResource);
1079
+ const pagination = response.meta?.pagination ?? {};
1080
+ return {
1081
+ items,
1082
+ hasMore: pagination.hasMore ?? false,
1083
+ nextCursor: pagination.nextCursor ?? null
1084
+ };
1085
+ }
899
1086
  var CustomersResource = class extends BaseResource {
900
1087
  /**
901
1088
  * List customers onboarded by the partner via delegation.
@@ -904,12 +1091,13 @@ var CustomersResource = class extends BaseResource {
904
1091
  * @returns CustomerListResponse with items, hasMore, nextCursor
905
1092
  */
906
1093
  async list(params) {
907
- return this.http.get("/customers", {
1094
+ const response = await this.http.get("/customers", {
908
1095
  params: {
909
1096
  limit: params?.limit,
910
1097
  cursor: params?.cursor
911
1098
  }
912
1099
  });
1100
+ return unwrapCustomerList(response);
913
1101
  }
914
1102
  };
915
1103
 
@@ -949,7 +1137,8 @@ var NaturalClient = class {
949
1137
 
950
1138
  // src/mcp/server.ts
951
1139
  var logger2 = getLogger("mcp.server");
952
- function createServer(apiKey) {
1140
+ function createServer(apiKeyOrOptions) {
1141
+ const options = typeof apiKeyOrOptions === "string" ? { apiKey: apiKeyOrOptions } : apiKeyOrOptions ?? {};
953
1142
  logger2.info("Creating Natural Payments MCP server");
954
1143
  const server = new FastMCP({
955
1144
  name: "Natural Payments",
@@ -958,7 +1147,7 @@ function createServer(apiKey) {
958
1147
  let client = null;
959
1148
  const getClient = () => {
960
1149
  if (!client) {
961
- client = new NaturalClient({ apiKey });
1150
+ client = new NaturalClient({ apiKey: options.apiKey });
962
1151
  }
963
1152
  return client;
964
1153
  };
@@ -969,11 +1158,13 @@ function createServer(apiKey) {
969
1158
  amount: z.number().positive().describe("Payment amount"),
970
1159
  memo: z.string().describe("Payment memo (required)"),
971
1160
  customerPartyId: z.string().describe("Customer party ID on whose behalf (pty_xxx)"),
1161
+ agentId: z.string().optional().describe("Agent ID (agt_xxx) for agent-initiated payments"),
972
1162
  recipientEmail: z.string().email().optional().describe("Recipient email address"),
973
1163
  recipientPhone: z.string().optional().describe("Recipient phone number"),
974
- recipientPartyId: z.string().optional().describe("Recipient party ID (pty_xxx)")
1164
+ recipientPartyId: z.string().optional().describe("Recipient party ID (pty_xxx)"),
1165
+ instanceId: z.string().optional().describe("Developer's session/conversation ID for observability grouping")
975
1166
  }),
976
- execute: async (args) => {
1167
+ execute: async (args) => runWithToolCall("create_payment", args, async () => {
977
1168
  const startTime = Date.now();
978
1169
  try {
979
1170
  const result = await getClient().payments.create({
@@ -982,7 +1173,9 @@ function createServer(apiKey) {
982
1173
  recipientPartyId: args.recipientPartyId,
983
1174
  amount: args.amount,
984
1175
  memo: args.memo,
985
- customerPartyId: args.customerPartyId
1176
+ customerPartyId: args.customerPartyId,
1177
+ agentId: args.agentId,
1178
+ instanceId: args.instanceId
986
1179
  });
987
1180
  const durationMs = Date.now() - startTime;
988
1181
  logToolCall(logger2, "create_payment", { success: true, durationMs });
@@ -996,18 +1189,21 @@ function createServer(apiKey) {
996
1189
  });
997
1190
  throw error;
998
1191
  }
999
- }
1192
+ })
1000
1193
  });
1001
1194
  server.addTool({
1002
1195
  name: "get_payment_status",
1003
1196
  description: "Check the status of a payment by transfer ID",
1004
1197
  parameters: z.object({
1005
- transferId: z.string().describe("The transfer ID returned from create_payment")
1198
+ transferId: z.string().describe("The transfer ID returned from create_payment"),
1199
+ instanceId: z.string().optional().describe("Developer's session/conversation ID for observability grouping")
1006
1200
  }),
1007
- execute: async (args) => {
1201
+ execute: async (args) => runWithToolCall("get_payment_status", args, async () => {
1008
1202
  const startTime = Date.now();
1009
1203
  try {
1010
- const result = await getClient().payments.retrieve(args.transferId);
1204
+ const result = await getClient().payments.retrieve(args.transferId, {
1205
+ instanceId: args.instanceId
1206
+ });
1011
1207
  const durationMs = Date.now() - startTime;
1012
1208
  logToolCall(logger2, "get_payment_status", { success: true, durationMs });
1013
1209
  return JSON.stringify(result, null, 2);
@@ -1020,16 +1216,18 @@ function createServer(apiKey) {
1020
1216
  });
1021
1217
  throw error;
1022
1218
  }
1023
- }
1219
+ })
1024
1220
  });
1025
1221
  server.addTool({
1026
1222
  name: "get_account_balance",
1027
1223
  description: "Get the current wallet balance",
1028
- parameters: z.object({}),
1029
- execute: async () => {
1224
+ parameters: z.object({
1225
+ instanceId: z.string().optional().describe("Developer's session/conversation ID for observability grouping")
1226
+ }),
1227
+ execute: async (args) => runWithToolCall("get_account_balance", args, async () => {
1030
1228
  const startTime = Date.now();
1031
1229
  try {
1032
- const result = await getClient().wallet.balance();
1230
+ const result = await getClient().wallet.balance({ instanceId: args.instanceId });
1033
1231
  const balances = result.balances.map((bal) => ({
1034
1232
  assetCode: bal.assetCode,
1035
1233
  available: bal.available.amountDollars,
@@ -1060,7 +1258,7 @@ function createServer(apiKey) {
1060
1258
  });
1061
1259
  throw error;
1062
1260
  }
1063
- }
1261
+ })
1064
1262
  });
1065
1263
  server.addTool({
1066
1264
  name: "list_transactions",
@@ -1069,16 +1267,18 @@ function createServer(apiKey) {
1069
1267
  limit: z.number().min(1).max(100).default(50).describe("Maximum number of transactions"),
1070
1268
  cursor: z.string().optional().describe("Pagination cursor from previous response"),
1071
1269
  agentId: z.string().optional().describe("Agent ID for agent-context authentication"),
1072
- customerPartyId: z.string().optional().describe("Customer party ID when acting on behalf of customer")
1270
+ customerPartyId: z.string().optional().describe("Customer party ID when acting on behalf of customer"),
1271
+ instanceId: z.string().optional().describe("Developer's session/conversation ID for observability grouping")
1073
1272
  }),
1074
- execute: async (args) => {
1273
+ execute: async (args) => runWithToolCall("list_transactions", args, async () => {
1075
1274
  const startTime = Date.now();
1076
1275
  try {
1077
1276
  const result = await getClient().transactions.list({
1078
1277
  limit: args.limit,
1079
1278
  cursor: args.cursor,
1080
1279
  agentId: args.agentId,
1081
- customerPartyId: args.customerPartyId
1280
+ customerPartyId: args.customerPartyId,
1281
+ instanceId: args.instanceId
1082
1282
  });
1083
1283
  const durationMs = Date.now() - startTime;
1084
1284
  logToolCall(logger2, "list_transactions", { success: true, durationMs });
@@ -1092,21 +1292,23 @@ function createServer(apiKey) {
1092
1292
  });
1093
1293
  throw error;
1094
1294
  }
1095
- }
1295
+ })
1096
1296
  });
1097
1297
  server.addTool({
1098
1298
  name: "list_agents",
1099
1299
  description: "List agents for the partner",
1100
1300
  parameters: z.object({
1101
1301
  status: z.enum(["ACTIVE", "REVOKED"]).optional().describe("Filter by status"),
1102
- limit: z.number().min(1).max(100).default(50).describe("Maximum number of agents")
1302
+ limit: z.number().min(1).max(100).default(50).describe("Maximum number of agents"),
1303
+ instanceId: z.string().optional().describe("Developer's session/conversation ID for observability grouping")
1103
1304
  }),
1104
- execute: async (args) => {
1305
+ execute: async (args) => runWithToolCall("list_agents", args, async () => {
1105
1306
  const startTime = Date.now();
1106
1307
  try {
1107
1308
  const result = await getClient().agents.list({
1108
1309
  status: args.status,
1109
- limit: args.limit
1310
+ limit: args.limit,
1311
+ instanceId: args.instanceId
1110
1312
  });
1111
1313
  const durationMs = Date.now() - startTime;
1112
1314
  logToolCall(logger2, "list_agents", { success: true, durationMs });
@@ -1120,7 +1322,7 @@ function createServer(apiKey) {
1120
1322
  });
1121
1323
  throw error;
1122
1324
  }
1123
- }
1325
+ })
1124
1326
  });
1125
1327
  return server;
1126
1328
  }