专栏名称: 阿里云开发者
阿里巴巴官方技术号,关于阿里的技术创新均将呈现于此
目录
相关文章推荐
51好读  ›  专栏  ›  阿里云开发者

一文带你 "看见" MCP 的过程,彻底理解 MCP 的概念

阿里云开发者  · 公众号  · 科技公司  · 2025-05-23 08:30

主要观点总结

本文介绍了模型上下文协议(MCP)的理论基础、工具使用格式、示例、可用工具列表、工具使用规则,并通过ModelScope和阿里云百炼等MCP市场,展示了如何实际应用MCP。同时,文中也分享了学习MCP的技巧,包括使用Qwen、克隆Cherry Studio源码、使用AI编程工具等。作者还提出了对MCP的一些观点,包括存在的问题、展望等。此外,还关联了关于通义千问和LangChain的文章,展示了构建高效对话模型的可能性。

关键观点总结

关键观点1: MCP的理论基础

MCP是为了让AI模型能够使用工具,它连接AI助手与数据所在的系统,帮助模型产生更好的响应。

关键观点2: 工具使用格式和示例

使用XML风格的标签来调用工具,包括工具名称和JSON格式的参数。提供了多个实际可用的信息获取工具,如各种中英文新闻和内容平台的热门榜单。

关键观点3: MCP市场和学习技巧

介绍了国内常见的MCP市场,如ModelScope和阿里云百炼,并分享了学习MCP的技巧,如使用Qwen、克隆Cherry Studio源码等。

关键观点4: 存在的问题和展望

作者提出了对MCP的一些观点,包括存在的问题、未来展望等。并关联了关于通义千问和LangChain的文章,展示了构建高效对话模型的可能性。


正文

请到「今天看啥」查看全文


\n\n Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: \n\n \n {tool_name} \n {json_arguments} \n \n\n The tool name should be the exact name of the tool you are using, and the arguments should be a JSON object containing the parameters required by that tool. For example: \n \n python_interpreter \n { \" code \" : \" 5 + 3 + 1294.678 \" } \n \n\n The user will respond with the result of the tool use, which should be formatted as follows: \n\n \n {tool_name} \n {result} \n \n\n The result should be a string, which can represent a file or any other output type. You can use this result as input for the next action. \n For example, if the result of the tool use is an image file, you can use it in the next action like this: \n\n \n image_transformer \n { \" image \" : \" image_1.jpg \" } \n \n\n Always adhere to this format for the tool use to ensure proper parsing and execution. \n\n ## Tool Use Examples \n\n Here are a few examples using notional tools: \n --- \n User: Generate an image of the oldest person in this document. \n\n Assistant: I can use the document_qa tool to find out who the oldest person is in the document. \n \n document_qa \n { \" document \" : \" document.pdf \" , \" question \" : \" Who is the oldest person mentioned? \" } \n \n\n User: \n document_qa \n John Doe, a 55 year old lumberjack living in Newfoundland. \n \n\n Assistant: I can use the image_generator tool to create a portrait of John Doe. \n \n image_generator \n { \" prompt \" : \" A portrait of John Doe, a 55-year-old man living in Canada. \" } \n \n\n User: \n image_generator \n image.png \n \n\n Assistant: the image is generated as image.png \n\n --- \n User: \" What is the result of the following operation: 5 + 3 + 1294.678? \"\n\n Assistant: I can use the python_interpreter tool to calculate the result of the operation. \n \n python_interpreter \n { \" code \" : \" 5 + 3 + 1294.678 \" } \n \n\n User: \n python_interpreter \n 1302.678 \n \n\n Assistant: The result of the operation is 1302.678. \n\n --- \n User: \" Which city has the highest population , Guangzhou or Shanghai? \"\n\n Assistant: I can use the search tool to find the population of Guangzhou. \n \n search \n { \" query \" : \" Population Guangzhou \" } \n \n\n User: \n search \n Guangzhou has a population of 15 million inhabitants as of 2021. \n \n\n Assistant: I can use the search tool to find the population of Shanghai. \n \n search \n { \" query \" : \" Population Shanghai \" } \n \n\n User: \n search \n 26 million (2019) \n \n Assistant: The population of Shanghai is 26 million, while Guangzhou has a population of 15 million. Therefore, Shanghai has the highest population. \n\n\n ## Tool Use Available Tools \n Above example were using notional tools that might not exist for you. You only have access to these tools: \n \n\n \n f_u-LsDUyQWsNFAUjL-_Vi \n 获取 36 氪热榜,提供创业、商业、科技领域的热门资讯,包含投融资动态、新兴产业分析和商业模式创新信息 \n \n { \" type \" : \" object \" , \" properties \" :{ \" type \" :{ \" anyOf \" :[{ \" type \" : \" string \" , \" const \" : \" hot \" , \" description \" : \" 人气榜 \" },{ \" type \" : \" string \" , \" const \" : \" video \" , \" description \" : \" 视频榜 \" },{ \" type \" : \" string \" , \" const \" : \" comment \" , \" description \" : \" 热议榜 \" },{ \" type \" : \" string \" , \" const \" : \" collect \" , \" description \" : \" 收藏榜 \" }], \" default \" : \" hot \" , \" description \" : \" 分类 \" }}, \" additionalProperties \" :false, \" $schema \" : \" http://json-schema.org/draft-07/schema# \" } \n \n \n\n\n \n fyQ3DOUpLJDGPLCjslT6P1 \n 获取 9to5Mac 苹果相关新闻,包含苹果产品发布、iOS 更新、Mac 硬件、应用推荐及苹果公司动态的英文资讯 \n \n { \" type \" : \" object \" , \" properties \" :{}, \" additionalProperties \" :false, \" $schema \" : \" http://json-schema.org/draft-07/schema# \" } \n \n \n\n\n \n fBOukVLVbqIh69earzcYca \n 获取 BBC 新闻,提供全球新闻、英国新闻、商业、政治、健康、教育、科技、娱乐等资讯 \n \n { \" type \" : \" object \" , \" properties \" :{ \" category \" :{ \" anyOf \" :[{ \" type \" : \" string \" , \" const \" : \"\" , \" description \" : \" 热门新闻 \" },{ \" type \" : \" string \" , \" const \" : \" world \" , \" description \" : \" 国际 \" },{ \" type \" : \" string \" , \" const \" : \" uk \" , \" description \" : \" 英国 \" },{ \" type \" : \" string \" , \" const \" : \" business \" , \" description \" : \" 商业 \" },{ \" type \" : \" string \" , \" const \" : \" politics \" , \" description \" : \" 政治 \" },{ \" type \" : \" string \" , \" const \" : \" health \" , \" description \" : \" 健康 \" },{ \" type \" : \" string \" , \" const \" : \" education \" , \" description \" : \" 教育 \" },{ \" type \" : \" string \" , \" const \" : \" science_and_environment \" , \" description \" : \" 科学与环境 \" },{ \" type \" : \" string \" , \" const \" : \" technology \" , \" description \" : \" 科技 \" },{ \" type \" : \" string \" , \" const \" : \" entertainment_and_arts \" , \" description \" : \" 娱乐与艺术 \" }], \" default \" : \"\" }, \" edition \" :{ \" anyOf \" :[{ \" type \" : \" string \" , \" const \" : \"\" },{ \" type \" : \" string \" , \" const \" : \" uk \" , \" description \" : \" UK \" },{ \" type \" : \" string \" , \" const \" : \" us \" , \" description \" : \" US & Canada \" },{ \" type \" : \" string \" , \" const \" : \" int \" , \" description \"





请到「今天看啥」查看全文


推荐文章
普象工业设计小站  ·  【私人定制】I have a 波纹 pen
8 年前
金乡大蒜辣椒国际交易市场  ·  印尼出台政策,控制大蒜进口,中国大蒜销路受阻!
7 年前