feat: 重构 MCP 工具导出逻辑并完善返回值类型系统

This commit is contained in:
lilong.129
2025-05-31 00:28:24 +08:00
parent 2a392f204b
commit 9089bd9324
7 changed files with 924 additions and 52 deletions
+15
View File
@@ -558,3 +558,18 @@ func (h *MCPHost) forceCloseAll() {
delete(h.connections, name)
}
}
// getActionToolProvider returns an ActionToolProvider for the given server name if available
// This method checks if the MCP server implements the ActionToolProvider interface
func (h *MCPHost) getActionToolProvider(serverName string) ActionToolProvider {
h.mu.RLock()
defer h.mu.RUnlock()
if conn, exists := h.connections[serverName]; exists {
// Check if the client directly implements ActionToolProvider interface
if actionToolProvider, ok := conn.Client.(ActionToolProvider); ok {
return actionToolProvider
}
}
return nil
}