Ming gongshi 明宮史 "Palace history of the Ming" is an unofficial history the Ming dynasty 明 (1368-1644) written by the late Ming-period scholar Liu Ruoyu 劉若愚 (1541-?), who was a chief eunuch (taijian 太監) during the Wanli reign-period 萬曆 (1573-1619). He was known as a well-educated person.
When the eunuch 'dictator' Wei Zhongxian 魏忠賢 (1568–1627) took over the power over the fate of the dynasty and the empire, Liu Ruoyu was sent out to supervise the archive of the palace attendant service (neizhifang 内直房). After Wei's downfall the Censor Yang Weiyuan 楊維垣 (d. 1645) arranged for Liu Ruoyu's degradation, so that he was demoted to commander of the guard of the mausoleum of Emperor Taizu 明太祖 (r. 1368-1398), Ming Xiaoling 明孝陵 in the southern capital Nanjing 南京, Jiangsu.
The processes against Wei Zhongxian's clique continued, and in connection with the execution of Gao Panlong 高攀龍 (1562-1626), Wei Zhongxian's right hand Li Yongzhen 李永貞 was put to death. Liu Ruoyu who had served under him was charged with the crime of collaboration but finally was released. In prison wrote the apologetic treatise Zhuozhongzhi 酌中志. In an appendix to this 23-juan long book, called Heitou yuanli jilve 黑頭爰立紀略, he described in detail the mechanisms in the inner court and the functioning of the various actors like the emperor, his consorts, the eunuchs, and the court ladies.
Later on Lü Se 呂瑟 selected five chapters from the Zhuozhongji (16-20) and created the 5-juan long Ming gongshi. It seems that the content of the original was not altered.
The text is divided into five collections (ji 集) named according to the cosmological Five Agents. In the book, the system of the inner court is described, the function of the employees, their duties and ritual robes, how they ate and spent their lives, and how documents were processed. All this information was seen from the viewpoint of a eunuch serving in a high position, and is therefore of an extremely high value because it provides the knowledge of an 'insider'.
In the Ming gongshi it can be seen that the eunuchs did not only administer the imperial palace (more or less identical to the Forbidden City of the Qing dynasty 清, 1644-1911), but also a large number of buildings inside the city that are described in the text.
The Ming gongshi was only preserved as a manuscript, but is included in the series Xuejin taoyuan 學津討原. It was also published by the Guoxue Fulun Society 國學扶輪社 in Shanghai and the Beijing Press 北京出版社 in 1963, in a joint version with Gao Shiqi's 高士奇 (1644-1703) book Jin'ao tuishi biji 金鰲退食筆記, and then again in 1980 by the Beijing Guji Press 北京古籍出版社.