align-mcp-remote 0.1.40 → 0.1.42

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.
@@ -15632,7 +15632,7 @@ var Client = class extends Protocol {
15632
15632
  };
15633
15633
 
15634
15634
  // package.json
15635
- var version2 = "0.1.39";
15635
+ var version2 = "0.1.41";
15636
15636
 
15637
15637
  // node_modules/pkce-challenge/dist/index.node.js
15638
15638
  var crypto;
@@ -18113,9 +18113,24 @@ async function performDownstreamAuth(authProvider, downstreamResource, callbackP
18113
18113
  const host = authProvider.options.host || "localhost";
18114
18114
  const redirectUrl = `http://${host}:${downstreamCallbackPort}/oauth/callback`;
18115
18115
  const scope = downstreamResource.scopes_required?.join(" ") ?? "";
18116
+ const downstreamClientMetadata = {
18117
+ redirect_uris: [redirectUrl],
18118
+ token_endpoint_auth_method: "none",
18119
+ grant_types: ["authorization_code", "refresh_token"],
18120
+ response_types: ["code"],
18121
+ client_name: authProvider.options.clientName || "MCP CLI Client",
18122
+ scope
18123
+ };
18124
+ const downstreamClientInfo = await registerClient(downstreamAs, {
18125
+ metadata: downstreamServerMetadata,
18126
+ clientMetadata: downstreamClientMetadata
18127
+ });
18128
+ debugLog("Registered downstream client", { client_id: downstreamClientInfo.client_id });
18129
+ const downstreamHash = crypto2.createHash("md5").update(downstreamAs).digest("hex");
18130
+ await writeJsonFile(downstreamHash, "downstream_client_info.json", downstreamClientInfo);
18116
18131
  const { authorizationUrl, codeVerifier } = await startAuthorization(downstreamAs, {
18117
18132
  metadata: downstreamServerMetadata,
18118
- clientInformation: await authProvider.clientInformation(),
18133
+ clientInformation: downstreamClientInfo,
18119
18134
  redirectUrl,
18120
18135
  scope,
18121
18136
  resource: new URL(downstreamResource.resource)
@@ -18135,7 +18150,7 @@ ${authorizationUrl.toString()}
18135
18150
  const code = await waitForDownstreamCode();
18136
18151
  const tokens = await exchangeAuthorization(downstreamAs, {
18137
18152
  metadata: downstreamServerMetadata,
18138
- clientInformation: await authProvider.clientInformation(),
18153
+ clientInformation: downstreamClientInfo,
18139
18154
  authorizationCode: code,
18140
18155
  codeVerifier,
18141
18156
  redirectUri: redirectUrl
@@ -18161,14 +18176,14 @@ async function connectToRemoteServer(client, serverUrl, authProvider, headers, a
18161
18176
  };
18162
18177
  const eventSourceInit = {
18163
18178
  fetch: async (url3, init) => {
18164
- const [tokens, downstreamHeader2] = await Promise.all([authProvider?.tokens?.(), resolveDownstreamHeader()]);
18179
+ const [tokens, downstreamHeader] = await Promise.all([authProvider?.tokens?.(), resolveDownstreamHeader()]);
18165
18180
  return fetch2(url3, {
18166
18181
  ...init,
18167
18182
  headers: {
18168
18183
  ...init?.headers instanceof Headers2 ? Object.fromEntries(init?.headers.entries()) : init?.headers || {},
18169
18184
  ...headers,
18170
18185
  ...tokens?.access_token ? { Authorization: `Bearer ${tokens.access_token}` } : {},
18171
- ...downstreamHeader2,
18186
+ ...downstreamHeader,
18172
18187
  Accept: "text/event-stream"
18173
18188
  }
18174
18189
  });
@@ -18177,15 +18192,22 @@ async function connectToRemoteServer(client, serverUrl, authProvider, headers, a
18177
18192
  log(`Using transport strategy: ${transportStrategy}`);
18178
18193
  const shouldAttemptFallback2 = transportStrategy === "http-first" || transportStrategy === "sse-first";
18179
18194
  const sseTransport = transportStrategy === "sse-only" || transportStrategy === "sse-first";
18180
- const downstreamHeader = await resolveDownstreamHeader();
18181
- const mergedHeaders = { ...headers, ...downstreamHeader };
18195
+ const fetchWithDownstreamHeader = async (input, init) => {
18196
+ const downstreamHeader = await resolveDownstreamHeader();
18197
+ const existingHeaders = init?.headers instanceof Headers2 ? Object.fromEntries(init.headers.entries()) : init?.headers || {};
18198
+ return fetch2(input, {
18199
+ ...init,
18200
+ headers: { ...existingHeaders, ...headers, ...downstreamHeader }
18201
+ });
18202
+ };
18182
18203
  const transport = sseTransport ? new SSEClientTransport(url2, {
18183
18204
  authProvider,
18184
- requestInit: { headers: mergedHeaders },
18205
+ requestInit: { headers },
18185
18206
  eventSourceInit
18186
18207
  }) : new StreamableHTTPClientTransport(url2, {
18187
18208
  authProvider,
18188
- requestInit: { headers: mergedHeaders }
18209
+ requestInit: { headers },
18210
+ fetch: fetchWithDownstreamHeader
18189
18211
  });
18190
18212
  try {
18191
18213
  debugLog("Attempting to connect to remote server", { sseTransport });
package/dist/client.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  performDownstreamAuth,
14
14
  setupSignalHandlers,
15
15
  version
16
- } from "./chunk-X7AWYUMO.js";
16
+ } from "./chunk-KAPZFZKG.js";
17
17
 
18
18
  // src/client.ts
19
19
  import { EventEmitter } from "events";
package/dist/proxy.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  parseCommandLineArgs,
12
12
  performDownstreamAuth,
13
13
  setupSignalHandlers
14
- } from "./chunk-X7AWYUMO.js";
14
+ } from "./chunk-KAPZFZKG.js";
15
15
 
16
16
  // src/proxy.ts
17
17
  import { EventEmitter } from "events";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "align-mcp-remote",
3
- "version": "0.1.40",
3
+ "version": "0.1.42",
4
4
  "description": "Remote proxy for Model Context Protocol, allowing local-only clients to connect to remote servers using oAuth",
5
5
  "keywords": [
6
6
  "mcp",