fix: type

This commit is contained in:
Neko Ayaka
2025-05-11 17:05:46 +08:00
parent c399879a08
commit fc7a98351c
+10 -14
View File
@@ -10,11 +10,10 @@ const tools = [
return await listTools()
},
parameters: z.object({}),
returns: z.object({}),
}),
tool({
name: 'mcp_connect_server',
description: 'Connect to the MCP server',
description: 'Connect to the MCP server. If "success", the connection to the MCP server is successful. Otherwise, the connection fails.',
execute: async ({ command, args }) => {
await connectServer(command, args)
return 'success'
@@ -23,25 +22,29 @@ const tools = [
command: z.string().describe('The command to connect to the MCP server'),
args: z.array(z.string()).describe('The arguments to pass to the MCP server'),
}),
returns: z.string().describe('If "success", the connection to the MCP server is successful. Otherwise, the connection fails.'),
}),
tool({
name: 'mcp_disconnect_server',
description: 'Disconnect from the MCP server',
description: 'Disconnect from the MCP server. If "success", the disconnection from the MCP server is successful. Otherwise, the disconnection fails.',
execute: async () => {
await disconnectServer()
return 'success'
},
parameters: z.object({}),
returns: z.string().describe('If "success", the connection to the MCP server is successful. Otherwise, the connection fails.'),
}),
tool({
name: 'mcp_call_tool',
description: 'Call a tool on the MCP server',
description: 'Call a tool on the MCP server. The result is a list of content and a boolean indicating whether the tool call is an error.',
execute: async ({ name, parameters }) => {
const parametersObject = Object.fromEntries(parameters.map(({ name, value }) => [name, value]))
const result = await callTool(name, parametersObject)
return result
return result satisfies {
content: {
type: string
text: string
}[]
isError: boolean
}
},
parameters: z.object({
name: z.string().describe('The name of the tool to call'),
@@ -50,13 +53,6 @@ const tools = [
value: z.any().describe('The value of the parameter'),
})).describe('The parameters to pass to the tool'),
}),
returns: z.object({
content: z.array(z.object({
type: z.string().describe('The type of the content'),
text: z.string().describe('The text of the content'),
})).describe('The content of the tool call result'),
isError: z.boolean().describe('Whether the tool call is an error'),
}).describe('The result of the tool call'),
}),
]