@mgsoftwarebv/mg-dashboard-mcp 3.4.0 → 3.4.2

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/dist/index.js CHANGED
@@ -83,7 +83,7 @@ function deriveAuthBaseUrl(proxyUrl2) {
83
83
  const u = new URL(proxyUrl2);
84
84
  return `${u.protocol}//${u.host}`;
85
85
  }
86
- async function performHandshake(proxyUrl2, pubPath, pubText) {
86
+ async function performHandshake(proxyUrl2, apiKey2, pubPath, pubText) {
87
87
  const base = deriveAuthBaseUrl(proxyUrl2);
88
88
  const challengeRes = await fetch(`${base}/v1/auth/ssh/challenge`, {
89
89
  method: "POST",
@@ -110,6 +110,7 @@ async function performHandshake(proxyUrl2, pubPath, pubText) {
110
110
  headers: { "Content-Type": "application/json" },
111
111
  body: JSON.stringify({
112
112
  challenge_id: challenge.challenge_id,
113
+ api_key: apiKey2,
113
114
  pubkey: pubText,
114
115
  signature: sign.stdout
115
116
  })
@@ -127,10 +128,11 @@ async function performHandshake(proxyUrl2, pubPath, pubText) {
127
128
  }
128
129
  async function runBridge(handshake, proxyUrl2, refresh) {
129
130
  let currentToken = handshake.token;
131
+ const requestHeaders = {
132
+ Authorization: `Bearer ${currentToken}`
133
+ };
130
134
  const upstreamTransport = new StreamableHTTPClientTransport(new URL(proxyUrl2), {
131
- requestInit: () => ({
132
- headers: { Authorization: `Bearer ${currentToken}` }
133
- })
135
+ requestInit: { headers: requestHeaders }
134
136
  });
135
137
  const upstream = new Client$1({ name: "mg-dashboard-mcp-proxy-bridge", version: "1.0.0" });
136
138
  const scheduleRefresh = (result) => {
@@ -139,6 +141,7 @@ async function runBridge(handshake, proxyUrl2, refresh) {
139
141
  try {
140
142
  const fresh = await refresh();
141
143
  currentToken = fresh.token;
144
+ requestHeaders.Authorization = `Bearer ${currentToken}`;
142
145
  console.error(`[Proxy] Token refreshed (key: ${fresh.proxyKeyName})`);
143
146
  scheduleRefresh(fresh);
144
147
  } catch (err) {
@@ -169,14 +172,30 @@ async function runBridge(handshake, proxyUrl2, refresh) {
169
172
  };
170
173
  await stdioServer.connect(new StdioServerTransport());
171
174
  console.error(`[Proxy] Bridge ready. Forwarding stdio \u2192 ${proxyUrl2}`);
175
+ await new Promise((resolve) => {
176
+ const keepAlive = setInterval(() => void 0, 2147483647);
177
+ const done = () => {
178
+ clearInterval(keepAlive);
179
+ resolve();
180
+ };
181
+ process.stdin.once("close", done);
182
+ process.stdin.once("end", done);
183
+ process.once("SIGINT", done);
184
+ process.once("SIGTERM", done);
185
+ });
172
186
  }
173
187
  async function runProxyMode(args2) {
174
188
  const proxyUrl2 = getArg(args2, "proxy-url") || process.env.MG_DASHBOARD_PROXY_URL;
189
+ const apiKey2 = getArg(args2, "api-key") || process.env.MG_DASHBOARD_API_KEY;
175
190
  const sshKey = getArg(args2, "ssh-key") || process.env.MG_DASHBOARD_SSH_KEY;
176
191
  if (!proxyUrl2) {
177
192
  console.error("--proxy-url is required (or set MG_DASHBOARD_PROXY_URL)");
178
193
  process.exit(1);
179
194
  }
195
+ if (!apiKey2) {
196
+ console.error("--api-key is required in proxy mode (or set MG_DASHBOARD_API_KEY)");
197
+ process.exit(1);
198
+ }
180
199
  if (!sshKey) {
181
200
  console.error("--ssh-key is required in proxy mode (or set MG_DASHBOARD_SSH_KEY)");
182
201
  process.exit(1);
@@ -189,7 +208,7 @@ async function runProxyMode(args2) {
189
208
  console.error(`[Proxy] ${err instanceof Error ? err.message : String(err)}`);
190
209
  process.exit(1);
191
210
  }
192
- const refresh = () => performHandshake(proxyUrl2, resolved.pubPath, resolved.pubText);
211
+ const refresh = () => performHandshake(proxyUrl2, apiKey2, resolved.pubPath, resolved.pubText);
193
212
  let handshake;
194
213
  try {
195
214
  handshake = await refresh();