From dffcaa11c3eebbeeb3032e841f144cd0ec210f90 Mon Sep 17 00:00:00 2001 From: Vaayne Date: Wed, 19 Mar 2025 22:28:13 +0800 Subject: [PATCH] fix: correct typo in properties variable and add null check --- src/renderer/src/utils/mcp-tools.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/utils/mcp-tools.ts b/src/renderer/src/utils/mcp-tools.ts index e2ea124f..04c7992f 100644 --- a/src/renderer/src/utils/mcp-tools.ts +++ b/src/renderer/src/utils/mcp-tools.ts @@ -18,7 +18,10 @@ const supportedAttributes = [ ] function filterPropertieAttributes(tool: MCPTool, filterNestedObj = false) { - const roperties = tool.inputSchema.properties + const properties = tool.inputSchema.properties + if (!properties) { + return {} + } const getSubMap = (obj: Record, keys: string[]) => { const filtered = Object.fromEntries(Object.entries(obj).filter(([key]) => keys.includes(key))) @@ -46,10 +49,10 @@ function filterPropertieAttributes(tool: MCPTool, filterNestedObj = false) { return filtered } - for (const [key, val] of Object.entries(roperties)) { - roperties[key] = getSubMap(val, supportedAttributes) + for (const [key, val] of Object.entries(properties)) { + properties[key] = getSubMap(val, supportedAttributes) } - return roperties + return properties } export function mcpToolsToOpenAITools(mcpTools: MCPTool[]): Array {