mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 11:44:28 +08:00
refactor(mcp): use includes http to detect streamable http type mcp server (#9865)
refactor(mcp): 简化 McpServerTypeSchema 的类型校验逻辑 将联合类型替换为字符串校验并优化 http 相关类型的转换
This commit is contained in:
parent
0a36869b3c
commit
9a92372c3e
@ -16,22 +16,18 @@ export type MCPConfigSample = z.infer<typeof MCPConfigSampleSchema>
|
||||
* 允许 inMemory 作为合法字段,需要额外校验 name 是否 builtin
|
||||
*/
|
||||
export const McpServerTypeSchema = z
|
||||
.union([
|
||||
z.literal('stdio'),
|
||||
z.literal('sse'),
|
||||
z.literal('streamableHttp'),
|
||||
z.literal('http'),
|
||||
z.literal('streamable_http'),
|
||||
z.literal('inMemory')
|
||||
])
|
||||
.string()
|
||||
.transform((type) => {
|
||||
if (type === 'streamable_http' || type === 'http') {
|
||||
if (type.includes('http')) {
|
||||
return 'streamableHttp'
|
||||
} else {
|
||||
return type
|
||||
}
|
||||
})
|
||||
.default('stdio') // 大多数情况下默认使用 stdio
|
||||
.pipe(
|
||||
z.union([z.literal('stdio'), z.literal('sse'), z.literal('streamableHttp'), z.literal('inMemory')]).default('stdio') // 大多数情况下默认使用 stdio
|
||||
)
|
||||
|
||||
/**
|
||||
* 定义单个 MCP 服务器的配置。
|
||||
* FIXME: 为了兼容性,暂时允许用户编辑任意字段,这可能会导致问题。
|
||||
|
||||
Loading…
Reference in New Issue
Block a user