news 2026/6/23 1:49:45

使用 Coze MCP 插件 + curl 调用工具生成高质量提示词示例

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
使用 Coze MCP 插件 + curl 调用工具生成高质量提示词示例

使用 Coze MCP 插件调用工具生成高质量提示词示例

在现代 AI 图像生成工作流中,我们常需要通过 API 调用来生成或优化图像提示(prompt),以获得更精细、更专业的生成效果。本文以 Coze MCP 平台的插件接口为例,展示如何使用curl命令调用sd_better_prompt工具,并解析返回结果。

一、API 调用示例

下面是一个典型的curlPOST 请求示例,调用了 MCP 插件接口:

curl-N -X POST https://mcp.coze.cn/v1/plugins/7439197952104710144\-H"Authorization: Bearer Token"\-H"Content-Type: application/json"\-H"Accept: application/json, text/event-stream"\-d'{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "sd_better_prompt", "arguments": { "prompt": "1girl" } } }'

参数说明

  • -N:启用流式输出(不缓冲),便于实时接收事件流(SSE)。

  • -X POST:使用 POST 方法调用接口。

  • -H "Authorization: Bearer Token":请求头中携带 API 授权令牌。

  • -H "Content-Type: application/json":请求体格式为 JSON。

  • -H "Accept: application/json, text/event-stream":支持 JSON 和事件流两种返回类型。

  • -d '{...}':请求体,遵循 JSON-RPC 2.0 规范:

    • method:指定调用的方法,这里是tools/call
    • params.name:要调用的工具名称,这里是sd_better_prompt
    • params.arguments.prompt:输入的原始提示词,这里是"1girl"

二、返回结果解析

调用成功后,服务端通过事件流返回结果,例如:

event:message id:M7QF7DZRCEWNMBTV5UQRR5RK55_0data:{"jsonrpc":"2.0","id":2,"result":{"_meta":{"logid":"202512151652440755E28A1AA54C77D352"},"content":[{"type":"text","text":"call tool success, resp={\"msg\":\"success\",\"data\":\"1girl, best quality, ultra-detailed, masterpiece, 4K, hyper detailed, realistic photo, detailed skin texture, natural lighting, sharp focus, indoor scene with soft diffused light, white background, simple composition, warm color tones, looking at viewer, slight smile, standing pose, elegant attire, detailed hair, high-definition, cinematic lighting, realistic shadows, vibrant colors, art station trending\"}, logid=202512151652440755E28A1AA54C77D352"}],"structuredContent":{"data":"1girl, best quality, ultra-detailed, masterpiece, 4K, hyper detailed, realistic photo, detailed skin texture, natural lighting, sharp focus, indoor scene with soft diffused light, white background, simple composition, warm color tones, looking at viewer, slight smile, standing pose, elegant attire, detailed hair, high-definition, cinematic lighting, realistic shadows, vibrant colors, art station trending","msg":"success"}}}

结果解析

  1. logid:本次调用的唯一日志 ID,用于排查和追踪。
  2. content:原始文本输出,包含调用状态和生成结果。
  3. structuredContent.data:处理后的提示词,经过sd_better_prompt优化,输出完整的高质量提示词,例如:
1girl, best quality, ultra-detailed, masterpiece, 4K, hyper detailed, realistic photo, detailed skin texture, natural lighting, sharp focus, indoor scene with soft diffused light, white background, simple composition, warm color tones, looking at viewer, slight smile, standing pose, elegant attire, detailed hair, high-definition, cinematic lighting, realistic shadows, vibrant colors, art station trending

这个提示词已经经过工具优化,适合直接用于图像生成模型(如 Stable Diffusion)以获得高质量的渲染效果。

三、总结

通过以上示例,我们可以看到:

  • 使用 MCP 插件接口可以轻松调用 AI 工具进行提示词优化。
  • 事件流(SSE)方式返回结果,方便实时获取输出。
  • 优化后的提示词不仅丰富了细节,还提升了渲染质量。
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/23 8:12:20

5个Apache Weex渲染性能提升技巧:终极优化指南

5个Apache Weex渲染性能提升技巧:终极优化指南 【免费下载链接】incubator-weex Apache Weex (Incubating) 项目地址: https://gitcode.com/gh_mirrors/in/incubator-weex Apache Weex作为业界领先的跨平台UI框架,在移动应用性能优化领域发挥着重…

作者头像 李华
网站建设 2026/6/23 21:29:22

生成对抗网络:从代码到创意的商业变现指南

生成对抗网络:从代码到创意的商业变现指南 【免费下载链接】stylegan StyleGAN - Official TensorFlow Implementation 项目地址: https://gitcode.com/gh_mirrors/st/stylegan 你是否曾为找不到合适的模特素材而烦恼?是否想过用AI技术批量生成创…

作者头像 李华
网站建设 2026/6/23 18:38:16

【R与Python函数调用适配全攻略】:掌握跨语言协作的5大核心技术

第一章:R与Python函数调用适配的背景与意义在数据科学和统计分析领域,R语言以其强大的统计建模能力和丰富的可视化包广受青睐,而Python则凭借其通用编程特性、机器学习生态和工程化优势成为主流工具。然而,实际项目中往往需要结合…

作者头像 李华
网站建设 2026/6/23 0:54:01

R与Python库版本同步实践全解析(20年专家亲授避坑手册)

第一章:R与Python库版本同步的背景与挑战在数据科学和统计分析领域,R 与 Python 是两种最广泛使用的编程语言。尽管它们各有优势——R 在统计建模和可视化方面表现突出,而 Python 则以通用性和丰富的机器学习生态见长——但在实际项目中&…

作者头像 李华
网站建设 2026/6/23 19:48:27

心法利器[147] | Agent,是大模型落地的殊途同归

心法利器 本栏目主要和大家一起讨论近期自己学习的心得和体会。具体介绍:仓颉专项:飞机大炮我都会,利器心法我还有。 2024年新的文章合集已经发布,获取方式看这里:再添近20万字-CS的陋室2024年文章合集更新&#xff0c…

作者头像 李华