@xlmtools/cli 0.1.2 → 0.2.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.
Files changed (66) hide show
  1. package/README.md +18 -12
  2. package/dist/cli.d.ts +2 -0
  3. package/{src/lib/api-fetch.ts → dist/lib/api-fetch.d.ts} +3 -14
  4. package/dist/lib/budget.d.ts +14 -0
  5. package/dist/lib/cache.d.ts +7 -0
  6. package/dist/lib/config.d.ts +2 -0
  7. package/dist/lib/format.d.ts +15 -0
  8. package/dist/lib/logger.d.ts +2 -0
  9. package/dist/lib/wallet.d.ts +9 -0
  10. package/dist/server.d.ts +22 -0
  11. package/dist/server.js +89 -0
  12. package/dist/tools/budget.d.ts +2 -0
  13. package/dist/tools/crypto.d.ts +2 -0
  14. package/dist/tools/dex-candles.d.ts +2 -0
  15. package/dist/tools/dex-orderbook.d.ts +2 -0
  16. package/dist/tools/dex-trades.d.ts +2 -0
  17. package/dist/tools/domain.d.ts +2 -0
  18. package/dist/tools/image.d.ts +2 -0
  19. package/dist/tools/oracle-price.d.ts +2 -0
  20. package/dist/tools/research.d.ts +2 -0
  21. package/dist/tools/scrape.d.ts +2 -0
  22. package/dist/tools/screenshot.d.ts +2 -0
  23. package/dist/tools/search.d.ts +2 -0
  24. package/dist/tools/stellar-account.d.ts +2 -0
  25. package/dist/tools/stellar-asset.d.ts +2 -0
  26. package/dist/tools/stellar-pools.d.ts +2 -0
  27. package/dist/tools/stocks.d.ts +2 -0
  28. package/dist/tools/swap-quote.d.ts +2 -0
  29. package/dist/tools/tools-list.d.ts +2 -0
  30. package/dist/tools/wallet-tool.d.ts +2 -0
  31. package/dist/tools/weather.d.ts +2 -0
  32. package/dist/tools/youtube.d.ts +2 -0
  33. package/package.json +27 -3
  34. package/dist/index.js +0 -77
  35. package/dist/tools/card.js +0 -51
  36. package/dist/tools/reddit.js +0 -40
  37. package/src/cli.ts +0 -245
  38. package/src/index.ts +0 -90
  39. package/src/lib/budget.ts +0 -78
  40. package/src/lib/cache.ts +0 -66
  41. package/src/lib/config.ts +0 -18
  42. package/src/lib/format.ts +0 -51
  43. package/src/lib/logger.ts +0 -6
  44. package/src/lib/wallet.ts +0 -143
  45. package/src/tools/budget.ts +0 -67
  46. package/src/tools/crypto.ts +0 -26
  47. package/src/tools/dex-candles.ts +0 -53
  48. package/src/tools/dex-orderbook.ts +0 -47
  49. package/src/tools/dex-trades.ts +0 -52
  50. package/src/tools/domain.ts +0 -25
  51. package/src/tools/image.ts +0 -50
  52. package/src/tools/oracle-price.ts +0 -43
  53. package/src/tools/research.ts +0 -49
  54. package/src/tools/scrape.ts +0 -43
  55. package/src/tools/screenshot.ts +0 -48
  56. package/src/tools/search.ts +0 -49
  57. package/src/tools/stellar-account.ts +0 -40
  58. package/src/tools/stellar-asset.ts +0 -41
  59. package/src/tools/stellar-pools.ts +0 -46
  60. package/src/tools/stocks.ts +0 -45
  61. package/src/tools/swap-quote.ts +0 -44
  62. package/src/tools/tools-list.ts +0 -22
  63. package/src/tools/wallet-tool.ts +0 -51
  64. package/src/tools/weather.ts +0 -25
  65. package/src/tools/youtube.ts +0 -51
  66. package/tsconfig.json +0 -13
package/README.md CHANGED
@@ -1,30 +1,36 @@
1
1
  # @xlmtools/cli
2
2
 
3
- XLMTools CLI — the MCP server that runs locally on the user's machine. Handles tool registration, payment signing, budget tracking, and response caching.
3
+ XLMTools CLI — the universal standalone CLI that runs on the user's machine. Provides the `xlm` binary for direct terminal use and exports the `createMcpServer()` factory that powers the `@xlmtools/mcp` stdio server. Handles tool registration, payment signing, budget tracking, and response caching.
4
4
 
5
5
  ## How it works
6
6
 
7
- This package is an MCP stdio server. It's started automatically by Claude, Cursor, or any MCP-compatible host when a user calls a XLMTools tool.
7
+ This package ships two things:
8
+
9
+ 1. A standalone `xlm` binary — the universal path. Any agent host with a Bash tool can invoke XLMTools by shelling out to `xlm <tool> <args>`.
10
+ 2. A `createMcpServer()` factory exported from `main`/`types` — consumed by the sibling `@xlmtools/mcp` package, which wraps it in a thin stdio adapter for MCP-capable hosts.
8
11
 
9
12
  ```
10
- MCP Host (Claude, Cursor, Windsurf)
11
- | stdio
12
- v
13
- @xlmtools/cli (this package)
14
- | - 21 tools registered via @modelcontextprotocol/sdk
15
- | - mppx polyfills fetch to auto-handle 402 payments
16
- | - budget enforcement (withBudget)
17
- | - response caching (withCache, 5-min TTL)
13
+ Agent host
18
14
  |
19
- | HTTPS
15
+ |-- Bash tool --> xlm (this package's bin)
16
+ |
17
+ |-- MCP stdio --> @xlmtools/mcp ──> imports createMcpServer() from @xlmtools/cli
20
18
  v
21
19
  @xlmtools/api (hosted API server)
20
+ - 21 tools registered via @modelcontextprotocol/sdk
21
+ - mppx polyfills fetch to auto-handle 402 payments
22
+ - budget enforcement (withBudget)
23
+ - response caching (withCache, 5-min TTL)
22
24
  ```
23
25
 
24
26
  ## Install (for users)
25
27
 
26
28
  ```bash
27
- claude mcp add xlmtools npx @xlmtools/cli
29
+ # Standalone CLI (universal works with any agent host that has Bash)
30
+ npm install -g @xlmtools/cli
31
+
32
+ # MCP server (optional fast-path — install the sibling package)
33
+ claude mcp add xlmtools npx @xlmtools/mcp
28
34
  ```
29
35
 
30
36
  On first run, the CLI:
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -12,19 +12,8 @@
12
12
  * const config = loadOrCreateWallet();
13
13
  * const res = await apiFetch(config, `/crypto?ids=${ids}`);
14
14
  */
15
-
16
15
  export interface ClientConfig {
17
- apiUrl: string;
18
- stellarPublicKey: string;
19
- }
20
-
21
- export async function apiFetch(
22
- config: ClientConfig,
23
- path: string,
24
- init?: RequestInit,
25
- ): Promise<Response> {
26
- const url = path.startsWith("http") ? path : `${config.apiUrl}${path}`;
27
- const headers = new Headers(init?.headers);
28
- headers.set("X-XLMTools-Client", config.stellarPublicKey);
29
- return fetch(url, { ...init, headers });
16
+ apiUrl: string;
17
+ stellarPublicKey: string;
30
18
  }
19
+ export declare function apiFetch(config: ClientConfig, path: string, init?: RequestInit): Promise<Response>;
@@ -0,0 +1,14 @@
1
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
+ export declare function setBudget(max: number): void;
3
+ export declare function clearBudget(): void;
4
+ export declare function getStatus(): {
5
+ max: number | null;
6
+ spent: number;
7
+ remaining: number | null;
8
+ };
9
+ /**
10
+ * Wrap a paid tool call with budget checking.
11
+ * If budget would be exceeded, returns an error without calling the API.
12
+ * On success, records the spend.
13
+ */
14
+ export declare function withBudget(toolName: string, fn: () => Promise<CallToolResult>): Promise<CallToolResult>;
@@ -0,0 +1,7 @@
1
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
+ /**
3
+ * Wrap a tool call with response caching.
4
+ * Identical tool+params within the TTL return the cached result
5
+ * with no API call and no payment.
6
+ */
7
+ export declare function withCache(toolName: string, params: Record<string, unknown>, fn: () => Promise<CallToolResult>): Promise<CallToolResult>;
@@ -0,0 +1,2 @@
1
+ export declare const TOOL_PRICES: Record<string, string>;
2
+ export declare const FREE_TOOLS: Set<string>;
@@ -0,0 +1,15 @@
1
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
+ export interface ReceiptInfo {
3
+ tx_hash: string;
4
+ amount: string;
5
+ currency: string;
6
+ network: string;
7
+ }
8
+ export declare function ok(data: unknown): CallToolResult;
9
+ /**
10
+ * Format a paid tool response, appending a receipt line if present.
11
+ * Strips the receipt from the data to avoid cluttering the JSON output,
12
+ * then appends a human-readable payment line.
13
+ */
14
+ export declare function okPaid(data: Record<string, unknown>): CallToolResult;
15
+ export declare function err(message: string): CallToolResult;
@@ -0,0 +1,2 @@
1
+ import pino from "pino";
2
+ export declare const logger: pino.Logger<never, boolean>;
@@ -0,0 +1,9 @@
1
+ import { Keypair } from "@stellar/stellar-sdk";
2
+ interface XLMToolsConfig {
3
+ stellarPrivateKey: string;
4
+ stellarPublicKey: string;
5
+ apiUrl: string;
6
+ }
7
+ export declare function loadOrCreateWallet(): XLMToolsConfig;
8
+ export declare function getKeypair(config: XLMToolsConfig): Keypair;
9
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * XLMTools MCP server factory.
3
+ *
4
+ * Builds and returns a fully-registered `McpServer` instance —
5
+ * without connecting any transport. Consumers are responsible for
6
+ * choosing the transport and calling `server.connect(transport)`.
7
+ *
8
+ * Currently used by `@xlmtools/mcp` (stdio transport wrapper).
9
+ * Could also be used to host over HTTP/SSE in the future by wiring
10
+ * a different transport.
11
+ */
12
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
13
+ /**
14
+ * Build a fully-configured XLMTools MCP server with all 21 tools
15
+ * registered. The caller must connect a transport.
16
+ *
17
+ * Side effects on first call:
18
+ * - Loads or creates the user's Stellar wallet at ~/.xlmtools/config.json
19
+ * - Initializes Mppx with a Stellar charge method (polyfills fetch
20
+ * to auto-handle 402 payment challenges)
21
+ */
22
+ export declare function createMcpServer(): McpServer;
package/dist/server.js ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * XLMTools MCP server factory.
3
+ *
4
+ * Builds and returns a fully-registered `McpServer` instance —
5
+ * without connecting any transport. Consumers are responsible for
6
+ * choosing the transport and calling `server.connect(transport)`.
7
+ *
8
+ * Currently used by `@xlmtools/mcp` (stdio transport wrapper).
9
+ * Could also be used to host over HTTP/SSE in the future by wiring
10
+ * a different transport.
11
+ */
12
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
13
+ import { Mppx } from "mppx/client";
14
+ import { stellar } from "@stellar/mpp/charge/client";
15
+ import { loadOrCreateWallet, getKeypair } from "./lib/wallet.js";
16
+ import { logger } from "./lib/logger.js";
17
+ import { registerCryptoTool } from "./tools/crypto.js";
18
+ import { registerWeatherTool } from "./tools/weather.js";
19
+ import { registerDomainTool } from "./tools/domain.js";
20
+ import { registerToolsListTool } from "./tools/tools-list.js";
21
+ import { registerWalletTool } from "./tools/wallet-tool.js";
22
+ import { registerSearchTool } from "./tools/search.js";
23
+ import { registerResearchTool } from "./tools/research.js";
24
+ import { registerYoutubeTool } from "./tools/youtube.js";
25
+ import { registerScreenshotTool } from "./tools/screenshot.js";
26
+ import { registerScrapeTool } from "./tools/scrape.js";
27
+ import { registerImageTool } from "./tools/image.js";
28
+ import { registerStocksTool } from "./tools/stocks.js";
29
+ import { registerDexOrderbookTool } from "./tools/dex-orderbook.js";
30
+ import { registerDexCandlesTool } from "./tools/dex-candles.js";
31
+ import { registerDexTradesTool } from "./tools/dex-trades.js";
32
+ import { registerSwapQuoteTool } from "./tools/swap-quote.js";
33
+ import { registerStellarAssetTool } from "./tools/stellar-asset.js";
34
+ import { registerStellarAccountTool } from "./tools/stellar-account.js";
35
+ import { registerStellarPoolsTool } from "./tools/stellar-pools.js";
36
+ import { registerOraclePriceTool } from "./tools/oracle-price.js";
37
+ import { registerBudgetTool } from "./tools/budget.js";
38
+ /**
39
+ * Build a fully-configured XLMTools MCP server with all 21 tools
40
+ * registered. The caller must connect a transport.
41
+ *
42
+ * Side effects on first call:
43
+ * - Loads or creates the user's Stellar wallet at ~/.xlmtools/config.json
44
+ * - Initializes Mppx with a Stellar charge method (polyfills fetch
45
+ * to auto-handle 402 payment challenges)
46
+ */
47
+ export function createMcpServer() {
48
+ const config = loadOrCreateWallet();
49
+ const keypair = getKeypair(config);
50
+ // Mppx polyfills global fetch to auto-handle 402 payments
51
+ Mppx.create({
52
+ methods: [
53
+ stellar.charge({
54
+ keypair,
55
+ mode: "pull",
56
+ onProgress(event) {
57
+ logger.debug({ eventType: event.type }, "MPP payment event");
58
+ },
59
+ }),
60
+ ],
61
+ });
62
+ // { logging: {} } enables ctx.mcpReq.log() in tool handlers
63
+ const server = new McpServer({ name: "xlmtools", version: "0.2.0" }, { capabilities: { tools: {}, logging: {} } });
64
+ // Free tools
65
+ registerCryptoTool(server);
66
+ registerWeatherTool(server);
67
+ registerDomainTool(server);
68
+ registerToolsListTool(server);
69
+ registerWalletTool(server);
70
+ registerBudgetTool(server);
71
+ // Paid tools
72
+ registerSearchTool(server);
73
+ registerResearchTool(server);
74
+ registerYoutubeTool(server);
75
+ registerScreenshotTool(server);
76
+ registerScrapeTool(server);
77
+ registerImageTool(server);
78
+ registerStocksTool(server);
79
+ // Stellar-native tools (free)
80
+ registerDexOrderbookTool(server);
81
+ registerDexCandlesTool(server);
82
+ registerDexTradesTool(server);
83
+ registerSwapQuoteTool(server);
84
+ registerStellarAssetTool(server);
85
+ registerStellarAccountTool(server);
86
+ registerStellarPoolsTool(server);
87
+ registerOraclePriceTool(server);
88
+ return server;
89
+ }
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerBudgetTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerCryptoTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerDexCandlesTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerDexOrderbookTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerDexTradesTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerDomainTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerImageTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerOraclePriceTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerResearchTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerScrapeTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerScreenshotTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerSearchTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerStellarAccountTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerStellarAssetTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerStellarPoolsTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerStocksTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerSwapQuoteTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerToolsListTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerWalletTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerWeatherTool(server: McpServer): void;
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerYoutubeTool(server: McpServer): void;
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "@xlmtools/cli",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
+ "description": "XLMTools standalone CLI — the `xlm` command plus the `createMcpServer` factory used by the @xlmtools/mcp wrapper package.",
4
5
  "type": "module",
5
6
  "bin": {
6
- "xlmtools": "dist/index.js",
7
7
  "xlm": "dist/cli.js"
8
8
  },
9
+ "main": "./dist/server.js",
10
+ "types": "./dist/server.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "README.md"
14
+ ],
9
15
  "scripts": {
10
- "dev": "tsx watch src/index.ts",
16
+ "dev": "tsx watch src/cli.ts",
11
17
  "build": "tsc",
12
18
  "test": "vitest run"
13
19
  },
@@ -24,5 +30,23 @@
24
30
  "tsx": "^4.21.0",
25
31
  "typescript": "^6.0.2",
26
32
  "vitest": "^4.1.2"
33
+ },
34
+ "keywords": [
35
+ "stellar",
36
+ "xlm",
37
+ "cli",
38
+ "soroban",
39
+ "mpp",
40
+ "x402",
41
+ "agent-tools"
42
+ ],
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/Blockchain-Oracle/xlmtools.git",
46
+ "directory": "packages/cli"
47
+ },
48
+ "license": "MIT",
49
+ "engines": {
50
+ "node": ">=22"
27
51
  }
28
52
  }
package/dist/index.js DELETED
@@ -1,77 +0,0 @@
1
- #!/usr/bin/env node
2
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
- import { Mppx } from "mppx/client";
5
- import { stellar } from "@stellar/mpp/charge/client";
6
- import { loadOrCreateWallet, getKeypair } from "./lib/wallet.js";
7
- import { logger } from "./lib/logger.js";
8
- import { registerCryptoTool } from "./tools/crypto.js";
9
- import { registerWeatherTool } from "./tools/weather.js";
10
- import { registerDomainTool } from "./tools/domain.js";
11
- import { registerToolsListTool } from "./tools/tools-list.js";
12
- import { registerWalletTool } from "./tools/wallet-tool.js";
13
- import { registerSearchTool } from "./tools/search.js";
14
- import { registerResearchTool } from "./tools/research.js";
15
- import { registerYoutubeTool } from "./tools/youtube.js";
16
- import { registerScreenshotTool } from "./tools/screenshot.js";
17
- import { registerScrapeTool } from "./tools/scrape.js";
18
- import { registerImageTool } from "./tools/image.js";
19
- import { registerStocksTool } from "./tools/stocks.js";
20
- import { registerDexOrderbookTool } from "./tools/dex-orderbook.js";
21
- import { registerDexCandlesTool } from "./tools/dex-candles.js";
22
- import { registerDexTradesTool } from "./tools/dex-trades.js";
23
- import { registerSwapQuoteTool } from "./tools/swap-quote.js";
24
- import { registerStellarAssetTool } from "./tools/stellar-asset.js";
25
- import { registerStellarAccountTool } from "./tools/stellar-account.js";
26
- import { registerStellarPoolsTool } from "./tools/stellar-pools.js";
27
- import { registerOraclePriceTool } from "./tools/oracle-price.js";
28
- import { registerBudgetTool } from "./tools/budget.js";
29
- const config = loadOrCreateWallet();
30
- const keypair = getKeypair(config);
31
- // Mppx polyfills global fetch to auto-handle 402 payments
32
- Mppx.create({
33
- methods: [
34
- stellar.charge({
35
- keypair,
36
- mode: "pull",
37
- onProgress(event) {
38
- logger.debug({ eventType: event.type }, "MPP payment event");
39
- },
40
- }),
41
- ],
42
- });
43
- // { logging: {} } enables ctx.mcpReq.log() in tool handlers
44
- const server = new McpServer({ name: "xlmtools", version: "0.1.0" }, { capabilities: { tools: {}, logging: {} } });
45
- // Free tools
46
- registerCryptoTool(server);
47
- registerWeatherTool(server);
48
- registerDomainTool(server);
49
- registerToolsListTool(server);
50
- registerWalletTool(server);
51
- registerBudgetTool(server);
52
- // Paid tools
53
- registerSearchTool(server);
54
- registerResearchTool(server);
55
- registerYoutubeTool(server);
56
- registerScreenshotTool(server);
57
- registerScrapeTool(server);
58
- registerImageTool(server);
59
- registerStocksTool(server);
60
- // Stellar-native tools (free)
61
- registerDexOrderbookTool(server);
62
- registerDexCandlesTool(server);
63
- registerDexTradesTool(server);
64
- registerSwapQuoteTool(server);
65
- registerStellarAssetTool(server);
66
- registerStellarAccountTool(server);
67
- registerStellarPoolsTool(server);
68
- registerOraclePriceTool(server);
69
- async function main() {
70
- const transport = new StdioServerTransport();
71
- await server.connect(transport);
72
- logger.info("XLMTools MCP server running");
73
- }
74
- main().catch((error) => {
75
- logger.error({ err: error }, "Fatal error");
76
- process.exit(1);
77
- });
@@ -1,51 +0,0 @@
1
- import { z } from "zod";
2
- import { loadOrCreateWallet } from "../lib/wallet.js";
3
- import { ok, err } from "../lib/format.js";
4
- import { logger } from "../lib/logger.js";
5
- export function registerCardTool(server) {
6
- server.registerTool("card", {
7
- title: "Virtual Card",
8
- description: `Issue a virtual Mastercard for agent spending. Card is funded from your XLMTools USDC balance.
9
- Cost: $10 flat card creation fee + load amount + 3.5% processing.
10
- IMPORTANT: Card details are shown ONCE and not stored.
11
- MVP: ASGCard API integration pending — add @asgcard/sdk and ASGCARD_STELLAR_KEY to enable real cards.`,
12
- inputSchema: z.object({
13
- amount: z
14
- .number()
15
- .min(5)
16
- .max(1000)
17
- .default(20)
18
- .describe("Amount to load in USD ($5-$1000)"),
19
- name: z
20
- .string()
21
- .default("AI AGENT")
22
- .describe("Name on card"),
23
- email: z
24
- .string()
25
- .email()
26
- .default("agent@xlmtools.dev")
27
- .describe("Email for registration"),
28
- }),
29
- }, async ({ amount, name, email }) => {
30
- logger.debug({ amount, name, email }, "card tool invoked");
31
- try {
32
- const config = loadOrCreateWallet();
33
- const res = await fetch(`${config.apiUrl}/card`, {
34
- method: "POST",
35
- headers: { "Content-Type": "application/json" },
36
- body: JSON.stringify({ amount, nameOnCard: name, email }),
37
- });
38
- if (!res.ok) {
39
- const body = await res.text();
40
- return err(`Card API error ${res.status}: ${body}`);
41
- }
42
- const data = await res.json();
43
- const totalCharge = (10 + amount + amount * 0.035).toFixed(3);
44
- return ok({ ...data, total_charged_usdc: totalCharge });
45
- }
46
- catch (e) {
47
- logger.error({ err: e }, "card tool error");
48
- return err(String(e));
49
- }
50
- });
51
- }
@@ -1,40 +0,0 @@
1
- import { z } from "zod";
2
- import { loadOrCreateWallet } from "../lib/wallet.js";
3
- import { ok, err } from "../lib/format.js";
4
- import { logger } from "../lib/logger.js";
5
- import { TOOL_PRICES } from "../lib/config.js";
6
- export function registerRedditTool(server) {
7
- server.registerTool("reddit", {
8
- title: "Reddit Search",
9
- description: `Search Reddit posts and comments in real-time.\nCost: $${TOOL_PRICES.reddit} USDC per query (paid via Stellar MPP).`,
10
- inputSchema: z.object({
11
- query: z.string().describe("Search query"),
12
- subreddit: z
13
- .string()
14
- .optional()
15
- .describe("Limit search to a specific subreddit (without r/ prefix)"),
16
- sort: z
17
- .enum(["relevance", "hot", "new", "top"])
18
- .default("relevance")
19
- .describe("Sort order for results"),
20
- }),
21
- }, async ({ query, subreddit, sort }) => {
22
- logger.debug({ query, subreddit, sort }, "reddit tool invoked");
23
- try {
24
- const config = loadOrCreateWallet();
25
- const params = new URLSearchParams({ q: query, sort });
26
- if (subreddit)
27
- params.set("subreddit", subreddit);
28
- const res = await fetch(`${config.apiUrl}/reddit?${params.toString()}`);
29
- if (!res.ok) {
30
- const body = await res.text();
31
- return err(`Reddit API error ${res.status}: ${body}`);
32
- }
33
- return ok(await res.json());
34
- }
35
- catch (e) {
36
- logger.error({ err: e }, "reddit tool error");
37
- return err(`Reddit search failed: ${String(e)}`);
38
- }
39
- });
40
- }