mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-23 06:04:46 +08:00
feat: implement MCP UIs
This commit is contained in:
57
web/src/core/mcp/schema.ts
Normal file
57
web/src/core/mcp/schema.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
export const MCPConfigSchema = z.object({
|
||||
mcpServers: z.record(
|
||||
z.union(
|
||||
[
|
||||
z.object({
|
||||
command: z.string({
|
||||
message: "`command` must be a string",
|
||||
}),
|
||||
args: z
|
||||
.array(z.string(), {
|
||||
message: "`args` must be an array of strings",
|
||||
})
|
||||
.optional(),
|
||||
env: z
|
||||
.record(z.string(), {
|
||||
message: "`env` must be an object of key-value pairs",
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
z.object({
|
||||
url: z
|
||||
.string({
|
||||
message:
|
||||
"`url` must be a valid URL starting with http:// or https://",
|
||||
})
|
||||
.refine(
|
||||
(value) => {
|
||||
try {
|
||||
const url = new URL(value);
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
{
|
||||
message:
|
||||
"`url` must be a valid URL starting with http:// or https://",
|
||||
},
|
||||
),
|
||||
env: z
|
||||
.record(z.string(), {
|
||||
message: "`env` must be an object of key-value pairs",
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
],
|
||||
{
|
||||
message: "Invalid server type",
|
||||
},
|
||||
),
|
||||
),
|
||||
});
|
||||
Reference in New Issue
Block a user