news 2026/3/28 22:10:33

使用 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/3/18 8:31:49

LangChain PromptTemplate定制化Anything-LLM回复风格

LangChain PromptTemplate定制化Anything-LLM回复风格 在企业级AI助手日益普及的今天,一个共性问题逐渐浮现:即便底层模型能力强大,默认生成的回复却常常“千人一面”——语气平淡、结构松散、缺乏品牌调性。特别是在构建内部知识库或客户服务…

作者头像 李华
网站建设 2026/3/14 5:44:24

终极免费3D抽奖系统:5分钟打造沉浸式年会互动体验

终极免费3D抽奖系统:5分钟打造沉浸式年会互动体验 【免费下载链接】log-lottery 🎈🎈🎈🎈年会抽奖程序,threejsvue3 3D球体动态抽奖应用。 项目地址: https://gitcode.com/gh_mirrors/lo/log-lottery …

作者头像 李华
网站建设 2026/3/20 0:52:47

Habitat-Sim安装配置全攻略:从环境搭建到功能验证

Habitat-Sim安装配置全攻略:从环境搭建到功能验证 【免费下载链接】habitat-sim A flexible, high-performance 3D simulator for Embodied AI research. 项目地址: https://gitcode.com/GitHub_Trending/ha/habitat-sim Habitat-Sim作为专为具身AI研究设计的…

作者头像 李华
网站建设 2026/3/24 11:19:22

Apache Weex渲染性能优化实战:5个技巧解决移动端卡顿问题

Apache Weex渲染性能优化实战:5个技巧解决移动端卡顿问题 【免费下载链接】incubator-weex Apache Weex (Incubating) 项目地址: https://gitcode.com/gh_mirrors/in/incubator-weex 在移动应用开发中,渲染性能直接影响用户体验。Apache Weex作为…

作者头像 李华