@@ -278,43 +278,70 @@ def add_common_tools(self):
278278 music_manager = get_music_tools_manager ()
279279 music_manager .init_tools (self .add_tool , PropertyList , Property , PropertyType )
280280
281- # 添加12306铁路查询工具
282- from src .mcp .tools .railway import get_railway_tools_manager
283-
284- railway_manager = get_railway_tools_manager ()
285- railway_manager .init_tools (self .add_tool , PropertyList , Property , PropertyType )
286-
287- # 添加搜索工具
288- from src .mcp .tools .search import get_search_manager
289-
290- search_manager = get_search_manager ()
291- search_manager .init_tools (self .add_tool , PropertyList , Property , PropertyType )
292-
293- # 添加菜谱工具
294- from src .mcp .tools .recipe import get_recipe_manager
295-
296- recipe_manager = get_recipe_manager ()
297- recipe_manager .init_tools (self .add_tool , PropertyList , Property , PropertyType )
298-
299281 # 添加摄像头工具
300282 from src .mcp .tools .camera import take_photo
301283
302284 # 注册take_photo工具
303285 properties = PropertyList ([Property ("question" , PropertyType .STRING )])
286+ VISION_DESC = (
287+ "【图像/识图/OCR/问答】当用户提到:拍照、识图、读取/提取文字、OCR、翻译图片文字、"
288+ "看一下这张图/截图、这是什么、数一数、识别二维码/条码、对比两张图、分析场景/报错截图、"
289+ "表格/票据信息抽取、图片问答 时调用本工具。"
290+ "功能:①拍照或接收已有图片/截图/URL;②物体/场景/标签识别;③OCR(多语)与翻译;④计数/位置;"
291+ "⑤二维码/条码读取;⑥关键信息抽取(表格/票据);⑦两图对比;⑧就图回答问题。"
292+ "输入建议:{ mode:'capture'|'upload'|'url', image?, url?, question?, target_lang? };"
293+ "若用户未提供图片且允许,可触发拍照(mode='capture')。"
294+ "避免:纯文本知识问答、与图片无关的请求。"
295+ "English: Vision/OCR/QA tool. Use when the user provides or asks about a photo/screenshot/image: "
296+ "describe, classify, OCR, translate, count objects, read QR/barcodes, extract tables/receipts, "
297+ "compare two images, image QA. Inputs as above. Do NOT use for pure text queries."
298+ "Examples: '这张图是什么', 'OCR这张发票并翻译成英文', '数一下图里有几只猫', '读一下这个二维码', "
299+ "'对比这两张UI截图的差异', '把截图里的表格提取成CSV'。"
300+ )
301+
304302 self .add_tool (
305303 McpTool (
306- "take_photo" ,
307- "拍照并分析图像内容。可以进行物体识别、文字识别、场景分析、问题解答等。适用于:看看这是什么、拍照识别、读取文字、分析场景、解答问题等需求。Take photo and analyze image content including object recognition, text recognition, scene analysis, and question answering." ,
304+ "take_photo" , # 保留原名兼容
305+ VISION_DESC ,
308306 properties ,
309307 take_photo ,
310308 )
311309 )
312310
313- # 添加高德地图工具
314- from src .mcp .tools .amap import get_amap_manager
311+ # 添加桌面截图工具
312+ from src .mcp .tools .screenshot import take_screenshot
313+
314+ # 注册take_screenshot工具
315+ screenshot_properties = PropertyList ([
316+ Property ("question" , PropertyType .STRING ),
317+ Property ("display" , PropertyType .STRING , default_value = None )
318+ ])
319+ SCREENSHOT_DESC = (
320+ "【桌面截图/屏幕分析】当用户提到:截屏、截图、看看桌面、分析屏幕、桌面上有什么、"
321+ "屏幕截图、查看当前界面、分析当前页面、读取屏幕内容、屏幕OCR 时调用本工具。"
322+ "功能:①截取整个桌面画面;②屏幕内容识别与分析;③屏幕OCR文字提取;④界面元素分析;"
323+ "⑤应用程序识别;⑥错误信息截图分析;⑦桌面状态检查;⑧多屏幕截图。"
324+ "参数说明:{ question: '你想了解的关于桌面/屏幕的问题', display: '显示器选择(可选)' };"
325+ "display可选值:'main'/'主屏'/'笔记本'(主显示器), 'secondary'/'副屏'/'外屏'(副显示器), 或留空(所有显示器);"
326+ "适用场景:桌面截图、屏幕分析、界面问题诊断、应用状态查看、错误截图分析等。"
327+ "注意:该工具会截取桌面,请确保用户同意截图操作。"
328+ "English: Desktop screenshot/screen analysis tool. Use when user mentions: screenshot, screen capture, "
329+ "desktop analysis, screen content, current interface, screen OCR, etc. "
330+ "Functions: ①Full desktop capture; ②Screen content recognition; ③Screen OCR; ④Interface analysis; "
331+ "⑤Application identification; ⑥Error screenshot analysis; ⑦Desktop status check. "
332+ "Parameters: { question: 'Question about desktop/screen', display: 'Display selection (optional)' }; "
333+ "Display options: 'main'(primary), 'secondary'(external), or empty(all displays). "
334+ "Examples: '截个图看看主屏', '查看副屏有什么', '分析当前屏幕内容', '读取屏幕上的文字'。"
335+ )
315336
316- amap_manager = get_amap_manager ()
317- amap_manager .init_tools (self .add_tool , PropertyList , Property , PropertyType )
337+ self .add_tool (
338+ McpTool (
339+ "take_screenshot" ,
340+ SCREENSHOT_DESC ,
341+ screenshot_properties ,
342+ take_screenshot ,
343+ )
344+ )
318345
319346 # 添加八字命理工具
320347 from src .mcp .tools .bazi import get_bazi_manager
0 commit comments