mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
fix(mcp): added backfill effect to add missing descriptions for mcp tools (#2290)
This commit is contained in:
@@ -10,6 +10,7 @@ const IconComponent = ({ icon: Icon, className }: { icon: any; className?: strin
|
|||||||
interface McpTool {
|
interface McpTool {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
|
description?: string
|
||||||
serverId: string
|
serverId: string
|
||||||
serverName: string
|
serverName: string
|
||||||
icon: React.ComponentType<any>
|
icon: React.ComponentType<any>
|
||||||
@@ -76,7 +77,10 @@ export function McpToolsList({
|
|||||||
},
|
},
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
usageControl: 'auto',
|
usageControl: 'auto',
|
||||||
schema: mcpTool.inputSchema,
|
schema: {
|
||||||
|
...mcpTool.inputSchema,
|
||||||
|
description: mcpTool.description,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
onToolSelect(newTool)
|
onToolSelect(newTool)
|
||||||
|
|||||||
@@ -858,16 +858,22 @@ export function ToolInput({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const mcpToolsNeedingSchema = selectedTools.filter(
|
// Find MCP tools that need schema or are missing description
|
||||||
(tool) => tool.type === 'mcp' && !tool.schema && tool.params?.toolName
|
const mcpToolsNeedingUpdate = selectedTools.filter(
|
||||||
|
(tool) =>
|
||||||
|
tool.type === 'mcp' && tool.params?.toolName && (!tool.schema || !tool.schema.description)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (mcpToolsNeedingSchema.length === 0) {
|
if (mcpToolsNeedingUpdate.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedTools = selectedTools.map((tool) => {
|
const updatedTools = selectedTools.map((tool) => {
|
||||||
if (tool.type !== 'mcp' || tool.schema || !tool.params?.toolName) {
|
if (tool.type !== 'mcp' || !tool.params?.toolName) {
|
||||||
|
return tool
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tool.schema?.description) {
|
||||||
return tool
|
return tool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -877,17 +883,27 @@ export function ToolInput({
|
|||||||
|
|
||||||
if (mcpTool?.inputSchema) {
|
if (mcpTool?.inputSchema) {
|
||||||
logger.info(`Backfilling schema for MCP tool: ${tool.params.toolName}`)
|
logger.info(`Backfilling schema for MCP tool: ${tool.params.toolName}`)
|
||||||
return { ...tool, schema: mcpTool.inputSchema }
|
return {
|
||||||
|
...tool,
|
||||||
|
schema: {
|
||||||
|
...mcpTool.inputSchema,
|
||||||
|
description: mcpTool.description,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tool
|
return tool
|
||||||
})
|
})
|
||||||
|
|
||||||
const hasChanges = updatedTools.some((tool, i) => tool.schema && !selectedTools[i].schema)
|
const hasChanges = updatedTools.some(
|
||||||
|
(tool, i) =>
|
||||||
|
(tool.schema && !selectedTools[i].schema) ||
|
||||||
|
(tool.schema?.description && !selectedTools[i].schema?.description)
|
||||||
|
)
|
||||||
|
|
||||||
if (hasChanges) {
|
if (hasChanges) {
|
||||||
hasBackfilledRef.current = true
|
hasBackfilledRef.current = true
|
||||||
logger.info(`Backfilled schemas for ${mcpToolsNeedingSchema.length} MCP tool(s)`)
|
logger.info(`Backfilled schemas for ${mcpToolsNeedingUpdate.length} MCP tool(s)`)
|
||||||
setStoreValue(updatedTools)
|
setStoreValue(updatedTools)
|
||||||
}
|
}
|
||||||
}, [mcpTools, mcpLoading, selectedTools, isPreview, setStoreValue])
|
}, [mcpTools, mcpLoading, selectedTools, isPreview, setStoreValue])
|
||||||
|
|||||||
Reference in New Issue
Block a user