fix bug of env
This commit is contained in:
parent
1a11ca64e5
commit
0f32993edb
@ -44,6 +44,9 @@ export class McpClient {
|
||||
if (!this.oauthPovider){
|
||||
this.oauthPovider = await this.oAuthClient.getOAuthProvider();
|
||||
}
|
||||
|
||||
const env = { ...process.env, ...this.options.env } as Record<string, string>;
|
||||
|
||||
// 根据连接类型创建传输层
|
||||
switch (this.options.connectionType) {
|
||||
case 'STDIO':
|
||||
@ -52,7 +55,7 @@ export class McpClient {
|
||||
args: this.options.args || [],
|
||||
cwd: this.options.cwd || process.cwd(),
|
||||
stderr: 'pipe',
|
||||
env: this.options.env,
|
||||
env
|
||||
});
|
||||
|
||||
break;
|
||||
|
@ -45,6 +45,10 @@ function getCWD(option: McpOptions) {
|
||||
// 如果是绝对路径,直接返回目录
|
||||
if (path.isAbsolute(file)) {
|
||||
// 如果是是文件,则返回文件所在的目录
|
||||
if (!fs.existsSync(file)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (fs.statSync(file).isDirectory()) {
|
||||
return file;
|
||||
} else {
|
||||
@ -53,6 +57,11 @@ function getCWD(option: McpOptions) {
|
||||
} else {
|
||||
// 如果是相对路径,根据 cwd 获取真实路径
|
||||
const absPath = path.resolve(option.cwd || process.cwd(), file);
|
||||
|
||||
if (!fs.existsSync(absPath)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 如果是是文件,则返回文件所在的目录
|
||||
if (fs.statSync(absPath).isDirectory()) {
|
||||
return absPath;
|
||||
|
Loading…
x
Reference in New Issue
Block a user