mcp-remote 0.1.28 → 0.1.30

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
@@ -72,6 +72,37 @@ To bypass authentication, or to emit custom headers on all requests to your remo
72
72
  },
73
73
  ```
74
74
 
75
+ ### Multiple Instances
76
+
77
+ To run multiple instances of the same remote server with different configurations (e.g., different Atlassian tenants), use the `--resource` flag to isolate OAuth sessions:
78
+
79
+ ```json
80
+ {
81
+ "mcpServers": {
82
+ "atlassian_tenant1": {
83
+ "command": "npx",
84
+ "args": [
85
+ "mcp-remote",
86
+ "https://mcp.atlassian.com/v1/sse",
87
+ "--resource",
88
+ "https://tenant1.atlassian.net/"
89
+ ]
90
+ },
91
+ "atlassian_tenant2": {
92
+ "command": "npx",
93
+ "args": [
94
+ "mcp-remote",
95
+ "https://mcp.atlassian.com/v1/sse",
96
+ "--resource",
97
+ "https://tenant2.atlassian.net/"
98
+ ]
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ Each unique combination of server URL, resource, and custom headers will maintain separate OAuth sessions and token storage.
105
+
75
106
  ### Flags
76
107
 
77
108
  * If `npx` is producing errors, consider adding `-y` as the first argument to auto-accept the installation of the `mcp-remote` package.
@@ -11872,7 +11872,7 @@ var Client = class extends Protocol {
11872
11872
  };
11873
11873
 
11874
11874
  // package.json
11875
- var version = "0.1.28";
11875
+ var version = "0.1.30";
11876
11876
 
11877
11877
  // node_modules/.pnpm/pkce-challenge@5.0.0/node_modules/pkce-challenge/dist/index.node.js
11878
11878
  var crypto;
@@ -13645,7 +13645,7 @@ import crypto2 from "crypto";
13645
13645
  import fs2 from "fs";
13646
13646
  import { readFile, rm } from "fs/promises";
13647
13647
  import path2 from "path";
13648
- import { fetch as fetch2, setGlobalDispatcher, EnvHttpProxyAgent } from "undici";
13648
+ import { EnvHttpProxyAgent, fetch as fetch2, Headers as Headers2, setGlobalDispatcher } from "undici";
13649
13649
  var REASON_AUTH_NEEDED = "authentication-needed";
13650
13650
  var REASON_TRANSPORT_FALLBACK = "falling-back-to-alternate-transport";
13651
13651
  var pid = process.pid;
@@ -13808,7 +13808,7 @@ async function connectToRemoteServer(client, serverUrl, authProvider, headers, a
13808
13808
  (tokens) => fetch2(url2, {
13809
13809
  ...init,
13810
13810
  headers: {
13811
- ...init?.headers,
13811
+ ...init?.headers instanceof Headers2 ? Object.fromEntries(init?.headers.entries()) : init?.headers || {},
13812
13812
  ...headers,
13813
13813
  ...tokens?.access_token ? { Authorization: `Bearer ${tokens.access_token}` } : {},
13814
13814
  Accept: "text/event-stream"
@@ -14136,7 +14136,7 @@ async function parseCommandLineArgs(args, usage) {
14136
14136
  log(usage);
14137
14137
  process.exit(1);
14138
14138
  }
14139
- const serverUrlHash = getServerUrlHash(serverUrl);
14139
+ const serverUrlHash = getServerUrlHash(serverUrl, authorizeResource, headers);
14140
14140
  global.currentServerUrlHash = serverUrlHash;
14141
14141
  debugLog(`Starting mcp-remote with server URL: ${serverUrl}`);
14142
14142
  const defaultPort = calculateDefaultPort(serverUrlHash);
@@ -14184,7 +14184,8 @@ async function parseCommandLineArgs(args, usage) {
14184
14184
  staticOAuthClientInfo,
14185
14185
  authorizeResource,
14186
14186
  ignoredTools,
14187
- authTimeoutMs
14187
+ authTimeoutMs,
14188
+ serverUrlHash
14188
14189
  };
14189
14190
  }
14190
14191
  function setupSignalHandlers(cleanup) {
@@ -14200,8 +14201,14 @@ function setupSignalHandlers(cleanup) {
14200
14201
  process.exit(0);
14201
14202
  });
14202
14203
  }
14203
- function getServerUrlHash(serverUrl) {
14204
- return crypto2.createHash("md5").update(serverUrl).digest("hex");
14204
+ function getServerUrlHash(serverUrl, authorizeResource, headers) {
14205
+ const parts = [serverUrl];
14206
+ if (authorizeResource) parts.push(authorizeResource);
14207
+ if (headers && Object.keys(headers).length > 0) {
14208
+ const sortedKeys = Object.keys(headers).sort();
14209
+ parts.push(JSON.stringify(headers, sortedKeys));
14210
+ }
14211
+ return crypto2.createHash("md5").update(parts.join("|")).digest("hex");
14205
14212
  }
14206
14213
  function patternToRegex(pattern) {
14207
14214
  const parts = pattern.split("*");
@@ -14233,7 +14240,7 @@ var NodeOAuthClientProvider = class {
14233
14240
  */
14234
14241
  constructor(options) {
14235
14242
  this.options = options;
14236
- this.serverUrlHash = getServerUrlHash(options.serverUrl);
14243
+ this.serverUrlHash = options.serverUrlHash;
14237
14244
  this.callbackPath = options.callbackPath || "/oauth/callback";
14238
14245
  this.clientName = options.clientName || "MCP CLI Client";
14239
14246
  this.clientUri = options.clientUri || "https://github.com/modelcontextprotocol/mcp-cli";
@@ -14612,7 +14619,6 @@ export {
14612
14619
  connectToRemoteServer,
14613
14620
  parseCommandLineArgs,
14614
14621
  setupSignalHandlers,
14615
- getServerUrlHash,
14616
14622
  NodeOAuthClientProvider,
14617
14623
  createLazyAuthCoordinator
14618
14624
  };
package/dist/client.js CHANGED
@@ -6,18 +6,16 @@ import {
6
6
  NodeOAuthClientProvider,
7
7
  connectToRemoteServer,
8
8
  createLazyAuthCoordinator,
9
- getServerUrlHash,
10
9
  log,
11
10
  parseCommandLineArgs,
12
11
  setupSignalHandlers,
13
12
  version
14
- } from "./chunk-RXOQMFC5.js";
13
+ } from "./chunk-RGTAVJIZ.js";
15
14
 
16
15
  // src/client.ts
17
16
  import { EventEmitter } from "events";
18
- async function runClient(serverUrl, callbackPort, headers, transportStrategy = "http-first", host, staticOAuthClientMetadata, staticOAuthClientInfo, authTimeoutMs) {
17
+ async function runClient(serverUrl, callbackPort, headers, transportStrategy = "http-first", host, staticOAuthClientMetadata, staticOAuthClientInfo, authTimeoutMs, serverUrlHash) {
19
18
  const events = new EventEmitter();
20
- const serverUrlHash = getServerUrlHash(serverUrl);
21
19
  const authCoordinator = createLazyAuthCoordinator(serverUrlHash, callbackPort, events, authTimeoutMs);
22
20
  const authProvider = new NodeOAuthClientProvider({
23
21
  serverUrl,
@@ -25,7 +23,8 @@ async function runClient(serverUrl, callbackPort, headers, transportStrategy = "
25
23
  host,
26
24
  clientName: "MCP CLI Client",
27
25
  staticOAuthClientMetadata,
28
- staticOAuthClientInfo
26
+ staticOAuthClientInfo,
27
+ serverUrlHash
29
28
  });
30
29
  const client = new Client(
31
30
  {
@@ -98,7 +97,17 @@ async function runClient(serverUrl, callbackPort, headers, transportStrategy = "
98
97
  }
99
98
  }
100
99
  parseCommandLineArgs(process.argv.slice(2), "Usage: npx tsx client.ts <https://server-url> [callback-port] [--debug]").then(
101
- ({ serverUrl, callbackPort, headers, transportStrategy, host, staticOAuthClientMetadata, staticOAuthClientInfo, authTimeoutMs }) => {
100
+ ({
101
+ serverUrl,
102
+ callbackPort,
103
+ headers,
104
+ transportStrategy,
105
+ host,
106
+ staticOAuthClientMetadata,
107
+ staticOAuthClientInfo,
108
+ authTimeoutMs,
109
+ serverUrlHash
110
+ }) => {
102
111
  return runClient(
103
112
  serverUrl,
104
113
  callbackPort,
@@ -107,7 +116,8 @@ parseCommandLineArgs(process.argv.slice(2), "Usage: npx tsx client.ts <https://s
107
116
  host,
108
117
  staticOAuthClientMetadata,
109
118
  staticOAuthClientInfo,
110
- authTimeoutMs
119
+ authTimeoutMs,
120
+ serverUrlHash
111
121
  );
112
122
  }
113
123
  ).catch((error) => {
package/dist/proxy.js CHANGED
@@ -4,12 +4,11 @@ import {
4
4
  NodeOAuthClientProvider,
5
5
  connectToRemoteServer,
6
6
  createLazyAuthCoordinator,
7
- getServerUrlHash,
8
7
  log,
9
8
  mcpProxy,
10
9
  parseCommandLineArgs,
11
10
  setupSignalHandlers
12
- } from "./chunk-RXOQMFC5.js";
11
+ } from "./chunk-RGTAVJIZ.js";
13
12
 
14
13
  // src/proxy.ts
15
14
  import { EventEmitter } from "events";
@@ -110,9 +109,8 @@ var StdioServerTransport = class {
110
109
  };
111
110
 
112
111
  // src/proxy.ts
113
- async function runProxy(serverUrl, callbackPort, headers, transportStrategy = "http-first", host, staticOAuthClientMetadata, staticOAuthClientInfo, authorizeResource, ignoredTools, authTimeoutMs) {
112
+ async function runProxy(serverUrl, callbackPort, headers, transportStrategy = "http-first", host, staticOAuthClientMetadata, staticOAuthClientInfo, authorizeResource, ignoredTools, authTimeoutMs, serverUrlHash) {
114
113
  const events = new EventEmitter();
115
- const serverUrlHash = getServerUrlHash(serverUrl);
116
114
  const authCoordinator = createLazyAuthCoordinator(serverUrlHash, callbackPort, events, authTimeoutMs);
117
115
  const authProvider = new NodeOAuthClientProvider({
118
116
  serverUrl,
@@ -121,7 +119,8 @@ async function runProxy(serverUrl, callbackPort, headers, transportStrategy = "h
121
119
  clientName: "MCP CLI Proxy",
122
120
  staticOAuthClientMetadata,
123
121
  staticOAuthClientInfo,
124
- authorizeResource
122
+ authorizeResource,
123
+ serverUrlHash
125
124
  });
126
125
  const localTransport = new StdioServerTransport();
127
126
  let server = null;
@@ -198,7 +197,8 @@ parseCommandLineArgs(process.argv.slice(2), "Usage: npx tsx proxy.ts <https://se
198
197
  staticOAuthClientInfo,
199
198
  authorizeResource,
200
199
  ignoredTools,
201
- authTimeoutMs
200
+ authTimeoutMs,
201
+ serverUrlHash
202
202
  }) => {
203
203
  return runProxy(
204
204
  serverUrl,
@@ -210,7 +210,8 @@ parseCommandLineArgs(process.argv.slice(2), "Usage: npx tsx proxy.ts <https://se
210
210
  staticOAuthClientInfo,
211
211
  authorizeResource,
212
212
  ignoredTools,
213
- authTimeoutMs
213
+ authTimeoutMs,
214
+ serverUrlHash
214
215
  );
215
216
  }
216
217
  ).catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-remote",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
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",
@@ -59,12 +59,5 @@
59
59
  "outDir": "dist",
60
60
  "external": []
61
61
  },
62
- "vitest": {
63
- "environment": "node",
64
- "globals": true,
65
- "include": [
66
- "src/**/*.test.ts"
67
- ]
68
- },
69
62
  "packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
70
63
  }