nirium-mcp 0.5.1 → 0.6.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.
Files changed (3) hide show
  1. package/LICENSE +86 -67
  2. package/package.json +5 -4
  3. package/dist/index.js +0 -295
package/LICENSE CHANGED
@@ -32,9 +32,10 @@
32
32
  not limited to compiled object code, generated documentation,
33
33
  and conversions to other media types.
34
34
 
35
- "Work" shall mean the work of authorship made available under
36
- the License, as indicated by a copyright notice that is included in
37
- or attached to the work (an example is provided in the Appendix below).
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
38
39
 
39
40
  "Derivative Works" shall mean any work, whether in Source or Object
40
41
  form, that is based on (or derived from) the Work and for which the
@@ -44,21 +45,23 @@
44
45
  separable from, or merely link (or bind by name) to the interfaces of,
45
46
  the Work and Derivative Works thereof.
46
47
 
47
- "Contribution" shall mean, as submitted to the Licensor for inclusion
48
- in the Work by the copyright owner or by an individual or Legal Entity
49
- authorized to submit on behalf of the copyright owner. For the purposes
50
- of this definition, "submitted" means any form of electronic, verbal,
51
- or written communication sent to the Licensor or its representatives,
52
- including but not limited to communication on electronic mailing lists,
53
- source code control systems, and issue tracking systems that are managed
54
- by, or on behalf of, the Licensor for the purpose of discussing and
55
- improving the Work, but excluding communication that is conspicuously
56
- marked or otherwise designated in writing by the copyright owner as
57
- "Not a Contribution."
58
-
59
- "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
- whom a Contribution has been received by the Licensor and subsequently
61
- incorporated within the Work.
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
62
65
 
63
66
  2. Grant of Copyright License. Subject to the terms and conditions of
64
67
  this License, each Contributor hereby grants to You a perpetual,
@@ -76,19 +79,20 @@
76
79
  by such Contributor that are necessarily infringed by their
77
80
  Contribution(s) alone or by combination of their Contribution(s)
78
81
  with the Work to which such Contribution(s) was submitted. If You
79
- institute patent litigation against any entity (including a cross-claim
80
- or counterclaim in a lawsuit) alleging that the Work or any Contribution
81
- incorporated within the Work constitutes direct or contributory patent
82
- infringement, then any patent licenses granted to You under this License
83
- for that Work shall terminate as of the date such litigation is filed.
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
84
88
 
85
89
  4. Redistribution. You may reproduce and distribute copies of the
86
90
  Work or Derivative Works thereof in any medium, with or without
87
91
  modifications, and in Source or Object form, provided that You
88
92
  meet the following conditions:
89
93
 
90
- (a) You must give any other recipients of the Work or Derivative Works
91
- a copy of this License; and
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
92
96
 
93
97
  (b) You must cause any modified files to carry prominent notices
94
98
  stating that You changed the files; and
@@ -100,59 +104,74 @@
100
104
  the Derivative Works; and
101
105
 
102
106
  (d) If the Work includes a "NOTICE" text file as part of its
103
- distribution, You must include a readable copy of the attribution
104
- notices contained within such NOTICE file, in at least one of the
105
- following places: within a NOTICE text file distributed as part of
106
- the Derivative Works; within the Source form or documentation, if
107
- provided along with the Derivative Works; or, within a display
108
- generated by the Derivative Works, if and wherever such third-party
109
- notices normally appear. The contents of the NOTICE file are for
110
- informational purposes only and do not modify the License.
111
-
112
- (e) You may add Your own attribution notices within Derivative Works
113
- that You distribute, alongside or as an addendum to the NOTICE text
114
- from the Work, provided that such additional attribution notices
115
- cannot be construed as modifying the License.
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
116
129
 
117
130
  5. Submission of Contributions. Unless You explicitly state otherwise,
118
131
  any Contribution intentionally submitted for inclusion in the Work
119
132
  by You to the Licensor shall be under the terms and conditions of
120
133
  this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
121
137
 
122
138
  6. Trademarks. This License does not grant permission to use the trade
123
139
  names, trademarks, service marks, or product names of the Licensor,
124
140
  except as required for reasonable and customary use in describing the
125
141
  origin of the Work and reproducing the content of the NOTICE file.
126
142
 
127
- 7. Disclaimer of Warranty. Unless required by applicable law or agreed
128
- to in writing, Licensor provides the Work (and each Contributor provides
129
- its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
130
- OF ANY KIND, either express or implied, including, without limitation,
131
- any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY,
132
- or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
133
- determining the appropriateness of using or redistributing the Work and
134
- assume any risks associated with Your exercise of permissions under this
135
- License.
136
-
137
- 8. Limitation of Liability. In no event and under no legal theory, whether
138
- in tort (including negligence), contract, or otherwise, unless required
139
- by applicable law (such as deliberate and grossly negligent acts) or
140
- agreed to in writing, shall any Contributor be liable to You for damages,
141
- including any direct, indirect, special, incidental, or consequential
142
- damages of any character arising as a result of this License or out of
143
- the use or inability to use the Work (including but not limited to
144
- damages for loss of goodwill, work stoppage, computer failure or
145
- malfunction, or all other commercial damages or losses), even if such
146
- Contributor has been advised of the possibility of such damages.
147
-
148
- 9. Accepting Warranty or Additional Liability. While redistributing the
149
- Work or Derivative Works thereof, You may choose to offer, and charge a
150
- fee for, acceptance of support, warranty, indemnity, or other liability
151
- obligations and rights consistent with this License. However, in
152
- accepting such obligations, You may offer only conditions consistent
153
- with this License. You must indemnify every Contributor for any
154
- liability incurred by, or claims asserted against, such Contributor by
155
- reason of your accepting any such warranty or additional liability.
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
156
175
 
157
176
  END OF TERMS AND CONDITIONS
158
177
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nirium-mcp",
3
- "version": "0.5.1",
4
- "description": "Model Context Protocol server for Nirium \u2014 exposes market data, autonomous loop control, and x402/MPP paid signals to any MCP-compatible AI (Claude, GPT, Cursor, VS Code Copilot).",
3
+ "version": "0.6.1",
4
+ "description": "Model Context Protocol server for Nirium — exposes market data, autonomous loop control, and x402/MPP paid signals to any MCP-compatible AI (Claude, GPT, Cursor, VS Code Copilot).",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "nirium-mcp": "dist/index.js"
@@ -9,10 +9,11 @@
9
9
  "homepage": "https://nirium.xyz",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "git+https://github.com/nirium-protocol/nirium-sdk.git"
12
+ "url": "git+https://github.com/nirium-protocol/nirium.git",
13
+ "directory": "packages/mcp"
13
14
  },
14
15
  "bugs": {
15
- "url": "https://github.com/nirium-protocol/nirium-sdk/issues",
16
+ "url": "https://github.com/nirium-protocol/nirium/issues",
16
17
  "email": "niriumprotocol@gmail.com"
17
18
  },
18
19
  "author": {
package/dist/index.js DELETED
@@ -1,295 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- // SPDX-License-Identifier: Apache-2.0
4
- // Copyright 2026 Nirium Protocol Contributors
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- // ═══════════════════════════════════════════════════════════════
7
- // Nirium MCP Server v0.5.0 — x402 + MPP + node tool suite
8
- // ═══════════════════════════════════════════════════════════════
9
- //
10
- // Exposes Nirium Protocol capabilities to any MCP-compatible AI:
11
- // Claude, GPT, Codex, Cursor, VS Code Copilot, etc.
12
- //
13
- // Three tiers of tools:
14
- // FREE — market data, loop status, node catalog, audit anchoring,
15
- // reporting summaries (standard HTTP to agent API)
16
- // PAID (x402) — premium signals via the OpenZeppelin Channels facilitator
17
- // PAID (MPP) — same signals via direct Soroban SAC transfer,
18
- // no external facilitator required
19
- //
20
- // Paid tools need STELLAR_SECRET_KEY, and on mainnet also SOROBAN_RPC_URL
21
- // (Stellar publishes no open mainnet RPC). Free tools need neither.
22
- //
23
- // Usage (stdio transport, from source):
24
- // STELLAR_SECRET_KEY=S... AGENT_API_URL=http://localhost:3001 npx tsx src/index.ts
25
- //
26
- // Claude Desktop config (published package):
27
- // {
28
- // "mcpServers": {
29
- // "nirium": {
30
- // "command": "npx",
31
- // "args": ["-y", "nirium-mcp"],
32
- // "env": {
33
- // "STELLAR_SECRET_KEY": "S...",
34
- // "AGENT_API_URL": "https://nirium-agent.fly.dev"
35
- // }
36
- // }
37
- // }
38
- // }
39
- //
40
- // ═══════════════════════════════════════════════════════════════
41
- const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
42
- const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
43
- const zod_1 = require("zod");
44
- const fetch_1 = require("@x402/fetch");
45
- const stellar_1 = require("@x402/stellar");
46
- const stellar_2 = require("@x402/stellar");
47
- const client_1 = require("mppx/client");
48
- const client_2 = require("@stellar/mpp/charge/client");
49
- // ─── Configuration ────────────────────────────────────────────
50
- const API_URL = process.env.AGENT_API_URL || 'http://127.0.0.1:3001';
51
- const STELLAR_KEY = process.env.STELLAR_SECRET_KEY || '';
52
- const NIRIUM_API_KEY = process.env.NIRIUM_API_KEY || '';
53
- const IS_MAINNET = process.env.STELLAR_NETWORK === 'mainnet';
54
- const STELLAR_NET = (IS_MAINNET
55
- ? 'stellar:pubnet'
56
- : stellar_2.STELLAR_TESTNET_CAIP2);
57
- // El default de RPC solo sirve para testnet: Stellar no publica un RPC de
58
- // mainnet abierto (el propio @x402/stellar lanza "mainnet requires a non-empty
59
- // rpcUrl"). Sin este guard, mainnet caía al RPC de testnet con el network id de
60
- // pubnet y el pago fallaba de forma confusa, con fondos reales. El RPC lo pone
61
- // quien corre el server — el endpoint dedicado de Nirium lleva token y vive
62
- // como secreto del backend, nunca dentro de un paquete publicado.
63
- const RPC_URL = process.env.SOROBAN_RPC_URL
64
- || (IS_MAINNET ? '' : stellar_2.DEFAULT_TESTNET_RPC_URL);
65
- // Sin RPC válido no se puede firmar un pago; las herramientas gratuitas siguen vivas.
66
- const PAYMENTS_ENABLED = !!STELLAR_KEY && !!RPC_URL;
67
- const PAYMENTS_DISABLED_REASON = PAYMENTS_ENABLED
68
- ? ''
69
- : !STELLAR_KEY
70
- ? 'STELLAR_SECRET_KEY is not set — paid tools need a funded Stellar wallet.'
71
- : 'STELLAR_NETWORK=mainnet requires SOROBAN_RPC_URL (Stellar publishes no open mainnet RPC). '
72
- + 'Pick a provider at https://developers.stellar.org/docs/data/apis/rpc/providers';
73
- // Derive public key from secret key if available, or use explicit env var
74
- const STELLAR_PUBLIC_KEY = (() => {
75
- if (process.env.STELLAR_PUBLIC_KEY)
76
- return process.env.STELLAR_PUBLIC_KEY;
77
- if (STELLAR_KEY) {
78
- try {
79
- return (0, stellar_2.createEd25519Signer)(STELLAR_KEY, STELLAR_NET).address;
80
- }
81
- catch {
82
- return '';
83
- }
84
- }
85
- return '';
86
- })();
87
- // Auth headers for authenticated endpoints
88
- const authHeaders = () => NIRIUM_API_KEY ? { 'x-api-key': NIRIUM_API_KEY } : {};
89
- // Auth + legal consent headers (required by loop/start and execute endpoints)
90
- const consentHeaders = () => ({
91
- ...authHeaders(),
92
- ...(STELLAR_PUBLIC_KEY ? { 'x-stellar-account': STELLAR_PUBLIC_KEY } : {}),
93
- });
94
- // ─── x402 Payment Client ──────────────────────────────────────
95
- //
96
- // Set up once; reused for all x402 premium tool calls.
97
- // Requires STELLAR_SECRET_KEY env var with funded testnet wallet.
98
- //
99
- let paidFetch = fetch;
100
- if (PAYMENTS_ENABLED) {
101
- const signer = (0, stellar_2.createEd25519Signer)(STELLAR_KEY, STELLAR_NET);
102
- const client = new fetch_1.x402Client()
103
- .register(STELLAR_NET, new stellar_1.ExactStellarScheme(signer, { url: RPC_URL }));
104
- paidFetch = (0, fetch_1.wrapFetchWithPayment)(fetch, client);
105
- console.error(`[Nirium MCP] x402 wallet: ${signer.address} | network: ${STELLAR_NET}`);
106
- }
107
- else {
108
- console.error(`[Nirium MCP] Paid tools disabled — ${PAYMENTS_DISABLED_REASON}`);
109
- }
110
- // ─── MPP Payment Client ───────────────────────────────────────
111
- //
112
- // MPP Charge mode: per-request Soroban SAC transfer.
113
- // No external facilitator — server verifies directly.
114
- // Same STELLAR_SECRET_KEY funds both x402 and MPP payments.
115
- //
116
- let mppFetch = fetch;
117
- if (PAYMENTS_ENABLED) {
118
- const mppx = client_1.Mppx.create({
119
- methods: [
120
- client_2.stellar.charge({
121
- secretKey: STELLAR_KEY,
122
- rpcUrl: RPC_URL,
123
- }),
124
- ],
125
- });
126
- mppFetch = mppx.fetch;
127
- console.error(`[Nirium MCP] MPP Charge enabled | network: ${STELLAR_NET}`);
128
- }
129
- else {
130
- console.error(`[Nirium MCP] MPP tools disabled — ${PAYMENTS_DISABLED_REASON}`);
131
- }
132
- // ─── Server ───────────────────────────────────────────────────
133
- const server = new mcp_js_1.McpServer({ name: 'nirium-mcp-server', version: '0.5.0' }, { capabilities: { tools: {} } });
134
- const text = (body) => ({ content: [{ type: 'text', text: typeof body === 'string' ? body : JSON.stringify(body, null, 2) }] });
135
- const fail = (message) => ({ content: [{ type: 'text', text: message }], isError: true });
136
- // Un pago sin wallet o sin RPC de mainnet no puede firmarse: decirlo aquí evita
137
- // que el modelo reciba un 402 opaco y lo reporte como "el servidor falló".
138
- const paymentsUnavailable = () => PAYMENTS_ENABLED ? null : fail(`Payment tools unavailable: ${PAYMENTS_DISABLED_REASON}`);
139
- // Los nodos gratuitos comparten forma: GET/POST → JSON, error legible.
140
- async function callJson(url, init, doFetch = fetch) {
141
- try {
142
- const res = await doFetch(url, init);
143
- if (!res.ok)
144
- return fail(`Error ${res.status}: ${await res.text()}`);
145
- return text(await res.json());
146
- }
147
- catch (err) {
148
- return fail(`Request failed: ${err instanceof Error ? err.message : String(err)}`);
149
- }
150
- }
151
- // ─── FREE TOOLS ───────────────────────────────────────────────
152
- server.tool('get_market_state', 'Fetch real-time market data: XLM/USDC price (CoinGecko), SDEX spread, base fee, Blend supply/borrow rate, CETES rate. Free — no API key required.', {}, async () => {
153
- const res = await fetch(`${API_URL}/api/tickers`);
154
- const data = await res.json();
155
- return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
156
- });
157
- server.tool('get_loop_status', 'Check the autonomous scanning loop: running/stopped, scan count, uptime, last AI decision. Free.', {}, async () => {
158
- const res = await fetch(`${API_URL}/api/loop/status`);
159
- const data = await res.json();
160
- return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
161
- });
162
- server.tool('start_loop', 'Start the autonomous market scanning loop. Requires NIRIUM_API_KEY env var.', {
163
- minProfitPercentage: zod_1.z.number().optional().describe('Minimum profit % to trigger (default: 0.3)'),
164
- maxBaseFee: zod_1.z.number().optional().describe('Max Stellar base fee in stroops (default: 500)'),
165
- }, async (args) => {
166
- const res = await fetch(`${API_URL}/api/loop/start`, {
167
- method: 'POST',
168
- headers: { 'Content-Type': 'application/json', ...consentHeaders() },
169
- body: JSON.stringify({ config: args }),
170
- });
171
- const data = await res.json();
172
- return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
173
- });
174
- server.tool('stop_loop', 'Stop the autonomous scanning loop. Requires NIRIUM_API_KEY env var.', {}, async () => {
175
- const res = await fetch(`${API_URL}/api/loop/stop`, {
176
- method: 'POST',
177
- headers: authHeaders(),
178
- });
179
- const data = await res.json();
180
- return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
181
- });
182
- server.tool('execute_demo', 'Dry-run a strategy via Soroban simulation — no real transaction. Free.', {
183
- strategy: zod_1.z.string().describe('Strategy name: flash-loan-arb, path-arbitrage, cross-dex, blend-yield, soroswap-swap'),
184
- asset: zod_1.z.string().describe('Trading pair, e.g. XLM-USDC'),
185
- }, async (args) => {
186
- const res = await fetch(`${API_URL}/api/execute-demo`, {
187
- method: 'POST',
188
- headers: { 'Content-Type': 'application/json' },
189
- body: JSON.stringify(args),
190
- });
191
- const data = await res.json();
192
- return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
193
- });
194
- // ─── PAID TOOLS (x402) ────────────────────────────────────────
195
- //
196
- // Each call automatically:
197
- // 1. Hits the endpoint → receives HTTP 402 + payment requirements
198
- // 2. Signs a Soroban auth entry for the USDC amount
199
- // 3. Submits X-PAYMENT header → receives 200 + data
200
- //
201
- // Cost: $0.02 USDC per signals call, $0.05 per market call, $0.25 per execution.
202
- // Requires STELLAR_SECRET_KEY env var with funded testnet wallet.
203
- //
204
- server.tool('get_premium_signals', 'PAID ($0.02 USDC via x402) — TESTNET ONLY: signals are produced by the autonomous loop, which runs on testnet; the mainnet box has no loop and returns 501 without charging. Signals reference testnet tokens, which have no monetary value, and are not a recommendation to buy, sell or hold anything. Requires funded Stellar wallet.', {
205
- count: zod_1.z.number().optional().describe('Number of signals to fetch (default: 20, max: 100)'),
206
- }, async (args) => paymentsUnavailable()
207
- ?? callJson(`${API_URL}/api/v1/premium/signals?count=${args.count || 20}`, undefined, paidFetch));
208
- server.tool('get_premium_market', 'PAID ($0.05 USDC via x402) — Market state with reference rates attributed to their source, network fee pressure, and a description of current network conditions. Factual data only: no recommendation, no advice, no signal to act. Requires funded Stellar wallet.', {}, async () => paymentsUnavailable()
209
- ?? callJson(`${API_URL}/api/v1/premium/market`, undefined, paidFetch));
210
- server.tool('execute_paid_strategy', 'PAID ($0.25 USDC via x402) — Execute a DeFi strategy on Stellar via Soroban. No Nirium account required — pay per execution. Requires funded Stellar wallet.', {
211
- strategy: zod_1.z.string().describe('Strategy: flash-loan-arb | path-arbitrage | cross-dex | blend-yield | soroswap-swap'),
212
- asset: zod_1.z.string().describe('Trading pair, e.g. XLM-USDC'),
213
- params: zod_1.z.record(zod_1.z.unknown()).optional().describe('Strategy-specific parameters'),
214
- }, async (args) => paymentsUnavailable()
215
- ?? callJson(`${API_URL}/api/v1/premium/execute`, {
216
- method: 'POST',
217
- headers: { 'Content-Type': 'application/json' },
218
- body: JSON.stringify(args),
219
- }, paidFetch));
220
- server.tool('get_wallet_info', 'Show the x402 + MPP wallet address and payment configuration for this MCP session. Free.', {}, async () => text({
221
- address: STELLAR_PUBLIC_KEY || null,
222
- network: STELLAR_NET,
223
- rpcUrl: RPC_URL || null,
224
- agentApiUrl: API_URL,
225
- niriumApiKeySet: !!NIRIUM_API_KEY,
226
- x402Enabled: PAYMENTS_ENABLED,
227
- mppEnabled: PAYMENTS_ENABLED,
228
- ...(PAYMENTS_ENABLED ? {} : { paymentsDisabledReason: PAYMENTS_DISABLED_REASON }),
229
- freeTools: ['get_market_state', 'get_loop_status', 'execute_demo', 'get_nodes', 'anchor_audit_record', 'get_reporting_summary'],
230
- authenticatedTools: ['start_loop', 'stop_loop'],
231
- paidToolsX402: ['get_premium_signals', 'get_premium_market', 'execute_paid_strategy'],
232
- paidToolsMpp: ['get_mpp_signals', 'get_mpp_market'],
233
- }));
234
- // ─── NODE CATALOG + AUDIT + REPORTING (free) ──────────────────
235
- //
236
- // Los nodos non-custodial que ya corren en mainnet. Ninguno mueve fondos:
237
- // el catálogo es lectura, el anclaje sube un hash a IPFS y el reporting
238
- // agrega recibos existentes — por eso no llevan wallet ni pago.
239
- //
240
- server.tool('get_nodes', 'List the Nirium execution nodes with their live status, custody model and network (testnet/mainnet). Free — reads the protocol registry.', {}, async () => callJson(`${API_URL}/api/nodes`));
241
- server.tool('anchor_audit_record', 'Anchor evidence to IPFS and get back a CID (immutable integrity seal, not notarization). '
242
- + 'Pass `hash` (sha-256 hex of your own file/event) or `record` (small JSON object, max 8KB). '
243
- + 'Anchor hashes rather than raw personal data — IPFS content cannot be deleted. Free during open beta.', {
244
- hash: zod_1.z.string().optional().describe('sha-256 hex (64 chars), optionally prefixed "sha-256:"'),
245
- record: zod_1.z.record(zod_1.z.unknown()).optional().describe('Small JSON object to anchor verbatim (max 8KB)'),
246
- txHash: zod_1.z.string().optional().describe('Related Stellar transaction hash, if any'),
247
- network: zod_1.z.string().optional().describe('Network label to store with the anchor, e.g. mainnet'),
248
- tag: zod_1.z.string().optional().describe('Free-form label to group anchors'),
249
- }, async (args) => {
250
- if (!args.hash && !args.record)
251
- return fail('Provide `hash` (sha-256 of your evidence) or `record` (small JSON object).');
252
- return callJson(`${API_URL}/api/audit/log`, {
253
- method: 'POST',
254
- headers: { 'Content-Type': 'application/json', ...authHeaders() },
255
- body: JSON.stringify(args),
256
- });
257
- });
258
- server.tool('get_reporting_summary', 'Institutional-format summary of settled payouts, x402/MPP payment receipts and IPFS anchors for a period. '
259
- + 'Not certified regulatory reporting — filings remain the client\'s responsibility. Free.', {
260
- from: zod_1.z.string().optional().describe('ISO start date, e.g. 2026-07-01 (defaults to last 30 days)'),
261
- to: zod_1.z.string().optional().describe('ISO end date'),
262
- network: zod_1.z.enum(['testnet', 'mainnet']).optional().describe('Filter by network; omit for all'),
263
- }, async (args) => {
264
- const q = new URLSearchParams(Object.entries(args).filter(([, v]) => v !== undefined)).toString();
265
- return callJson(`${API_URL}/api/reporting/summary${q ? `?${q}` : ''}`, { headers: authHeaders() });
266
- });
267
- // ─── PAID TOOLS (MPP) ─────────────────────────────────────────
268
- //
269
- // MPP Charge mode: no external facilitator.
270
- // The client signs a Soroban SAC transfer and sends it inline.
271
- // Server verifies the on-chain transfer and returns 200.
272
- //
273
- // Advantage over x402: no Coinbase facilitator dependency.
274
- // Both x402 and MPP tools are available — client chooses.
275
- //
276
- server.tool('get_mpp_signals', 'PAID ($0.02 USDC via MPP Charge) — TESTNET ONLY, same data as get_premium_signals, settled via direct Soroban SAC transfer with no external facilitator. Testnet tokens have no monetary value; this is not a recommendation to buy, sell or hold anything. Requires funded Stellar wallet.', {
277
- count: zod_1.z.number().optional().describe('Number of signals to fetch (default: 20, max: 100)'),
278
- }, async (args) => paymentsUnavailable()
279
- ?? callJson(`${API_URL}/api/v1/mpp/signals?count=${args.count || 20}`, undefined, mppFetch));
280
- server.tool('get_mpp_market', 'PAID ($0.05 USDC via MPP Charge) — Market state settled via direct Soroban SAC transfer, no external facilitator. Reference rates with their source, fee pressure, and network conditions. Factual data only: no recommendation or advice. Requires funded Stellar wallet.', {}, async () => paymentsUnavailable()
281
- ?? callJson(`${API_URL}/api/v1/mpp/market`, undefined, mppFetch));
282
- // ─── Start ────────────────────────────────────────────────────
283
- async function main() {
284
- const transport = new stdio_js_1.StdioServerTransport();
285
- await server.connect(transport);
286
- console.error('[Nirium MCP] v0.5.0 running on stdio');
287
- console.error(`[Nirium MCP] Agent API: ${API_URL}`);
288
- console.error(`[Nirium MCP] NIRIUM_API_KEY set: ${!!NIRIUM_API_KEY}`);
289
- console.error(`[Nirium MCP] x402 enabled: ${!!STELLAR_KEY}`);
290
- console.error(`[Nirium MCP] MPP Charge enabled: ${!!STELLAR_KEY}`);
291
- }
292
- main().catch((err) => {
293
- console.error('[Nirium MCP] Fatal error:', err);
294
- process.exit(1);
295
- });