mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🔗 feat: Support Environment Variables in MCP URL Config (#7424)
This commit is contained in:
parent
55d52d07f2
commit
f8cb0cdcda
1 changed files with 13 additions and 6 deletions
|
|
@ -53,9 +53,10 @@ export const WebSocketOptionsSchema = BaseOptionsSchema.extend({
|
|||
type: z.literal('websocket').optional(),
|
||||
url: z
|
||||
.string()
|
||||
.url()
|
||||
.transform((val: string) => extractEnvVariable(val))
|
||||
.pipe(z.string().url())
|
||||
.refine(
|
||||
(val) => {
|
||||
(val: string) => {
|
||||
const protocol = new URL(val).protocol;
|
||||
return protocol === 'ws:' || protocol === 'wss:';
|
||||
},
|
||||
|
|
@ -70,9 +71,10 @@ export const SSEOptionsSchema = BaseOptionsSchema.extend({
|
|||
headers: z.record(z.string(), z.string()).optional(),
|
||||
url: z
|
||||
.string()
|
||||
.url()
|
||||
.transform((val: string) => extractEnvVariable(val))
|
||||
.pipe(z.string().url())
|
||||
.refine(
|
||||
(val) => {
|
||||
(val: string) => {
|
||||
const protocol = new URL(val).protocol;
|
||||
return protocol !== 'ws:' && protocol !== 'wss:';
|
||||
},
|
||||
|
|
@ -87,9 +89,10 @@ export const StreamableHTTPOptionsSchema = BaseOptionsSchema.extend({
|
|||
headers: z.record(z.string(), z.string()).optional(),
|
||||
url: z
|
||||
.string()
|
||||
.url()
|
||||
.transform((val: string) => extractEnvVariable(val))
|
||||
.pipe(z.string().url())
|
||||
.refine(
|
||||
(val) => {
|
||||
(val: string) => {
|
||||
const protocol = new URL(val).protocol;
|
||||
return protocol !== 'ws:' && protocol !== 'wss:';
|
||||
},
|
||||
|
|
@ -141,5 +144,9 @@ export function processMCPEnv(obj: Readonly<MCPOptions>, userId?: string): MCPOp
|
|||
newObj.headers = processedHeaders;
|
||||
}
|
||||
|
||||
if ('url' in newObj && newObj.url) {
|
||||
newObj.url = extractEnvVariable(newObj.url);
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue