@mcp-use/client 2.0.0 → 2.0.1-canary.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
@@ -1009,6 +1009,7 @@ var init_stdio = __esm({
1009
1009
  env;
1010
1010
  cwd;
1011
1011
  errlog;
1012
+ stderr;
1012
1013
  clientInfo;
1013
1014
  protocolNegotiation;
1014
1015
  /**
@@ -1021,6 +1022,7 @@ var init_stdio = __esm({
1021
1022
  args = [],
1022
1023
  env,
1023
1024
  errlog = process2.stderr,
1025
+ stderr = "pipe",
1024
1026
  ...rest
1025
1027
  } = {}) {
1026
1028
  super(rest);
@@ -1028,6 +1030,7 @@ var init_stdio = __esm({
1028
1030
  this.args = args;
1029
1031
  this.env = env;
1030
1032
  this.errlog = errlog;
1033
+ this.stderr = stderr;
1031
1034
  this.clientInfo = rest.clientInfo ?? {
1032
1035
  name: "stdio-connector",
1033
1036
  version: "1.0.0"
@@ -1047,21 +1050,14 @@ var init_stdio = __esm({
1047
1050
  }
1048
1051
  logger.debug(`Connecting to MCP implementation via stdio: ${this.command}`);
1049
1052
  try {
1050
- let mergedEnv;
1051
- if (this.env) {
1052
- mergedEnv = {};
1053
- for (const [key, value] of Object.entries(process2.env)) {
1054
- if (value !== void 0) {
1055
- mergedEnv[key] = value;
1056
- }
1057
- }
1058
- Object.assign(mergedEnv, this.env);
1059
- }
1060
1053
  const serverParams = {
1061
1054
  command: this.command,
1062
1055
  args: this.args,
1063
- env: mergedEnv,
1064
- cwd: this.cwd
1056
+ // The SDK layers explicit values over getDefaultEnvironment(). Passing
1057
+ // the configured env through avoids exposing unrelated parent secrets.
1058
+ env: this.env,
1059
+ cwd: this.cwd,
1060
+ stderr: this.stderr
1065
1061
  };
1066
1062
  this.connectionManager = new StdioConnectionManager(
1067
1063
  serverParams,
@@ -1151,6 +1147,10 @@ var init_stdio = __esm({
1151
1147
  serverParams;
1152
1148
  errlog;
1153
1149
  _transport = null;
1150
+ _stderrSource = null;
1151
+ _onErrlogError = (error) => {
1152
+ logger.warn(`Error writing child stderr to errlog: ${error}`);
1153
+ };
1154
1154
  /**
1155
1155
  * Creates a connection manager for a local server process.
1156
1156
  *
@@ -1163,16 +1163,29 @@ var init_stdio = __esm({
1163
1163
  this.errlog = errlog;
1164
1164
  }
1165
1165
  async establishConnection() {
1166
- this._transport = new StdioClientTransport(this.serverParams);
1167
- if (this._transport.stderr && typeof this._transport.stderr.pipe === "function") {
1168
- this._transport.stderr.pipe(
1169
- this.errlog
1170
- );
1166
+ const stderr = this.serverParams.stderr ?? "pipe";
1167
+ this._transport = new StdioClientTransport({
1168
+ ...this.serverParams,
1169
+ stderr
1170
+ });
1171
+ const childStderr = this._transport.stderr;
1172
+ if (stderr === "pipe" && childStderr && "pipe" in childStderr) {
1173
+ this._stderrSource = childStderr;
1174
+ this._stderrSource.on("error", (error) => {
1175
+ logger.warn(`Error forwarding child stderr: ${error}`);
1176
+ });
1177
+ this.errlog.on("error", this._onErrlogError);
1178
+ this._stderrSource.pipe(this.errlog, { end: false });
1171
1179
  }
1172
1180
  logger.debug(`${this.constructor.name} connected successfully`);
1173
1181
  return this._transport;
1174
1182
  }
1175
1183
  async closeConnection(_connection) {
1184
+ if (this._stderrSource) {
1185
+ this._stderrSource.unpipe(this.errlog);
1186
+ this.errlog.off("error", this._onErrlogError);
1187
+ this._stderrSource = null;
1188
+ }
1176
1189
  if (this._transport) {
1177
1190
  try {
1178
1191
  await this._transport.close();
@@ -1206,7 +1219,7 @@ init_connector_telemetry();
1206
1219
  init_logging();
1207
1220
 
1208
1221
  // src/utils/version.ts
1209
- var VERSION = "2.0.0";
1222
+ var VERSION = "2.0.1-canary.1";
1210
1223
  function getPackageVersion() {
1211
1224
  return VERSION;
1212
1225
  }
@@ -5493,6 +5506,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
5493
5506
  args: stdioConfig.args,
5494
5507
  env: stdioConfig.env,
5495
5508
  cwd: stdioConfig.cwd,
5509
+ ...stdioConfig.stderr !== void 0 && { stderr: stdioConfig.stderr },
5496
5510
  protocolNegotiation: stdioConfig.protocolNegotiation,
5497
5511
  clientInfo: normalizeClientInfo(merged.clientInfo),
5498
5512
  roots: stdioConfig.roots,