@ktmcp-cli/nordigen 1.0.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 ADDED
@@ -0,0 +1,424 @@
1
+ # Nordigen CLI
2
+
3
+ <p align="center">
4
+ <img src="banner.png" alt="KTMCP Banner" width="100%">
5
+ </p>
6
+
7
+
8
+ Production-ready command-line interface for the Nordigen Account Information Services API (Open Banking).
9
+
10
+ ## Features
11
+
12
+ - Complete coverage of Nordigen API v2
13
+ - JWT authentication with automatic token refresh
14
+ - Secure credential storage
15
+ - Rich terminal output with colors and formatting
16
+ - JSON output for scripting and automation
17
+ - Comprehensive error handling
18
+ - Support for all major operations:
19
+ - Account information (balances, details, transactions)
20
+ - Institution browsing and search
21
+ - End User Agreements (EUA) management
22
+ - Requisition creation and management
23
+ - Payment operations
24
+
25
+ ## Installation
26
+
27
+ ### From Source
28
+
29
+ ```bash
30
+ cd /workspace/group/ktmcp/workspace/nordigen
31
+ npm install
32
+ chmod +x bin/nordigen.js
33
+ npm link # or add to PATH
34
+ ```
35
+
36
+ ### From NPM (when published)
37
+
38
+ ```bash
39
+ npm install -g @ktmcp-cli/nordigen
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ### 1. Authentication
45
+
46
+ First, obtain your API credentials from the Nordigen dashboard at https://nordigen.com
47
+
48
+ ```bash
49
+ # Login with your credentials
50
+ nordigen auth login --secret-id YOUR_SECRET_ID --secret-key YOUR_SECRET_KEY
51
+
52
+ # Check authentication status
53
+ nordigen auth status
54
+ ```
55
+
56
+ ### 2. Browse Institutions
57
+
58
+ ```bash
59
+ # List banks in Great Britain
60
+ nordigen institutions list --country GB
61
+
62
+ # Search for a specific bank
63
+ nordigen institutions search "Barclays" --country GB
64
+
65
+ # Get details for a specific institution
66
+ nordigen institutions get BARCLAYS_BARCGB22
67
+ ```
68
+
69
+ ### 3. Create End User Agreement
70
+
71
+ ```bash
72
+ # Create an agreement for accessing account data
73
+ nordigen agreements create \
74
+ --institution-id BARCLAYS_BARCGB22 \
75
+ --max-days 90 \
76
+ --valid-days 90
77
+ ```
78
+
79
+ ### 4. Create Requisition
80
+
81
+ ```bash
82
+ # Create a requisition to connect a bank account
83
+ nordigen requisitions create \
84
+ --institution-id BARCLAYS_BARCGB22 \
85
+ --redirect https://yourapp.com/callback \
86
+ --agreement <AGREEMENT_ID>
87
+
88
+ # The command will return an authentication link
89
+ # Send this link to the end user to authorize access
90
+ ```
91
+
92
+ ### 5. Access Account Data
93
+
94
+ ```bash
95
+ # Get account metadata
96
+ nordigen accounts get <ACCOUNT_ID>
97
+
98
+ # Get account balances
99
+ nordigen accounts balances <ACCOUNT_ID>
100
+
101
+ # Get account transactions
102
+ nordigen accounts transactions <ACCOUNT_ID>
103
+
104
+ # Get transactions for a date range
105
+ nordigen accounts transactions <ACCOUNT_ID> \
106
+ --from 2024-01-01 \
107
+ --to 2024-12-31
108
+ ```
109
+
110
+ ## Command Reference
111
+
112
+ ### Authentication
113
+
114
+ ```bash
115
+ # Login
116
+ nordigen auth login --secret-id <id> --secret-key <key>
117
+
118
+ # Check status
119
+ nordigen auth status
120
+
121
+ # Logout
122
+ nordigen auth logout
123
+ ```
124
+
125
+ ### Institutions
126
+
127
+ ```bash
128
+ # List institutions
129
+ nordigen institutions list --country <CODE>
130
+ nordigen institutions list --country GB --payments
131
+
132
+ # Search institutions
133
+ nordigen institutions search <query> --country <CODE>
134
+
135
+ # Get institution details
136
+ nordigen institutions get <INSTITUTION_ID>
137
+ ```
138
+
139
+ ### End User Agreements
140
+
141
+ ```bash
142
+ # List agreements
143
+ nordigen agreements list
144
+
145
+ # Create agreement
146
+ nordigen agreements create \
147
+ --institution-id <ID> \
148
+ --max-days 90 \
149
+ --valid-days 90 \
150
+ --scope balances details transactions
151
+
152
+ # Get agreement
153
+ nordigen agreements get <AGREEMENT_ID>
154
+
155
+ # Delete agreement
156
+ nordigen agreements delete <AGREEMENT_ID> --yes
157
+
158
+ # Accept agreement (programmatically)
159
+ nordigen agreements accept <AGREEMENT_ID> \
160
+ --user-agent "Mozilla/5.0..." \
161
+ --ip "192.168.1.1"
162
+ ```
163
+
164
+ ### Requisitions
165
+
166
+ ```bash
167
+ # List requisitions
168
+ nordigen requisitions list
169
+
170
+ # Create requisition
171
+ nordigen requisitions create \
172
+ --institution-id <ID> \
173
+ --redirect <URL> \
174
+ --reference "my-ref" \
175
+ --agreement <AGREEMENT_ID>
176
+
177
+ # Get requisition
178
+ nordigen requisitions get <REQUISITION_ID>
179
+
180
+ # Delete requisition
181
+ nordigen requisitions delete <REQUISITION_ID> --yes
182
+ ```
183
+
184
+ ### Accounts
185
+
186
+ ```bash
187
+ # Get account metadata
188
+ nordigen accounts get <ACCOUNT_ID>
189
+
190
+ # Get balances
191
+ nordigen accounts balances <ACCOUNT_ID>
192
+
193
+ # Get account details
194
+ nordigen accounts details <ACCOUNT_ID>
195
+
196
+ # Get transactions
197
+ nordigen accounts transactions <ACCOUNT_ID>
198
+ nordigen accounts transactions <ACCOUNT_ID> --from 2024-01-01 --to 2024-12-31
199
+
200
+ # Premium transactions (with country-specific data)
201
+ nordigen accounts transactions <ACCOUNT_ID> --premium --country GB
202
+ ```
203
+
204
+ ### Payments
205
+
206
+ ```bash
207
+ # List payments
208
+ nordigen payments list
209
+
210
+ # Get payment details
211
+ nordigen payments get <PAYMENT_ID>
212
+
213
+ # Delete payment
214
+ nordigen payments delete <PAYMENT_ID> --yes
215
+
216
+ # List creditors
217
+ nordigen payments creditors
218
+
219
+ # Get required payment fields for institution
220
+ nordigen payments fields <INSTITUTION_ID>
221
+ ```
222
+
223
+ ### Configuration
224
+
225
+ ```bash
226
+ # Show configuration
227
+ nordigen config show
228
+ nordigen config show --show-secrets # WARNING: displays sensitive data
229
+
230
+ # Get specific value
231
+ nordigen config get auth.secret_id
232
+
233
+ # Set value
234
+ nordigen config set defaults.country GB
235
+
236
+ # Set default country
237
+ nordigen config set-country GB
238
+
239
+ # Clear all configuration
240
+ nordigen config clear --yes
241
+ ```
242
+
243
+ ## JSON Output
244
+
245
+ All commands support `--json` or `-j` flag for machine-readable output:
246
+
247
+ ```bash
248
+ # Get account as JSON
249
+ nordigen accounts get <ACCOUNT_ID> --json
250
+
251
+ # Pipe to jq for processing
252
+ nordigen institutions list --country GB --json | jq '.[].name'
253
+ ```
254
+
255
+ ## Environment Variables
256
+
257
+ - `DEBUG=1` - Enable debug output with stack traces
258
+ - `NORDIGEN_SECRET_ID` - Alternative to storing secret ID in config
259
+ - `NORDIGEN_SECRET_KEY` - Alternative to storing secret key in config
260
+
261
+ ## Configuration Storage
262
+
263
+ Configuration is stored securely in:
264
+
265
+ - **Linux/macOS**: `~/.config/nordigen-cli/config.json`
266
+ - **Windows**: `%APPDATA%\nordigen-cli\config.json`
267
+
268
+ The config file has permissions set to `0600` (read/write for owner only).
269
+
270
+ ## Error Handling
271
+
272
+ The CLI provides detailed error messages with exit codes:
273
+
274
+ - `0` - Success
275
+ - `1` - General error
276
+ - `400` - Bad request / validation error
277
+ - `401` - Authentication error
278
+ - `403` - Permission denied
279
+ - `404` - Resource not found
280
+ - `429` - Rate limit exceeded
281
+ - `500` - Server error
282
+
283
+ Enable debug output for detailed stack traces:
284
+
285
+ ```bash
286
+ DEBUG=1 nordigen accounts get <ACCOUNT_ID>
287
+ ```
288
+
289
+ ## Common Workflows
290
+
291
+ ### Complete Bank Connection Flow
292
+
293
+ ```bash
294
+ # 1. Find the institution
295
+ nordigen institutions search "Your Bank" --country GB
296
+
297
+ # 2. Create end user agreement
298
+ nordigen agreements create --institution-id <INST_ID> --max-days 90
299
+
300
+ # 3. Create requisition
301
+ nordigen requisitions create \
302
+ --institution-id <INST_ID> \
303
+ --redirect https://yourapp.com/callback \
304
+ --agreement <AGREEMENT_ID>
305
+
306
+ # 4. Send the returned link to your user for authentication
307
+
308
+ # 5. After user authenticates, retrieve accounts
309
+ nordigen requisitions get <REQUISITION_ID>
310
+
311
+ # 6. Access account data
312
+ nordigen accounts balances <ACCOUNT_ID>
313
+ nordigen accounts transactions <ACCOUNT_ID>
314
+ ```
315
+
316
+ ### Batch Processing Accounts
317
+
318
+ ```bash
319
+ # Get all requisitions as JSON
320
+ nordigen requisitions list --json > requisitions.json
321
+
322
+ # Extract account IDs and fetch transactions
323
+ cat requisitions.json | jq -r '.results[].accounts[]' | while read account; do
324
+ echo "Fetching transactions for $account"
325
+ nordigen accounts transactions $account --json > "transactions_${account}.json"
326
+ done
327
+ ```
328
+
329
+ ## Why CLI > MCP?
330
+
331
+ ### Performance
332
+ - **CLI**: Direct execution, no protocol overhead, instant responses
333
+ - **MCP**: Additional network/IPC layer, serialization overhead, slower responses
334
+
335
+ ### Simplicity
336
+ - **CLI**: Simple command invocation, standard UNIX patterns, easy to compose
337
+ - **MCP**: Requires server setup, protocol understanding, more moving parts
338
+
339
+ ### Debugging
340
+ - **CLI**: Standard stdout/stderr, easy to debug with DEBUG flag
341
+ - **MCP**: Protocol messages, requires MCP-specific debugging tools
342
+
343
+ ### Integration
344
+ - **CLI**: Works with any language via subprocess, easy shell scripting
345
+ - **MCP**: Requires MCP client library, limited language support
346
+
347
+ ### Portability
348
+ - **CLI**: Single binary/script, runs anywhere with Node.js
349
+ - **MCP**: Requires MCP server runtime, more dependencies
350
+
351
+ ### Use Cases
352
+
353
+ **Use CLI when:**
354
+ - Building scripts and automation
355
+ - One-off data retrieval tasks
356
+ - Integrating with existing shell workflows
357
+ - Debugging API responses
358
+ - Human interaction needed
359
+
360
+ **Use MCP when:**
361
+ - Building persistent AI agent applications
362
+ - Need stateful server connections
363
+ - Multiple AI tools need shared context
364
+ - Protocol-level features required
365
+
366
+ ## Troubleshooting
367
+
368
+ ### Token Expired
369
+
370
+ ```bash
371
+ # Check authentication status
372
+ nordigen auth status
373
+
374
+ # Re-login if needed
375
+ nordigen auth login --secret-id <id> --secret-key <key>
376
+ ```
377
+
378
+ ### Rate Limiting
379
+
380
+ If you hit rate limits, the API will return a 429 error. Wait and retry, or implement exponential backoff in your scripts.
381
+
382
+ ### Account Access Errors
383
+
384
+ Ensure:
385
+ 1. Valid End User Agreement exists
386
+ 2. Agreement has correct access scope
387
+ 3. User has completed authentication flow
388
+ 4. Access period hasn't expired
389
+
390
+ ## API Documentation
391
+
392
+ For complete API reference, see:
393
+ - Official Nordigen Docs: https://nordigen.com/en/docs/
394
+ - OpenAPI Spec: https://ob.nordigen.com/api/swagger/
395
+
396
+ ## Development
397
+
398
+ ```bash
399
+ # Install dependencies
400
+ npm install
401
+
402
+ # Run tests
403
+ npm test
404
+
405
+ # Lint code
406
+ npm run lint
407
+
408
+ # Make executable
409
+ chmod +x bin/nordigen.js
410
+ ```
411
+
412
+ ## License
413
+
414
+ MIT
415
+
416
+ ## Support
417
+
418
+ - GitHub Issues: https://github.com/ktmcp/nordigen-cli/issues
419
+ - Email: support@ktmcp.com
420
+
421
+ ## Related Documentation
422
+
423
+ - [AGENT.md](./AGENT.md) - AI agent integration patterns
424
+ - [OPENCLAW.md](./OPENCLAW.md) - OpenClaw integration guide
package/SETUP.md ADDED
@@ -0,0 +1,259 @@
1
+ # Nordigen CLI - Setup & Installation Guide
2
+
3
+ Complete setup guide for getting the Nordigen CLI running.
4
+
5
+ ## Prerequisites
6
+
7
+ - **Node.js**: Version 18 or higher
8
+ - **npm**: Comes with Node.js
9
+ - **Nordigen Account**: Sign up at https://nordigen.com
10
+
11
+ ## Quick Setup (Automated)
12
+
13
+ ```bash
14
+ cd /workspace/group/ktmcp/workspace/nordigen
15
+ ./scripts/quickstart.sh
16
+ ```
17
+
18
+ The script will:
19
+ 1. Check Node.js version
20
+ 2. Install dependencies
21
+ 3. Make CLI executable
22
+ 4. Link CLI globally
23
+ 5. Authenticate (if credentials are set)
24
+
25
+ ## Manual Setup
26
+
27
+ ### 1. Install Dependencies
28
+
29
+ ```bash
30
+ cd /workspace/group/ktmcp/workspace/nordigen
31
+ npm install
32
+ ```
33
+
34
+ This installs:
35
+ - `commander` - CLI framework
36
+ - `chalk` - Terminal colors
37
+ - `ora` - Spinners
38
+ - `conf` - Configuration storage
39
+ - `node-fetch` - HTTP client
40
+ - `date-fns` - Date utilities
41
+
42
+ ### 2. Make Executable
43
+
44
+ ```bash
45
+ chmod +x bin/nordigen.js
46
+ ```
47
+
48
+ ### 3. Link CLI Globally
49
+
50
+ ```bash
51
+ npm link
52
+ ```
53
+
54
+ This creates a global `nordigen` command.
55
+
56
+ **Verify installation:**
57
+ ```bash
58
+ nordigen --version
59
+ nordigen --help
60
+ ```
61
+
62
+ ### 4. Get API Credentials
63
+
64
+ 1. Visit https://nordigen.com/en/account/login/
65
+ 2. Sign up or log in
66
+ 3. Navigate to: **User Secrets** → **Create New Secret**
67
+ 4. Copy your:
68
+ - Secret ID
69
+ - Secret Key
70
+
71
+ ### 5. Configure Credentials
72
+
73
+ **Option A: Environment Variables (Recommended)**
74
+
75
+ ```bash
76
+ export NORDIGEN_SECRET_ID="your-secret-id-here"
77
+ export NORDIGEN_SECRET_KEY="your-secret-key-here"
78
+ ```
79
+
80
+ Add to your `~/.bashrc` or `~/.zshrc` for persistence.
81
+
82
+ **Option B: Login Command**
83
+
84
+ ```bash
85
+ nordigen auth login \
86
+ --secret-id "your-secret-id" \
87
+ --secret-key "your-secret-key"
88
+ ```
89
+
90
+ Credentials are stored securely in:
91
+ - Linux/macOS: `~/.config/nordigen-cli/config.json`
92
+ - Windows: `%APPDATA%\nordigen-cli\config.json`
93
+
94
+ **Option C: .env File**
95
+
96
+ ```bash
97
+ cp .env.example .env
98
+ # Edit .env and add your credentials
99
+ ```
100
+
101
+ ### 6. Test Installation
102
+
103
+ ```bash
104
+ # Check authentication
105
+ nordigen auth status
106
+
107
+ # List institutions in UK
108
+ nordigen institutions list --country GB
109
+
110
+ # Get specific institution
111
+ nordigen institutions get BARCLAYS_BARCGB22
112
+ ```
113
+
114
+ ## Post-Installation
115
+
116
+ ### Set Default Country (Optional)
117
+
118
+ ```bash
119
+ nordigen config set-country GB
120
+ ```
121
+
122
+ ### Enable Debug Mode (Optional)
123
+
124
+ ```bash
125
+ export DEBUG=1
126
+ nordigen accounts balances <account-id>
127
+ ```
128
+
129
+ ## Troubleshooting
130
+
131
+ ### "Command not found: nordigen"
132
+
133
+ **Solution**: Ensure `npm link` completed successfully and npm global bin is in PATH.
134
+
135
+ ```bash
136
+ # Check npm global bin path
137
+ npm config get prefix
138
+
139
+ # Add to PATH (if needed)
140
+ export PATH="$(npm config get prefix)/bin:$PATH"
141
+ ```
142
+
143
+ ### "Not authenticated" error
144
+
145
+ **Solution**: Login with your credentials.
146
+
147
+ ```bash
148
+ nordigen auth login --secret-id <id> --secret-key <key>
149
+ ```
150
+
151
+ ### Token expired
152
+
153
+ **Solution**: The CLI automatically refreshes tokens. If that fails, re-login.
154
+
155
+ ```bash
156
+ nordigen auth status
157
+ nordigen auth login --secret-id <id> --secret-key <key>
158
+ ```
159
+
160
+ ### Permission denied on config file
161
+
162
+ **Solution**: Fix file permissions.
163
+
164
+ ```bash
165
+ chmod 600 ~/.config/nordigen-cli/config.json
166
+ ```
167
+
168
+ ### Module not found errors
169
+
170
+ **Solution**: Reinstall dependencies.
171
+
172
+ ```bash
173
+ rm -rf node_modules package-lock.json
174
+ npm install
175
+ ```
176
+
177
+ ## Development Setup
178
+
179
+ For contributing to the CLI:
180
+
181
+ ```bash
182
+ # Clone the repository
183
+ git clone https://github.com/ktmcp/nordigen-cli.git
184
+ cd nordigen-cli
185
+
186
+ # Install dependencies
187
+ npm install
188
+
189
+ # Link for local development
190
+ npm link
191
+
192
+ # Run tests
193
+ npm test
194
+
195
+ # Lint code
196
+ npm run lint
197
+ ```
198
+
199
+ ## Uninstallation
200
+
201
+ ```bash
202
+ # Unlink global command
203
+ npm unlink -g @ktmcp-cli/nordigen
204
+
205
+ # Or if installed via npm
206
+ npm uninstall -g @ktmcp-cli/nordigen
207
+
208
+ # Remove config (optional)
209
+ rm -rf ~/.config/nordigen-cli
210
+ ```
211
+
212
+ ## Updating
213
+
214
+ ### From Source
215
+
216
+ ```bash
217
+ cd nordigen-cli
218
+ git pull
219
+ npm install
220
+ ```
221
+
222
+ ### From NPM
223
+
224
+ ```bash
225
+ npm update -g @ktmcp-cli/nordigen
226
+ ```
227
+
228
+ ## Docker Setup (Alternative)
229
+
230
+ Coming soon - Docker container for isolated environments.
231
+
232
+ ## Next Steps
233
+
234
+ After successful installation:
235
+
236
+ 1. Read [README.md](./README.md) for full documentation
237
+ 2. Try [EXAMPLES.md](./EXAMPLES.md) for practical use cases
238
+ 3. Check [QUICKREF.md](./QUICKREF.md) for command reference
239
+ 4. See [AGENT.md](./AGENT.md) for AI integration
240
+
241
+ ## Support
242
+
243
+ - **Issues**: https://github.com/ktmcp/nordigen-cli/issues
244
+ - **Documentation**: See *.md files in this directory
245
+ - **API Docs**: https://nordigen.com/en/docs/
246
+
247
+ ## Verification Checklist
248
+
249
+ - [ ] Node.js 18+ installed
250
+ - [ ] Dependencies installed (`npm install`)
251
+ - [ ] CLI executable (`chmod +x bin/nordigen.js`)
252
+ - [ ] CLI linked globally (`npm link`)
253
+ - [ ] `nordigen --version` works
254
+ - [ ] Nordigen account created
255
+ - [ ] API credentials obtained
256
+ - [ ] Authenticated (`nordigen auth login`)
257
+ - [ ] Test command works (`nordigen institutions list --country GB`)
258
+
259
+ Once all items are checked, you're ready to use the Nordigen CLI!