mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 14:59:27 +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
8eb0be7562
commit
795d12c91e
@ -91,7 +91,7 @@ class McpService {
|
|||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
baseUrl: server.baseUrl,
|
baseUrl: server.baseUrl,
|
||||||
command: server.command,
|
command: server.command,
|
||||||
args: server.args,
|
args: Array.isArray(server.args) ? server.args : [],
|
||||||
registryUrl: server.registryUrl,
|
registryUrl: server.registryUrl,
|
||||||
env: server.env,
|
env: server.env,
|
||||||
id: server.id
|
id: server.id
|
||||||
@ -567,12 +567,11 @@ class McpService {
|
|||||||
try {
|
try {
|
||||||
const result = await client.listResources()
|
const result = await client.listResources()
|
||||||
const resources = result.resources || []
|
const resources = result.resources || []
|
||||||
const serverResources = (Array.isArray(resources) ? resources : []).map((resource: any) => ({
|
return (Array.isArray(resources) ? resources : []).map((resource: any) => ({
|
||||||
...resource,
|
...resource,
|
||||||
serverId: server.id,
|
serverId: server.id,
|
||||||
serverName: server.name
|
serverName: server.name
|
||||||
}))
|
}))
|
||||||
return serverResources
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// -32601 is the code for the method not found
|
// -32601 is the code for the method not found
|
||||||
if (error?.code !== -32601) {
|
if (error?.code !== -32601) {
|
||||||
|
|||||||
@ -95,7 +95,7 @@ const AddMcpServerModal: FC<AddMcpServerModalProps> = ({ visible, onClose, onSuc
|
|||||||
description: serverToAdd!.description ?? '',
|
description: serverToAdd!.description ?? '',
|
||||||
baseUrl: serverToAdd!.baseUrl ?? serverToAdd!.url ?? '',
|
baseUrl: serverToAdd!.baseUrl ?? serverToAdd!.url ?? '',
|
||||||
command: serverToAdd!.command ?? '',
|
command: serverToAdd!.command ?? '',
|
||||||
args: serverToAdd!.args || [],
|
args: Array.isArray(serverToAdd!.args) ? serverToAdd!.args : [],
|
||||||
env: serverToAdd!.env || {},
|
env: serverToAdd!.env || {},
|
||||||
isActive: false,
|
isActive: false,
|
||||||
type: serverToAdd!.type,
|
type: serverToAdd!.type,
|
||||||
@ -236,7 +236,6 @@ const parseAndExtractServer = (
|
|||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
typeof parsedJson === 'object' &&
|
typeof parsedJson === 'object' &&
|
||||||
parsedJson !== null &&
|
|
||||||
!Array.isArray(parsedJson) &&
|
!Array.isArray(parsedJson) &&
|
||||||
!parsedJson.mcpServers // 確保是直接的伺服器物件
|
!parsedJson.mcpServers // 確保是直接的伺服器物件
|
||||||
) {
|
) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user