feat(MCPSettings): enhance JSON loading to inherit all MCPServer fields (#8498)

Use spread operator to copy all fields from parsed JSON instead of manually
mapping specific fields. This ensures all MCPServer properties including
headers, timeout, dxtVersion, and other optional fields are preserved during
JSON import.

Previously missing fields:
- headers: Record<string, string>
- timeout: number
- dxtVersion: string
- dxtPath: string
- Other optional MCPServer properties

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
LiuVaayne 2025-07-25 16:56:43 +08:00 committed by GitHub
parent 03b996d626
commit 20438989f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -216,19 +216,10 @@ const AddMcpServerModal: FC<AddMcpServerModalProps> = ({
// 如果成功解析並通過所有檢查,立即加入伺服器(非啟用狀態)並關閉對話框
const newServer: MCPServer = {
id: nanoid(),
name: serverToAdd!.name!,
description: serverToAdd!.description ?? '',
...serverToAdd!,
name: serverToAdd!.name || t('settings.mcp.newServer'),
baseUrl: serverToAdd!.baseUrl ?? serverToAdd!.url ?? '',
command: serverToAdd!.command ?? '',
args: Array.isArray(serverToAdd!.args) ? serverToAdd!.args : [],
env: serverToAdd!.env || {},
isActive: false,
type: serverToAdd!.type,
logoUrl: serverToAdd!.logoUrl,
provider: serverToAdd!.provider,
providerUrl: serverToAdd!.providerUrl,
tags: serverToAdd!.tags,
configSample: serverToAdd!.configSample
isActive: false // 初始狀態為非啟用
}
onSuccess(newServer)