File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 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 () => {
5959
6060 await client . close ( ) ;
6161} ) ;
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 {
117117 this . _serverParams . command ,
118118 this . _serverParams . args ?? [ ] ,
119119 {
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+ } ,
121125 stdio : [ "pipe" , "pipe" , this . _serverParams . stderr ?? "inherit" ] ,
122126 shell : false ,
123127 signal : this . _abortController . signal ,
You can’t perform that action at this time.
0 commit comments