mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
fix: ensure args are an array in AddMcpServerModal and MCPService com… (#6413)
fix: ensure args are an array in AddMcpServerModal and MCPService components
This commit is contained in:
parent
16ea4cbdec
commit
9428461fb7
@ -91,7 +91,7 @@ class McpService {
|
||||
return JSON.stringify({
|
||||
baseUrl: server.baseUrl,
|
||||
command: server.command,
|
||||
args: server.args,
|
||||
args: Array.isArray(server.args) ? server.args : [],
|
||||
registryUrl: server.registryUrl,
|
||||
env: server.env,
|
||||
id: server.id
|
||||
@ -567,12 +567,11 @@ class McpService {
|
||||
try {
|
||||
const result = await client.listResources()
|
||||
const resources = result.resources || []
|
||||
const serverResources = (Array.isArray(resources) ? resources : []).map((resource: any) => ({
|
||||
return (Array.isArray(resources) ? resources : []).map((resource: any) => ({
|
||||
...resource,
|
||||
serverId: server.id,
|
||||
serverName: server.name
|
||||
}))
|
||||
return serverResources
|
||||
} catch (error: any) {
|
||||
// -32601 is the code for the method not found
|
||||
if (error?.code !== -32601) {
|
||||
|
||||
@ -95,7 +95,7 @@ const AddMcpServerModal: FC<AddMcpServerModalProps> = ({ visible, onClose, onSuc
|
||||
description: serverToAdd!.description ?? '',
|
||||
baseUrl: serverToAdd!.baseUrl ?? serverToAdd!.url ?? '',
|
||||
command: serverToAdd!.command ?? '',
|
||||
args: serverToAdd!.args || [],
|
||||
args: Array.isArray(serverToAdd!.args) ? serverToAdd!.args : [],
|
||||
env: serverToAdd!.env || {},
|
||||
isActive: false,
|
||||
type: serverToAdd!.type,
|
||||
@ -236,7 +236,6 @@ const parseAndExtractServer = (
|
||||
}
|
||||
} else if (
|
||||
typeof parsedJson === 'object' &&
|
||||
parsedJson !== null &&
|
||||
!Array.isArray(parsedJson) &&
|
||||
!parsedJson.mcpServers // 確保是直接的伺服器物件
|
||||
) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user