@xlmtools/cli 0.1.2 → 0.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/README.md +120 -67
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +0 -0
- package/{src/lib/api-fetch.ts → dist/lib/api-fetch.d.ts} +3 -14
- package/dist/lib/budget.d.ts +14 -0
- package/dist/lib/cache.d.ts +7 -0
- package/dist/lib/config.d.ts +2 -0
- package/dist/lib/format.d.ts +15 -0
- package/dist/lib/logger.d.ts +2 -0
- package/dist/lib/wallet.d.ts +9 -0
- package/dist/server.d.ts +22 -0
- package/dist/server.js +89 -0
- package/dist/tools/budget.d.ts +2 -0
- package/dist/tools/crypto.d.ts +2 -0
- package/dist/tools/dex-candles.d.ts +2 -0
- package/dist/tools/dex-orderbook.d.ts +2 -0
- package/dist/tools/dex-trades.d.ts +2 -0
- package/dist/tools/domain.d.ts +2 -0
- package/dist/tools/image.d.ts +2 -0
- package/dist/tools/oracle-price.d.ts +2 -0
- package/dist/tools/research.d.ts +2 -0
- package/dist/tools/scrape.d.ts +2 -0
- package/dist/tools/screenshot.d.ts +2 -0
- package/dist/tools/search.d.ts +2 -0
- package/dist/tools/stellar-account.d.ts +2 -0
- package/dist/tools/stellar-asset.d.ts +2 -0
- package/dist/tools/stellar-pools.d.ts +2 -0
- package/dist/tools/stocks.d.ts +2 -0
- package/dist/tools/swap-quote.d.ts +2 -0
- package/dist/tools/tools-list.d.ts +2 -0
- package/dist/tools/wallet-tool.d.ts +2 -0
- package/dist/tools/weather.d.ts +2 -0
- package/dist/tools/youtube.d.ts +2 -0
- package/package.json +32 -8
- package/dist/index.js +0 -77
- package/dist/tools/card.js +0 -51
- package/dist/tools/reddit.js +0 -40
- package/src/cli.ts +0 -245
- package/src/index.ts +0 -90
- package/src/lib/budget.ts +0 -78
- package/src/lib/cache.ts +0 -66
- package/src/lib/config.ts +0 -18
- package/src/lib/format.ts +0 -51
- package/src/lib/logger.ts +0 -6
- package/src/lib/wallet.ts +0 -143
- package/src/tools/budget.ts +0 -67
- package/src/tools/crypto.ts +0 -26
- package/src/tools/dex-candles.ts +0 -53
- package/src/tools/dex-orderbook.ts +0 -47
- package/src/tools/dex-trades.ts +0 -52
- package/src/tools/domain.ts +0 -25
- package/src/tools/image.ts +0 -50
- package/src/tools/oracle-price.ts +0 -43
- package/src/tools/research.ts +0 -49
- package/src/tools/scrape.ts +0 -43
- package/src/tools/screenshot.ts +0 -48
- package/src/tools/search.ts +0 -49
- package/src/tools/stellar-account.ts +0 -40
- package/src/tools/stellar-asset.ts +0 -41
- package/src/tools/stellar-pools.ts +0 -46
- package/src/tools/stocks.ts +0 -45
- package/src/tools/swap-quote.ts +0 -44
- package/src/tools/tools-list.ts +0 -22
- package/src/tools/wallet-tool.ts +0 -51
- package/src/tools/weather.ts +0 -25
- package/src/tools/youtube.ts +0 -51
- package/tsconfig.json +0 -13
package/README.md
CHANGED
|
@@ -1,99 +1,152 @@
|
|
|
1
1
|
# @xlmtools/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Standalone CLI for XLMTools — 21 pay-per-call tools for AI agents on Stellar. Install it, type `xlm`, and go.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @xlmtools/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
On first run, XLMTools auto-generates a Stellar testnet wallet, funds it with XLM via friendbot, and adds a USDC trustline. The only manual step is grabbing testnet USDC from [faucet.circle.com](https://faucet.circle.com) to use paid tools.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
8
14
|
|
|
15
|
+
```bash
|
|
16
|
+
xlm <tool> [args] [--flag value]
|
|
9
17
|
```
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
|
|
19
|
+
### Quick examples
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Free tools — no cost
|
|
23
|
+
xlm crypto bitcoin,ethereum,stellar
|
|
24
|
+
xlm weather Lagos
|
|
25
|
+
xlm wallet
|
|
26
|
+
xlm oracle-price BTC
|
|
27
|
+
xlm dex-orderbook XLM/USDC --limit 5
|
|
28
|
+
xlm swap-quote XLM USDC 100
|
|
29
|
+
xlm stellar-asset USDC
|
|
30
|
+
xlm domain xlmtools.com
|
|
31
|
+
xlm tools
|
|
32
|
+
|
|
33
|
+
# Paid tools — USDC charged per call via Stellar MPP
|
|
34
|
+
xlm search "Stellar x402 micropayments" --count 5
|
|
35
|
+
xlm stocks AAPL
|
|
36
|
+
xlm research "Soroban smart contracts" --num-results 3
|
|
37
|
+
xlm youtube "Stellar blockchain"
|
|
38
|
+
xlm scrape https://stellar.org
|
|
39
|
+
xlm screenshot https://xlmtools.com --format png
|
|
40
|
+
xlm image "a stingray gliding over a coral reef at dusk" --size 1024x1024
|
|
22
41
|
```
|
|
23
42
|
|
|
24
|
-
|
|
43
|
+
Output is JSON. Pipe to `jq` for filtering:
|
|
25
44
|
|
|
26
45
|
```bash
|
|
27
|
-
|
|
46
|
+
xlm crypto bitcoin | jq '.bitcoin.usd'
|
|
28
47
|
```
|
|
29
48
|
|
|
30
|
-
|
|
31
|
-
1. Generates a Stellar keypair at `~/.xlmtools/config.json`
|
|
32
|
-
2. Funds the wallet with testnet XLM via friendbot (testnet only)
|
|
33
|
-
3. Adds a USDC trustline so the wallet can receive payments
|
|
49
|
+
### All commands
|
|
34
50
|
|
|
35
|
-
|
|
51
|
+
**Paid** ($0.001–$0.04 USDC per call, settled on Stellar testnet):
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
53
|
+
| Command | Price | What it does |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `xlm search <query> [--count N]` | $0.003 | Web + news search |
|
|
56
|
+
| `xlm research <query> [--num-results N]` | $0.010 | Multi-source deep research |
|
|
57
|
+
| `xlm youtube <query>` or `--id <id>` | $0.002 | Video search or lookup |
|
|
58
|
+
| `xlm screenshot <url> [--format png]` | $0.010 | Capture a URL screenshot |
|
|
59
|
+
| `xlm scrape <url>` | $0.002 | Extract clean text from a URL |
|
|
60
|
+
| `xlm image <prompt> [--size 1024x1024]` | $0.040 | AI image generation |
|
|
61
|
+
| `xlm stocks <symbol>` | $0.001 | Real-time stock quotes |
|
|
62
|
+
|
|
63
|
+
**Free** (no cost):
|
|
64
|
+
|
|
65
|
+
| Command | What it does |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `xlm crypto <ids> [--vs-currency usd]` | Crypto prices from CoinGecko |
|
|
68
|
+
| `xlm weather <location>` | Current weather for any city |
|
|
69
|
+
| `xlm domain <name>` | Domain availability check |
|
|
70
|
+
| `xlm dex-orderbook <pair> [--limit N]` | Stellar DEX orderbook |
|
|
71
|
+
| `xlm dex-candles <pair> [--resolution 1h] [--limit N]` | OHLCV candlesticks |
|
|
72
|
+
| `xlm dex-trades <pair> [--limit N]` | Recent DEX trades |
|
|
73
|
+
| `xlm swap-quote <from> <to> <amount>` | Best swap path between assets |
|
|
74
|
+
| `xlm stellar-asset <asset>` | Asset info, supply, trustlines |
|
|
75
|
+
| `xlm stellar-account <address>` | Account balances and signers |
|
|
76
|
+
| `xlm stellar-pools [--asset X] [--limit N]` | Liquidity pool data |
|
|
77
|
+
| `xlm oracle-price <asset> [--feed crypto]` | Reflector oracle prices |
|
|
78
|
+
| `xlm wallet` | Your Stellar wallet address + balance |
|
|
79
|
+
| `xlm tools` | List all 21 tools and prices |
|
|
80
|
+
| `xlm --help` | Full help text |
|
|
81
|
+
|
|
82
|
+
## Payment
|
|
83
|
+
|
|
84
|
+
Every paid tool call produces a real Stellar testnet transaction. The receipt shows at the bottom of the output:
|
|
40
85
|
|
|
41
|
-
# Or directly
|
|
42
|
-
cd packages/cli
|
|
43
|
-
pnpm dev
|
|
44
86
|
```
|
|
87
|
+
Payment: $0.003 USDC · tx/a3f9c28d71e0... · stellar testnet
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Verify any payment at [stellar.expert/explorer/testnet](https://stellar.expert/explorer/testnet).
|
|
45
91
|
|
|
46
|
-
|
|
92
|
+
## Wallet
|
|
47
93
|
|
|
48
|
-
|
|
94
|
+
Your wallet is at `~/.xlmtools/config.json`. The private key never leaves your machine. Check your balance:
|
|
49
95
|
|
|
50
96
|
```bash
|
|
51
|
-
|
|
97
|
+
xlm wallet
|
|
52
98
|
```
|
|
53
99
|
|
|
54
|
-
|
|
100
|
+
Fund with testnet USDC: visit [faucet.circle.com](https://faucet.circle.com), select Stellar, paste your wallet address.
|
|
55
101
|
|
|
56
|
-
##
|
|
102
|
+
## Also available as
|
|
57
103
|
|
|
58
|
-
|
|
104
|
+
- **MCP server**: `claude mcp add xlmtools npx @xlmtools/mcp` — for Claude Code, Cursor, Cline, VS Code Copilot, Windsurf, and 7+ other MCP hosts. Same wallet, same tools.
|
|
105
|
+
- **Agent Skill**: `pnpm dlx skills add github:Blockchain-Oracle/xlmtools --skill xlmtools` — teaches agents when and how to use each tool.
|
|
59
106
|
|
|
60
|
-
|
|
61
|
-
search, research, youtube, screenshot, scrape, image, stocks
|
|
107
|
+
## Links
|
|
62
108
|
|
|
63
|
-
|
|
64
|
-
|
|
109
|
+
- [xlmtools.com](https://xlmtools.com) — website
|
|
110
|
+
- [docs.xlmtools.com](https://docs.xlmtools.com) — full documentation
|
|
111
|
+
- [api.xlmtools.com](https://api.xlmtools.com) — hosted API
|
|
112
|
+
- [GitHub](https://github.com/Blockchain-Oracle/xlmtools) — source code
|
|
113
|
+
- [`@xlmtools/mcp`](https://www.npmjs.com/package/@xlmtools/mcp) — MCP server package
|
|
65
114
|
|
|
66
|
-
|
|
115
|
+
---
|
|
67
116
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
| `src/lib/format.ts` | `ok()`, `okPaid()`, `err()` response formatters |
|
|
75
|
-
| `src/lib/config.ts` | Tool prices and free tool list |
|
|
76
|
-
| `src/lib/logger.ts` | pino logger (stderr) |
|
|
77
|
-
| `src/tools/*.ts` | One file per tool |
|
|
78
|
-
|
|
79
|
-
### Payment flow
|
|
80
|
-
|
|
81
|
-
1. Tool handler calls `fetch(apiUrl/toolname)` with params
|
|
82
|
-
2. API returns `402 Payment Required`
|
|
83
|
-
3. mppx (global fetch polyfill) intercepts the 402
|
|
84
|
-
4. Builds a Soroban SAC USDC transfer using the local Stellar keypair
|
|
85
|
-
5. Signs and retries the request with payment proof
|
|
86
|
-
6. API verifies, executes the tool, returns result with receipt
|
|
87
|
-
7. `okPaid()` strips the receipt and appends a human-readable payment footer
|
|
88
|
-
|
|
89
|
-
### Budget flow
|
|
117
|
+
## For contributors
|
|
118
|
+
|
|
119
|
+
This package provides two things:
|
|
120
|
+
|
|
121
|
+
1. The `xlm` binary (standalone CLI) at `dist/cli.js`
|
|
122
|
+
2. A `createMcpServer()` factory at `dist/server.js` — imported by [`@xlmtools/mcp`](https://www.npmjs.com/package/@xlmtools/mcp) to power the MCP stdio server
|
|
90
123
|
|
|
124
|
+
### Development
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pnpm dev:cli # from monorepo root
|
|
128
|
+
# or
|
|
129
|
+
cd packages/cli && pnpm dev
|
|
91
130
|
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
131
|
+
|
|
132
|
+
### Build
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pnpm build
|
|
97
136
|
```
|
|
98
137
|
|
|
99
|
-
|
|
138
|
+
### Key files
|
|
139
|
+
|
|
140
|
+
| File | Purpose |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
| `src/cli.ts` | Standalone `xlm` binary — arg parsing, URL building, response printing |
|
|
143
|
+
| `src/server.ts` | `createMcpServer()` factory — registers all 21 tools on a fresh McpServer |
|
|
144
|
+
| `src/lib/wallet.ts` | Wallet creation, testnet auto-funding |
|
|
145
|
+
| `src/lib/api-fetch.ts` | Shared fetch with `X-XLMTools-Client` header for stats attribution |
|
|
146
|
+
| `src/lib/budget.ts` | Session budget cap (`withBudget()` wrapper) |
|
|
147
|
+
| `src/lib/cache.ts` | 5-min response cache (`withCache()` wrapper) |
|
|
148
|
+
| `src/tools/*.ts` | One file per tool — each calls `server.registerTool(...)` |
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -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
|
-
|
|
18
|
-
|
|
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,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,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 {};
|
package/dist/server.d.ts
ADDED
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xlmtools/cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
9
|
+
"main": "./dist/server.js",
|
|
10
|
+
"types": "./dist/server.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
16
17
|
"@stellar/mpp": "^0.4.0",
|
|
@@ -24,5 +25,28 @@
|
|
|
24
25
|
"tsx": "^4.21.0",
|
|
25
26
|
"typescript": "^6.0.2",
|
|
26
27
|
"vitest": "^4.1.2"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"stellar",
|
|
31
|
+
"xlm",
|
|
32
|
+
"cli",
|
|
33
|
+
"soroban",
|
|
34
|
+
"mpp",
|
|
35
|
+
"x402",
|
|
36
|
+
"agent-tools"
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/Blockchain-Oracle/xlmtools.git",
|
|
41
|
+
"directory": "packages/cli"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"dev": "tsx watch src/cli.ts",
|
|
49
|
+
"build": "tsc",
|
|
50
|
+
"test": "vitest run"
|
|
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
|
-
});
|