@clawpay-hedera/sdk 0.1.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/README.md +294 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +137 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/hedera-payment.d.ts +25 -0
- package/dist/client/hedera-payment.d.ts.map +1 -0
- package/dist/client/hedera-payment.js +68 -0
- package/dist/client/hedera-payment.js.map +1 -0
- package/dist/client/with-x402-client.d.ts +27 -0
- package/dist/client/with-x402-client.d.ts.map +1 -0
- package/dist/client/with-x402-client.js +136 -0
- package/dist/client/with-x402-client.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/handler/proxy/hooks/analytics-hook.d.ts +299 -0
- package/dist/handler/proxy/hooks/analytics-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/analytics-hook.js +133 -0
- package/dist/handler/proxy/hooks/analytics-hook.js.map +1 -0
- package/dist/handler/proxy/hooks/auth-headers-hook.d.ts +20 -0
- package/dist/handler/proxy/hooks/auth-headers-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/auth-headers-hook.js +34 -0
- package/dist/handler/proxy/hooks/auth-headers-hook.js.map +1 -0
- package/dist/handler/proxy/hooks/hcs-audit-hook.d.ts +133 -0
- package/dist/handler/proxy/hooks/hcs-audit-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/hcs-audit-hook.js +138 -0
- package/dist/handler/proxy/hooks/hcs-audit-hook.js.map +1 -0
- package/dist/handler/proxy/hooks/logging-hook.d.ts +100 -0
- package/dist/handler/proxy/hooks/logging-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/logging-hook.js +14 -0
- package/dist/handler/proxy/hooks/logging-hook.js.map +1 -0
- package/dist/handler/proxy/hooks/x402-hook.d.ts +246 -0
- package/dist/handler/proxy/hooks/x402-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/x402-hook.js +219 -0
- package/dist/handler/proxy/hooks/x402-hook.js.map +1 -0
- package/dist/handler/proxy/hooks.d.ts +12111 -0
- package/dist/handler/proxy/hooks.d.ts.map +1 -0
- package/dist/handler/proxy/hooks.js +142 -0
- package/dist/handler/proxy/hooks.js.map +1 -0
- package/dist/handler/proxy/index.d.ts +3 -0
- package/dist/handler/proxy/index.d.ts.map +1 -0
- package/dist/handler/proxy/index.js +489 -0
- package/dist/handler/proxy/index.js.map +1 -0
- package/dist/handler/server/index.d.ts +25 -0
- package/dist/handler/server/index.d.ts.map +1 -0
- package/dist/handler/server/index.js +38 -0
- package/dist/handler/server/index.js.map +1 -0
- package/dist/handler/server/platform-detection.d.ts +32 -0
- package/dist/handler/server/platform-detection.d.ts.map +1 -0
- package/dist/handler/server/platform-detection.js +441 -0
- package/dist/handler/server/platform-detection.js.map +1 -0
- package/dist/handler/server/plugins/with-x402.d.ts +21 -0
- package/dist/handler/server/plugins/with-x402.d.ts.map +1 -0
- package/dist/handler/server/plugins/with-x402.js +290 -0
- package/dist/handler/server/plugins/with-x402.js.map +1 -0
- package/dist/handler/server/templates/x402-server.d.ts +16 -0
- package/dist/handler/server/templates/x402-server.d.ts.map +1 -0
- package/dist/handler/server/templates/x402-server.js +13 -0
- package/dist/handler/server/templates/x402-server.js.map +1 -0
- package/dist/handler/shared/hedera-price.d.ts +26 -0
- package/dist/handler/shared/hedera-price.d.ts.map +1 -0
- package/dist/handler/shared/hedera-price.js +54 -0
- package/dist/handler/shared/hedera-price.js.map +1 -0
- package/dist/handler.d.ts +14 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +12 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/networks/hedera.d.ts +52 -0
- package/dist/networks/hedera.d.ts.map +1 -0
- package/dist/networks/hedera.js +61 -0
- package/dist/networks/hedera.js.map +1 -0
- package/dist/server/stdio/index.d.ts +2 -0
- package/dist/server/stdio/index.d.ts.map +1 -0
- package/dist/server/stdio/index.js +91 -0
- package/dist/server/stdio/index.js.map +1 -0
- package/dist/server/stdio/proxy-server.d.ts +9 -0
- package/dist/server/stdio/proxy-server.d.ts.map +1 -0
- package/dist/server/stdio/proxy-server.js +53 -0
- package/dist/server/stdio/proxy-server.js.map +1 -0
- package/dist/server/stdio/start-stdio-server.d.ts +28 -0
- package/dist/server/stdio/start-stdio-server.d.ts.map +1 -0
- package/dist/server/stdio/start-stdio-server.js +84 -0
- package/dist/server/stdio/start-stdio-server.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -0
- package/dist/utils/signer.d.ts +4 -0
- package/dist/utils/signer.d.ts.map +1 -0
- package/dist/utils/signer.js +58 -0
- package/dist/utils/signer.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { config } from "dotenv";
|
|
2
|
+
import { createServerConnections, ServerType, startStdioServer } from "./start-stdio-server.js";
|
|
3
|
+
config();
|
|
4
|
+
// Load environment variables
|
|
5
|
+
const serverUrls = process.env.SERVER_URLS?.split(',');
|
|
6
|
+
if (!serverUrls || serverUrls.length === 0) {
|
|
7
|
+
throw new Error("Missing environment variables: SERVER_URLS is required");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validates that the parsed wallet object has the correct structure for X402ClientConfig['wallet']
|
|
11
|
+
* @param wallet - The parsed wallet object to validate
|
|
12
|
+
* @returns true if the wallet structure is valid, false otherwise
|
|
13
|
+
*/
|
|
14
|
+
function isValidWalletStructure(wallet) {
|
|
15
|
+
if (!wallet || typeof wallet !== 'object') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const walletObj = wallet;
|
|
19
|
+
// Check if it has evm or svm properties (at least one should be present)
|
|
20
|
+
const hasEvm = 'evm' in walletObj;
|
|
21
|
+
const hasSvm = 'svm' in walletObj;
|
|
22
|
+
if (!hasEvm && !hasSvm) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
// If evm is present, it should be an object
|
|
26
|
+
if (hasEvm && (typeof walletObj.evm !== 'object' || walletObj.evm === null)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
// If svm is present, it should be an object
|
|
30
|
+
if (hasSvm && (typeof walletObj.svm !== 'object' || walletObj.svm === null)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
// Optional X402 client config via env
|
|
36
|
+
const x402WalletJson = process.env.X402_WALLET_JSON;
|
|
37
|
+
const x402MaxAtomic = process.env.X402_MAX_ATOMIC;
|
|
38
|
+
const x402Version = process.env.X402_VERSION;
|
|
39
|
+
let x402ClientConfig = undefined;
|
|
40
|
+
if (x402WalletJson) {
|
|
41
|
+
try {
|
|
42
|
+
const parsedWallet = JSON.parse(x402WalletJson);
|
|
43
|
+
if (!isValidWalletStructure(parsedWallet)) {
|
|
44
|
+
console.error("Invalid X402_WALLET_JSON structure. Must contain 'evm' and/or 'svm' wallet objects.");
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const wallet = parsedWallet;
|
|
48
|
+
const maybeMax = x402MaxAtomic ? (() => { try {
|
|
49
|
+
return BigInt(x402MaxAtomic);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
} })() : undefined;
|
|
54
|
+
const maybeVersion = x402Version ? Number(x402Version) : undefined;
|
|
55
|
+
x402ClientConfig = {
|
|
56
|
+
wallet,
|
|
57
|
+
...(maybeMax !== undefined ? { maxPaymentValue: maybeMax } : {}),
|
|
58
|
+
...(maybeVersion !== undefined ? { version: maybeVersion } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
console.error("Invalid X402_WALLET_JSON. Must be valid JSON.");
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Main function to start the MCP stdio server
|
|
68
|
+
* This connects to multiple remote MCP servers and exposes them via a stdio interface
|
|
69
|
+
*/
|
|
70
|
+
async function main() {
|
|
71
|
+
try {
|
|
72
|
+
// console.log(`Connecting to ${serverUrls.length} server(s)...`);
|
|
73
|
+
// Multi-server approach using HTTP stream + optional X402 client
|
|
74
|
+
const serverConnections = createServerConnections(serverUrls, ServerType.HTTPStream);
|
|
75
|
+
await startStdioServer({
|
|
76
|
+
serverConnections,
|
|
77
|
+
x402ClientConfig,
|
|
78
|
+
});
|
|
79
|
+
// console.log(`Connected to ${serverUrls.length} servers using payment transport`);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error("Failed to start server:", error);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Run the main function
|
|
87
|
+
main().catch(err => {
|
|
88
|
+
console.error("Fatal error:", err);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/stdio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhG,MAAM,EAAE,CAAC;AAET,6BAA6B;AAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,GAA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AiB;YACjB,gBAAgB;SACnB,CAAC,CAAC;QAEH,oFAAoF;IACxF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC;AAED,wBAAwB;AACxB,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { type ServerCapabilities } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
export declare const proxyServer: ({ client, server, serverCapabilities, }: {
|
|
5
|
+
client: Client;
|
|
6
|
+
server: Server;
|
|
7
|
+
serverCapabilities: ServerCapabilities;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
//# sourceMappingURL=proxy-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-server.d.ts","sourceRoot":"","sources":["../../../src/server/stdio/proxy-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAWL,KAAK,kBAAkB,EAGxB,MAAM,oCAAoC,CAAC;AAE5C,eAAO,MAAM,WAAW,GAAU,yCAI/B;IACD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,KAAG,OAAO,CAAC,IAAI,CAyEf,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CallToolRequestSchema, CompleteRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ListToolsRequestSchema, LoggingMessageNotificationSchema, ReadResourceRequestSchema, ResourceUpdatedNotificationSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
export const proxyServer = async ({ client, server, serverCapabilities, }) => {
|
|
3
|
+
if (serverCapabilities?.logging) {
|
|
4
|
+
server.setNotificationHandler(LoggingMessageNotificationSchema, async (args) => {
|
|
5
|
+
return client.notification(args);
|
|
6
|
+
});
|
|
7
|
+
client.setNotificationHandler(LoggingMessageNotificationSchema, async (args) => {
|
|
8
|
+
return server.notification(args);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (serverCapabilities?.prompts) {
|
|
12
|
+
server.setRequestHandler(GetPromptRequestSchema, async (args) => {
|
|
13
|
+
return client.getPrompt(args.params);
|
|
14
|
+
});
|
|
15
|
+
server.setRequestHandler(ListPromptsRequestSchema, async (args) => {
|
|
16
|
+
return client.listPrompts(args.params);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (serverCapabilities?.resources) {
|
|
20
|
+
server.setRequestHandler(ListResourcesRequestSchema, async (args) => {
|
|
21
|
+
return client.listResources(args.params);
|
|
22
|
+
});
|
|
23
|
+
server.setRequestHandler(ListResourceTemplatesRequestSchema, async (args) => {
|
|
24
|
+
return client.listResourceTemplates(args.params);
|
|
25
|
+
});
|
|
26
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (args) => {
|
|
27
|
+
return client.readResource(args.params);
|
|
28
|
+
});
|
|
29
|
+
if (serverCapabilities?.resources.subscribe) {
|
|
30
|
+
server.setNotificationHandler(ResourceUpdatedNotificationSchema, async (args) => {
|
|
31
|
+
return client.notification(args);
|
|
32
|
+
});
|
|
33
|
+
server.setRequestHandler(SubscribeRequestSchema, async (args) => {
|
|
34
|
+
return client.subscribeResource(args.params);
|
|
35
|
+
});
|
|
36
|
+
server.setRequestHandler(UnsubscribeRequestSchema, async (args) => {
|
|
37
|
+
return client.unsubscribeResource(args.params);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (serverCapabilities?.tools) {
|
|
42
|
+
server.setRequestHandler(CallToolRequestSchema, async (args) => {
|
|
43
|
+
return client.callTool(args.params);
|
|
44
|
+
});
|
|
45
|
+
server.setRequestHandler(ListToolsRequestSchema, async (args) => {
|
|
46
|
+
return client.listTools(args.params);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
server.setRequestHandler(CompleteRequestSchema, async (args) => {
|
|
50
|
+
return client.complete(args.params);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=proxy-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-server.js","sourceRoot":"","sources":["../../../src/server/stdio/proxy-server.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,kCAAkC,EAClC,sBAAsB,EACtB,gCAAgC,EAChC,yBAAyB,EACzB,iCAAiC,EAEjC,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,EAChC,MAAM,EACN,MAAM,EACN,kBAAkB,GAKnB,EAAiB,EAAE;IAClB,IAAI,kBAAkB,EAAE,OAAO,EAAE,CAAC;QAChC,MAAM,CAAC,sBAAsB,CAC3B,gCAAgC,EAChC,KAAK,EAAE,IAAI,EAAE,EAAE;YACb,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC,CACF,CAAC;QACF,MAAM,CAAC,sBAAsB,CAC3B,gCAAgC,EAChC,KAAK,EA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AAC;YACnC,CAAC,CACF,CAAC;YAEF,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAC9D,OAAO,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAChE,OAAO,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,kBAAkB,EAAE,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC7D,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC9D,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC7D,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import type { SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
3
|
+
import type { StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
4
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
+
import { type X402ClientConfig } from "../../client/with-x402-client.js";
|
|
6
|
+
export declare enum ServerType {
|
|
7
|
+
HTTPStream = "HTTPStream"
|
|
8
|
+
}
|
|
9
|
+
export interface ServerConnection {
|
|
10
|
+
url: string;
|
|
11
|
+
serverType: ServerType;
|
|
12
|
+
transportOptions?: SSEClientTransportOptions | StreamableHTTPClientTransportOptions;
|
|
13
|
+
client?: Client;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Enhanced proxy server that connects to multiple MCP servers and exposes them via a stdio interface
|
|
17
|
+
*/
|
|
18
|
+
export declare const startStdioServer: ({ initStdioServer, initStreamClient, serverConnections, x402ClientConfig, }: {
|
|
19
|
+
initStdioServer?: () => Promise<Server>;
|
|
20
|
+
initStreamClient?: () => Promise<Client>;
|
|
21
|
+
serverConnections: ServerConnection[];
|
|
22
|
+
x402ClientConfig?: X402ClientConfig;
|
|
23
|
+
}) => Promise<Server[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Creates server connection configurations from a list of URLs
|
|
26
|
+
*/
|
|
27
|
+
export declare const createServerConnections: (urls: string[], serverType?: ServerType, transportOptions?: StreamableHTTPClientTransportOptions) => ServerConnection[];
|
|
28
|
+
//# sourceMappingURL=start-stdio-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-stdio-server.d.ts","sourceRoot":"","sources":["../../../src/server/stdio/start-stdio-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEzF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,oDAAoD,CAAC;AAE/G,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGzF,oBAAY,UAAU;IAClB,UAAU,eAAe;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,UAAU,CAAC;IACvB,gBAAgB,CAAC,EAAE,yBAAyB,GAAG,oCAAoC,CAAC;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAU,6EAKpC;IACC,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACvC,KAAG,OAAO,CAAC,MAAM,EAAE,CAwFnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAChC,MAAM,MAAM,EAAE,EACd,aAAY,UAAkC,EAC9C,mBAAkB,oCAAyC,KAC5D,gBAAgB,EAMlB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
3
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import packageJson from '../../../package.json' with { type: 'json' };
|
|
6
|
+
import { withX402Client } from "../../client/with-x402-client.js";
|
|
7
|
+
import { proxyServer } from "./proxy-server.js";
|
|
8
|
+
export var ServerType;
|
|
9
|
+
(function (ServerType) {
|
|
10
|
+
ServerType["HTTPStream"] = "HTTPStream";
|
|
11
|
+
})(ServerType || (ServerType = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Enhanced proxy server that connects to multiple MCP servers and exposes them via a stdio interface
|
|
14
|
+
*/
|
|
15
|
+
export const startStdioServer = async ({ initStdioServer, initStreamClient, serverConnections, x402ClientConfig, }) => {
|
|
16
|
+
if (serverConnections.length === 0) {
|
|
17
|
+
throw new Error("No server connections provided");
|
|
18
|
+
}
|
|
19
|
+
// Connect to all servers
|
|
20
|
+
const connectedClients = [];
|
|
21
|
+
for (const connection of serverConnections) {
|
|
22
|
+
let transport;
|
|
23
|
+
transport = new StreamableHTTPClientTransport(new URL(connection.url), connection.transportOptions);
|
|
24
|
+
let streamClient;
|
|
25
|
+
if (connection.client) {
|
|
26
|
+
streamClient = connection.client;
|
|
27
|
+
}
|
|
28
|
+
else if (initStreamClient) {
|
|
29
|
+
streamClient = await initStreamClient();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
streamClient = new Client({
|
|
33
|
+
name: "clawpay-cli",
|
|
34
|
+
version: packageJson.version,
|
|
35
|
+
}, {
|
|
36
|
+
capabilities: {},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
await streamClient.connect(transport);
|
|
40
|
+
// Optionally wrap the client with X402 payment capabilities
|
|
41
|
+
const wrappedClient = x402ClientConfig
|
|
42
|
+
? withX402Client(streamClient, x402ClientConfig)
|
|
43
|
+
: streamClient;
|
|
44
|
+
connectedClients.push(wrappedClient);
|
|
45
|
+
}
|
|
46
|
+
// We know there's at least one client because we check at the start
|
|
47
|
+
// TypeScript doesn't understand our check above, so we'll assert that connectedClients[0] exists
|
|
48
|
+
const servers = [];
|
|
49
|
+
for (const client of connectedClients) {
|
|
50
|
+
const serverVersion = client.getServerVersion();
|
|
51
|
+
const serverCapabilities = client.getServerCapabilities();
|
|
52
|
+
// Create the stdio server
|
|
53
|
+
const stdioServer = initStdioServer
|
|
54
|
+
? await initStdioServer()
|
|
55
|
+
: new Server(serverVersion, {
|
|
56
|
+
capabilities: serverCapabilities,
|
|
57
|
+
});
|
|
58
|
+
const stdioTransport = new StdioServerTransport();
|
|
59
|
+
await stdioServer.connect(stdioTransport);
|
|
60
|
+
// Set up proxies for all connected clients
|
|
61
|
+
// Start with primary client
|
|
62
|
+
await proxyServer({
|
|
63
|
+
client,
|
|
64
|
+
server: stdioServer,
|
|
65
|
+
serverCapabilities,
|
|
66
|
+
});
|
|
67
|
+
// Set up any additional clients if needed
|
|
68
|
+
// This is where you could add logic to distribute requests across servers
|
|
69
|
+
// or handle specific capabilities from different servers
|
|
70
|
+
servers.push(stdioServer);
|
|
71
|
+
}
|
|
72
|
+
return servers;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Creates server connection configurations from a list of URLs
|
|
76
|
+
*/
|
|
77
|
+
export const createServerConnections = (urls, serverType = ServerType.HTTPStream, transportOptions = {}) => {
|
|
78
|
+
return urls.map(url => ({
|
|
79
|
+
url,
|
|
80
|
+
serverType,
|
|
81
|
+
transportOptions,
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=start-stdio-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-stdio-server.js","sourceRoot":"","sources":["../../../src/server/stdio/start-stdio-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAInE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,WAAW,MAAM,uBAAuB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtE,OAAO,EAAE,cAAc,EAAyB,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAN,IAAY,UAEX;AAFD,WAAY,UAAU;IAClB,uCAAyB,CAAA;AAC7B,CAAC,EAFW,UAAU,KAAV,UAAU,QAErB;AASD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACnC,eAAe,EACf,gB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C,CAAC;QAEF,MAAM,kBAAkB,GAAG,MAAM,CAAC,qBAAqB,EAEtD,CAAC;QAEF,0BAA0B;QAC1B,MAAM,WAAW,GAAG,eAAe;YAC/B,CAAC,CAAC,MAAM,eAAe,EAAE;YACzB,CAAC,CAAC,IAAI,MAAM,CAAC,aAAa,EAAE;gBACxB,YAAY,EAAE,kBAAkB;aACnC,CAAC,CAAC;QAEP,MAAM,cAAc,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAClD,MAAM,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAE1C,2CAA2C;QAC3C,4BAA4B;QAC5B,MAAM,WAAW,CAAC;YACd,MAAM;YACN,MAAM,EAAE,WAAW;YACnB,kBAAkB;SACrB,CAAC,CAAC;QAEH,0CAA0C;QAC1C,0EAA0E;QAC1E,yDAAyD;QAEzD,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACnC,IAAc,EACd,aAAyB,UAAU,CAAC,UAAU,EAC9C,mBAAyD,EAAE,EACzC,EAAE;IACpB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpB,GAAG;QACH,UAAU;QACV,gBAAgB;KACnB,CAAC,CAAC,CAAC;AACR,CAAC,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { startStdioServer, createServerConnections, ServerType, type ServerConnection } from './server/stdio/start-stdio-server.js';
|
|
2
|
+
export { proxyServer } from './server/stdio/proxy-server.js';
|
|
3
|
+
export type { Account } from 'viem';
|
|
4
|
+
export type { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
5
|
+
export type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EACH,gBAAgB,EAChB,uBAAuB,EACvB,UAAU,EACV,KAAK,gBAAgB,EACxB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,YAAY,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,YAAY,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,YAAY,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EACH,gBAAgB,EAChB,uBAAuB,EACvB,UAAU,EAEb,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Account, Chain, Client, PublicActions, RpcSchema, Transport, WalletActions } from "viem";
|
|
2
|
+
export type SignerWallet<chain extends Chain = Chain, transport extends Transport = Transport, account extends Account = Account> = Client<transport, chain, account, RpcSchema, PublicActions<transport, chain, account> & WalletActions<chain, account>>;
|
|
3
|
+
export declare function createSignerFromViemAccount(network: string, account: Account): SignerWallet<Chain>;
|
|
4
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/utils/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAKlG,MAAM,MAAM,YAAY,CACtB,KAAK,SAAS,KAAK,GAAG,KAAK,EAC3B,SAAS,SAAS,SAAS,GAAG,SAAS,EACvC,OAAO,SAAS,OAAO,GAAG,OAAO,IAC/B,MAAM,CACR,SAAS,EACT,KAAK,EACL,OAAO,EACP,SAAS,EACT,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CACzE,CAAC;AAoDF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAOhG"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { base, baseSepolia, avalancheFuji, sei, seiTestnet, polygon, polygonAmoy } from "viem/chains";
|
|
2
|
+
import { createWalletClient, http, defineChain } from "viem";
|
|
3
|
+
import { publicActions } from "viem";
|
|
4
|
+
// Hedera chain definitions (primary)
|
|
5
|
+
const hederaTestnet = defineChain({
|
|
6
|
+
id: 296,
|
|
7
|
+
name: 'Hedera Testnet',
|
|
8
|
+
nativeCurrency: { name: 'HBAR', symbol: 'HBAR', decimals: 18 },
|
|
9
|
+
rpcUrls: { default: { http: ['https://testnet.hashio.io/api'] } },
|
|
10
|
+
blockExplorers: { default: { name: 'HashScan', url: 'https://hashscan.io/testnet' } },
|
|
11
|
+
testnet: true,
|
|
12
|
+
});
|
|
13
|
+
const hederaMainnet = defineChain({
|
|
14
|
+
id: 295,
|
|
15
|
+
name: 'Hedera Mainnet',
|
|
16
|
+
nativeCurrency: { name: 'HBAR', symbol: 'HBAR', decimals: 18 },
|
|
17
|
+
rpcUrls: { default: { http: ['https://mainnet.hashio.io/api'] } },
|
|
18
|
+
blockExplorers: { default: { name: 'HashScan', url: 'https://hashscan.io/mainnet' } },
|
|
19
|
+
testnet: false,
|
|
20
|
+
});
|
|
21
|
+
function getChainFromNetwork(network) {
|
|
22
|
+
if (!network) {
|
|
23
|
+
throw new Error("Network is required");
|
|
24
|
+
}
|
|
25
|
+
switch (network) {
|
|
26
|
+
// Hedera (primary)
|
|
27
|
+
case "hedera-testnet":
|
|
28
|
+
return hederaTestnet;
|
|
29
|
+
case "hedera":
|
|
30
|
+
return hederaMainnet;
|
|
31
|
+
// Legacy EVM chains (kept for backward compatibility with proxy strategies)
|
|
32
|
+
case "base":
|
|
33
|
+
return base;
|
|
34
|
+
case "base-sepolia":
|
|
35
|
+
return baseSepolia;
|
|
36
|
+
case "avalanche-fuji":
|
|
37
|
+
return avalancheFuji;
|
|
38
|
+
case "sei":
|
|
39
|
+
return sei;
|
|
40
|
+
case "sei-testnet":
|
|
41
|
+
return seiTestnet;
|
|
42
|
+
case "polygon":
|
|
43
|
+
return polygon;
|
|
44
|
+
case "polygon-amoy":
|
|
45
|
+
return polygonAmoy;
|
|
46
|
+
default:
|
|
47
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function createSignerFromViemAccount(network, account) {
|
|
51
|
+
const chain = getChainFromNetwork(network);
|
|
52
|
+
return createWalletClient({
|
|
53
|
+
chain,
|
|
54
|
+
transport: http(),
|
|
55
|
+
account: account,
|
|
56
|
+
}).extend(publicActions);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/utils/signer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAcrC,qCAAqC;AACrC,MAAM,aAAa,GAAG,WAAW,CAAC;IAChC,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,gBAAgB;IACtB,cAAc,EAAE,EAAE,IAAI,EA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ACjB,KAAK,cAAc;YACjB,OAAO,WAAW,CAAC;QACrB;YACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAEH,MAAM,UAAU,2BAA2B,CAAC,OAAe,EAAE,OAAgB;IACzE,MAAM,KAAK,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,kBAAkB,CAAC;QACxB,KAAK;QACL,SAAS,EAAE,IAAI,EAAE;QACjB,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AAC3B,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clawpay-hedera/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SDK and CLI for ClawPay - autonomous MCP micropayments for AI agents on Hedera",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"clawpay": "dist/cli/index.js",
|
|
10
|
+
"clawpay-hedera": "dist/cli/index.js"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"client": "./dist/client.js",
|
|
15
|
+
"node": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./client": {
|
|
20
|
+
"types": "./dist/client.d.ts",
|
|
21
|
+
"default": "./dist/client.js"
|
|
22
|
+
},
|
|
23
|
+
"./utils": {
|
|
24
|
+
"types": "./dist/utils.d.ts",
|
|
25
|
+
"default": "./dist/utils.js"
|
|
26
|
+
},
|
|
27
|
+
"./server": {
|
|
28
|
+
"types": "./dist/server.d.ts",
|
|
29
|
+
"default": "./dist/server.js"
|
|
30
|
+
},
|
|
31
|
+
"./handler": {
|
|
32
|
+
"types": "./dist/handler.d.ts",
|
|
33
|
+
"default": "./dist/handler.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc",
|
|
38
|
+
"dev": "tsc --watch",
|
|
39
|
+
"clean": "rm -rf dist",
|
|
40
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
41
|
+
"release:beta": "pnpm -C ../.. release:beta",
|
|
42
|
+
"release:stable": "pnpm -C ../.. release:stable"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"clawpay",
|
|
46
|
+
"hedera",
|
|
47
|
+
"sdk",
|
|
48
|
+
"cli",
|
|
49
|
+
"mcp",
|
|
50
|
+
"payment",
|
|
51
|
+
"x402",
|
|
52
|
+
"hts",
|
|
53
|
+
"hcs",
|
|
54
|
+
"hbar",
|
|
55
|
+
"typescript"
|
|
56
|
+
],
|
|
57
|
+
"author": "",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public",
|
|
61
|
+
"tag": "latest"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^20.0.0",
|
|
65
|
+
"typescript": "^5.0.0"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=20.10.0",
|
|
69
|
+
"pnpm": ">=9.0.0"
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"dist",
|
|
73
|
+
"README.md"
|
|
74
|
+
],
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"@modelcontextprotocol/sdk": "1.18.2",
|
|
77
|
+
"commander": "^12.1.0",
|
|
78
|
+
"dotenv": "^16.5.0",
|
|
79
|
+
"@hashgraph/sdk": "^2.58.0",
|
|
80
|
+
"viem": "2.37.13",
|
|
81
|
+
"x402": "^0.6.5",
|
|
82
|
+
"x402-fetch": "^0.6.0",
|
|
83
|
+
"zod": "^3.25.76",
|
|
84
|
+
"mcp-handler": "1.0.2"
|
|
85
|
+
}
|
|
86
|
+
}
|