@mgsoftwarebv/mg-dashboard-mcp 3.4.0 → 3.4.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/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) {
@@ -172,11 +175,16 @@ async function runBridge(handshake, proxyUrl2, refresh) {
172
175
  }
173
176
  async function runProxyMode(args2) {
174
177
  const proxyUrl2 = getArg(args2, "proxy-url") || process.env.MG_DASHBOARD_PROXY_URL;
178
+ const apiKey2 = getArg(args2, "api-key") || process.env.MG_DASHBOARD_API_KEY;
175
179
  const sshKey = getArg(args2, "ssh-key") || process.env.MG_DASHBOARD_SSH_KEY;
176
180
  if (!proxyUrl2) {
177
181
  console.error("--proxy-url is required (or set MG_DASHBOARD_PROXY_URL)");
178
182
  process.exit(1);
179
183
  }
184
+ if (!apiKey2) {
185
+ console.error("--api-key is required in proxy mode (or set MG_DASHBOARD_API_KEY)");
186
+ process.exit(1);
187
+ }
180
188
  if (!sshKey) {
181
189
  console.error("--ssh-key is required in proxy mode (or set MG_DASHBOARD_SSH_KEY)");
182
190
  process.exit(1);
@@ -189,7 +197,7 @@ async function runProxyMode(args2) {
189
197
  console.error(`[Proxy] ${err instanceof Error ? err.message : String(err)}`);
190
198
  process.exit(1);
191
199
  }
192
- const refresh = () => performHandshake(proxyUrl2, resolved.pubPath, resolved.pubText);
200
+ const refresh = () => performHandshake(proxyUrl2, apiKey2, resolved.pubPath, resolved.pubText);
193
201
  let handshake;
194
202
  try {
195
203
  handshake = await refresh();