@naturalpay/sdk 0.0.4 → 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.
- package/README.md +1 -1
- package/dist/index.cjs +47 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +47 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp/cli.cjs +94 -31
- package/dist/mcp/cli.cjs.map +1 -1
- package/dist/mcp/cli.js +94 -31
- package/dist/mcp/cli.js.map +1 -1
- package/dist/mcp/index.cjs +93 -30
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.cts +7 -3
- package/dist/mcp/index.d.ts +7 -3
- package/dist/mcp/index.js +93 -30
- package/dist/mcp/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -210,7 +210,7 @@ npx naturalpay mcp serve --transport http --port 8080
|
|
|
210
210
|
```typescript
|
|
211
211
|
import { createServer } from 'naturalpay/mcp';
|
|
212
212
|
|
|
213
|
-
const server = createServer('pk_sandbox_xxx');
|
|
213
|
+
const server = createServer({ apiKey: 'pk_sandbox_xxx' });
|
|
214
214
|
|
|
215
215
|
// Start with stdio
|
|
216
216
|
server.start({ transportType: 'stdio' });
|
package/dist/index.cjs
CHANGED
|
@@ -298,6 +298,12 @@ function logToolCall(logger2, toolName, options) {
|
|
|
298
298
|
logger2.info(`Tool call: ${toolName}`, extra);
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
+
var toolCallStorage = new async_hooks.AsyncLocalStorage();
|
|
302
|
+
function getToolCallHeader() {
|
|
303
|
+
const data = toolCallStorage.getStore();
|
|
304
|
+
if (!data) return void 0;
|
|
305
|
+
return btoa(JSON.stringify(data));
|
|
306
|
+
}
|
|
301
307
|
|
|
302
308
|
// src/http.ts
|
|
303
309
|
var logger = getLogger("http");
|
|
@@ -531,9 +537,15 @@ var HTTPClient = class {
|
|
|
531
537
|
const headers = {
|
|
532
538
|
Authorization: `Bearer ${jwt}`,
|
|
533
539
|
"Content-Type": "application/json",
|
|
534
|
-
"User-Agent": `naturalpay-ts/${SDK_VERSION2}
|
|
535
|
-
...options?.headers
|
|
540
|
+
"User-Agent": `naturalpay-ts/${SDK_VERSION2}`
|
|
536
541
|
};
|
|
542
|
+
const toolCallHeader = getToolCallHeader();
|
|
543
|
+
if (toolCallHeader) {
|
|
544
|
+
headers["X-Tool-Call"] = toolCallHeader;
|
|
545
|
+
}
|
|
546
|
+
if (options?.headers) {
|
|
547
|
+
Object.assign(headers, options.headers);
|
|
548
|
+
}
|
|
537
549
|
const response = await fetch(url, {
|
|
538
550
|
method,
|
|
539
551
|
headers,
|
|
@@ -649,9 +661,16 @@ var PaymentsResource = class extends BaseResource {
|
|
|
649
661
|
};
|
|
650
662
|
if (params.memo) attributes["description"] = params.memo;
|
|
651
663
|
const body = { data: { attributes } };
|
|
664
|
+
const headers = { "Idempotency-Key": idempotencyKey };
|
|
665
|
+
if (params.agentId) {
|
|
666
|
+
headers["X-Agent-ID"] = params.agentId;
|
|
667
|
+
}
|
|
668
|
+
if (params.instanceId) {
|
|
669
|
+
headers["X-Instance-ID"] = params.instanceId;
|
|
670
|
+
}
|
|
652
671
|
const response = await this.http.post("/payments", {
|
|
653
672
|
body,
|
|
654
|
-
headers
|
|
673
|
+
headers
|
|
655
674
|
});
|
|
656
675
|
return unwrapPayment(response);
|
|
657
676
|
}
|
|
@@ -661,8 +680,14 @@ var PaymentsResource = class extends BaseResource {
|
|
|
661
680
|
* @param transferId - The transfer ID to look up
|
|
662
681
|
* @returns Payment object with current status
|
|
663
682
|
*/
|
|
664
|
-
async retrieve(transferId) {
|
|
665
|
-
const
|
|
683
|
+
async retrieve(transferId, options) {
|
|
684
|
+
const headers = {};
|
|
685
|
+
if (options?.instanceId) {
|
|
686
|
+
headers["X-Instance-ID"] = options.instanceId;
|
|
687
|
+
}
|
|
688
|
+
const response = await this.http.get(`/payments/${transferId}`, {
|
|
689
|
+
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
690
|
+
});
|
|
666
691
|
return unwrapPayment(response);
|
|
667
692
|
}
|
|
668
693
|
};
|
|
@@ -745,8 +770,14 @@ var WalletResource = class extends BaseResource {
|
|
|
745
770
|
*
|
|
746
771
|
* @returns AccountBalance with available, current, pending amounts
|
|
747
772
|
*/
|
|
748
|
-
async balance() {
|
|
749
|
-
const
|
|
773
|
+
async balance(options) {
|
|
774
|
+
const headers = {};
|
|
775
|
+
if (options?.instanceId) {
|
|
776
|
+
headers["X-Instance-ID"] = options.instanceId;
|
|
777
|
+
}
|
|
778
|
+
const response = await this.http.get("/wallet/balance", {
|
|
779
|
+
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
780
|
+
});
|
|
750
781
|
return unwrapBalance(response);
|
|
751
782
|
}
|
|
752
783
|
/**
|
|
@@ -840,6 +871,9 @@ var TransactionsResource = class extends BaseResource {
|
|
|
840
871
|
if (params?.customerPartyId) {
|
|
841
872
|
headers["X-On-Behalf-Of"] = params.customerPartyId;
|
|
842
873
|
}
|
|
874
|
+
if (params?.instanceId) {
|
|
875
|
+
headers["X-Instance-ID"] = params.instanceId;
|
|
876
|
+
}
|
|
843
877
|
const response = await this.http.get("/transactions", {
|
|
844
878
|
params: {
|
|
845
879
|
limit: params?.limit ?? 50,
|
|
@@ -911,13 +945,18 @@ var AgentsResource = class extends BaseResource {
|
|
|
911
945
|
* @returns AgentListResponse with list of agents
|
|
912
946
|
*/
|
|
913
947
|
async list(params) {
|
|
948
|
+
const headers = {};
|
|
949
|
+
if (params?.instanceId) {
|
|
950
|
+
headers["X-Instance-ID"] = params.instanceId;
|
|
951
|
+
}
|
|
914
952
|
const response = await this.http.get("/agents", {
|
|
915
953
|
params: {
|
|
916
954
|
status: params?.status,
|
|
917
955
|
partyId: params?.partyId,
|
|
918
956
|
limit: params?.limit ?? 50,
|
|
919
957
|
cursor: params?.cursor
|
|
920
|
-
}
|
|
958
|
+
},
|
|
959
|
+
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
921
960
|
});
|
|
922
961
|
return unwrapAgentList(response);
|
|
923
962
|
}
|