neutron-mcp 1.0.4 → 1.0.5

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 CHANGED
@@ -152,6 +152,8 @@ Then use `"command": "neutron-mcp"` instead of `npx` in your config.
152
152
 
153
153
  Once configured, just ask your AI assistant naturally:
154
154
 
155
+ > "Authenticate with Neutron and verify my credentials"
156
+
155
157
  > "Create a Lightning invoice for 10,000 sats"
156
158
 
157
159
  > "Show me my wallet balances"
@@ -170,6 +172,11 @@ Once configured, just ask your AI assistant naturally:
170
172
 
171
173
  ## Available Tools
172
174
 
175
+ ### Authentication
176
+ | Tool | Description |
177
+ |------|-------------|
178
+ | `neutron_authenticate` | Verify API credentials and get access token |
179
+
173
180
  ### Account Management
174
181
  | Tool | Description |
175
182
  |------|-------------|
package/dist/index.js CHANGED
@@ -79,6 +79,15 @@ const server = new Server({
79
79
  });
80
80
  // Tool definitions
81
81
  const tools = [
82
+ {
83
+ name: "neutron_authenticate",
84
+ description: "Authenticate with Neutron API using your API key and secret. Returns account ID, access token, and token expiry. Use this to verify your credentials are configured correctly.",
85
+ inputSchema: {
86
+ type: "object",
87
+ properties: {},
88
+ required: [],
89
+ },
90
+ },
82
91
  {
83
92
  name: "neutron_get_account",
84
93
  description: "Get Neutron account information including display name, status, country, and timezone",
@@ -411,6 +420,22 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
411
420
  const client = createClient();
412
421
  try {
413
422
  switch (name) {
423
+ case "neutron_authenticate": {
424
+ const authResult = await client.authenticate();
425
+ return {
426
+ content: [
427
+ {
428
+ type: "text",
429
+ text: JSON.stringify({
430
+ success: true,
431
+ accountId: authResult.accountId,
432
+ tokenExpiry: authResult.expiredAt,
433
+ message: "Authentication successful. Your API credentials are valid.",
434
+ }, null, 2),
435
+ },
436
+ ],
437
+ };
438
+ }
414
439
  case "neutron_get_account": {
415
440
  const account = await client.getAccount();
416
441
  return {
@@ -1,12 +1,14 @@
1
- import type { NeutronConfig, Account, Wallet, ReceiveAddress, Transaction, CreateTransactionRequest, TransactionListParams, TransactionListResponse, Webhook, CreateWebhookRequest, UpdateWebhookRequest, FiatInstitution } from "./types.js";
1
+ import type { NeutronConfig, AuthResponse, Account, Wallet, ReceiveAddress, Transaction, CreateTransactionRequest, TransactionListParams, TransactionListResponse, Webhook, CreateWebhookRequest, UpdateWebhookRequest, FiatInstitution } from "./types.js";
2
2
  export declare class NeutronClient {
3
3
  private config;
4
4
  private accountId;
5
5
  private accessToken;
6
6
  private tokenExpiry;
7
+ private cachedAuthResponse;
7
8
  constructor(config: NeutronConfig);
8
9
  private generateSignature;
9
10
  private ensureAuthenticated;
11
+ authenticate(): Promise<AuthResponse>;
10
12
  private request;
11
13
  getAccount(): Promise<Account>;
12
14
  getWallets(): Promise<Wallet[]>;
@@ -4,6 +4,7 @@ export class NeutronClient {
4
4
  accountId = null;
5
5
  accessToken = null;
6
6
  tokenExpiry = 0;
7
+ cachedAuthResponse = null;
7
8
  constructor(config) {
8
9
  this.config = config;
9
10
  }
@@ -16,9 +17,9 @@ export class NeutronClient {
16
17
  .digest("hex");
17
18
  }
18
19
  async ensureAuthenticated() {
19
- // Check if we have a valid token
20
- if (this.accessToken && this.accountId && Date.now() < this.tokenExpiry) {
21
- return;
20
+ // Check if we have a valid cached token
21
+ if (this.cachedAuthResponse && this.accessToken && this.accountId && Date.now() < this.tokenExpiry) {
22
+ return this.cachedAuthResponse;
22
23
  }
23
24
  // Authenticate to get accountId and accessToken
24
25
  const payload = JSON.stringify({ test: "auth" });
@@ -39,10 +40,21 @@ export class NeutronClient {
39
40
  const authResult = (await response.json());
40
41
  this.accountId = authResult.accountId;
41
42
  this.accessToken = authResult.accessToken;
43
+ this.cachedAuthResponse = authResult;
42
44
  // Set expiry (parse the expiredAt or default to 1 hour)
43
45
  this.tokenExpiry = authResult.expiredAt
44
46
  ? new Date(authResult.expiredAt).getTime()
45
47
  : Date.now() + 3600000;
48
+ return authResult;
49
+ }
50
+ // Public method to authenticate and verify credentials
51
+ async authenticate() {
52
+ // Force re-authentication by clearing cached token
53
+ this.accessToken = null;
54
+ this.accountId = null;
55
+ this.tokenExpiry = 0;
56
+ this.cachedAuthResponse = null;
57
+ return this.ensureAuthenticated();
46
58
  }
47
59
  async request(method, path, body) {
48
60
  await this.ensureAuthenticated();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neutron-mcp",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "MCP server for Neutron - Lightning payments, Bitcoin, USDT, and fiat transactions for AI-powered applications",
5
5
  "main": "dist/index.js",
6
6
  "bin": {