File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -59,3 +59,33 @@ test("should read messages", async () => {
59
59
60
60
await client . close ( ) ;
61
61
} ) ;
62
+
63
+ test ( "should work with actual node mcp server" , async ( ) => {
64
+ const client = new StdioClientTransport ( {
65
+ command : "npx" ,
66
+ args : [ "-y" , "@wrtnlabs/calculator-mcp" ] ,
67
+ } ) ;
68
+
69
+ await client . start ( ) ;
70
+ await client . close ( ) ;
71
+ } ) ;
72
+
73
+ test ( "should work with actual node mcp server and empty env" , async ( ) => {
74
+ const client = new StdioClientTransport ( {
75
+ command : "npx" ,
76
+ args : [ "-y" , "@wrtnlabs/calculator-mcp" ] ,
77
+ env : { } ,
78
+ } ) ;
79
+ await client . start ( ) ;
80
+ await client . close ( ) ;
81
+ } ) ;
82
+
83
+ test ( "should work with actual node mcp server and custom env" , async ( ) => {
84
+ const client = new StdioClientTransport ( {
85
+ command : "npx" ,
86
+ args : [ "-y" , "@wrtnlabs/calculator-mcp" ] ,
87
+ env : { TEST_VAR : "test-value" } ,
88
+ } ) ;
89
+ await client . start ( ) ;
90
+ await client . close ( ) ;
91
+ } ) ;
Original file line number Diff line number Diff line change @@ -117,7 +117,11 @@ export class StdioClientTransport implements Transport {
117
117
this . _serverParams . command ,
118
118
this . _serverParams . args ?? [ ] ,
119
119
{
120
- env : this . _serverParams . env ?? getDefaultEnvironment ( ) ,
120
+ // merge default env with server env because mcp server needs some env vars
121
+ env : {
122
+ ...getDefaultEnvironment ( ) ,
123
+ ...this . _serverParams . env ,
124
+ } ,
121
125
stdio : [ "pipe" , "pipe" , this . _serverParams . stderr ?? "inherit" ] ,
122
126
shell : false ,
123
127
signal : this . _abortController . signal ,
You can’t perform that action at this time.
0 commit comments