refactor(mcp): use includes http to detect streamable http type mcp server (#9865)

refactor(mcp): 简化 McpServerTypeSchema 的类型校验逻辑

将联合类型替换为字符串校验并优化 http 相关类型的转换
This commit is contained in:
Phantom 2025-09-04 11:41:26 +08:00 committed by GitHub
parent 0a36869b3c
commit 9a92372c3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: 为了兼容性