@@ -53,9 +53,10 @@ export const WebSocketOptionsSchema = BaseOptionsSchema.extend({
53
53
type : z . literal ( 'websocket' ) . optional ( ) ,
54
54
url : z
55
55
. string ( )
56
- . url ( )
56
+ . transform ( ( val : string ) => extractEnvVariable ( val ) )
57
+ . pipe ( z . string ( ) . url ( ) )
57
58
. refine (
58
- ( val ) => {
59
+ ( val : string ) => {
59
60
const protocol = new URL ( val ) . protocol ;
60
61
return protocol === 'ws:' || protocol === 'wss:' ;
61
62
} ,
@@ -70,9 +71,10 @@ export const SSEOptionsSchema = BaseOptionsSchema.extend({
70
71
headers : z . record ( z . string ( ) , z . string ( ) ) . optional ( ) ,
71
72
url : z
72
73
. string ( )
73
- . url ( )
74
+ . transform ( ( val : string ) => extractEnvVariable ( val ) )
75
+ . pipe ( z . string ( ) . url ( ) )
74
76
. refine (
75
- ( val ) => {
77
+ ( val : string ) => {
76
78
const protocol = new URL ( val ) . protocol ;
77
79
return protocol !== 'ws:' && protocol !== 'wss:' ;
78
80
} ,
@@ -87,9 +89,10 @@ export const StreamableHTTPOptionsSchema = BaseOptionsSchema.extend({
87
89
headers : z . record ( z . string ( ) , z . string ( ) ) . optional ( ) ,
88
90
url : z
89
91
. string ( )
90
- . url ( )
92
+ . transform ( ( val : string ) => extractEnvVariable ( val ) )
93
+ . pipe ( z . string ( ) . url ( ) )
91
94
. refine (
92
- ( val ) => {
95
+ ( val : string ) => {
93
96
const protocol = new URL ( val ) . protocol ;
94
97
return protocol !== 'ws:' && protocol !== 'wss:' ;
95
98
} ,
@@ -141,5 +144,9 @@ export function processMCPEnv(obj: Readonly<MCPOptions>, userId?: string): MCPOp
141
144
newObj . headers = processedHeaders ;
142
145
}
143
146
147
+ if ( 'url' in newObj && newObj . url ) {
148
+ newObj . url = extractEnvVariable ( newObj . url ) ;
149
+ }
150
+
144
151
return newObj ;
145
152
}
0 commit comments