Agent
Claude Code
把 Imagifly MCP 服务器接入 Anthropic 的终端编码 Agent。
Claude Code 是 Anthropic 的 Agent 式编码工具。它能读写代码、执行命令,在你的终端和 IDE 里完成多步骤开发任务。接入 Imagifly 服务器后,它在干活的同时还能生成图片和视频。
添加服务器
macOS / Linux:
claude mcp add --transport http imagifly https://imagifly.net/api/mcp \
--header "Authorization: Bearer $IMAGIFLY_API_KEY"Windows PowerShell:
claude mcp add --transport http imagifly https://imagifly.net/api/mcp `
--header "Authorization: Bearer $env:IMAGIFLY_API_KEY"加上 --scope user 可让服务器在所有项目中可用:
claude mcp add --scope user --transport http imagifly https://imagifly.net/api/mcp \
--header "Authorization: Bearer $IMAGIFLY_API_KEY"| 作用域 | 存放位置 | 生效范围 |
|---|---|---|
local(默认) | ~/.claude.json,按项目保存 | 仅当前项目 |
project | 仓库内的 .mcp.json | 所有打开该仓库的人 |
user | ~/.claude.json,全局 | 你所有的项目 |
项目级配置
把 .mcp.json 提交到仓库即可共享服务器定义。Claude Code 会从环境变量展开 ${IMAGIFLY_API_KEY},所以不会把密钥提交上去:
{
"mcpServers": {
"imagifly": {
"type": "http",
"url": "https://imagifly.net/api/mcp",
"headers": {
"Authorization": "Bearer ${IMAGIFLY_API_KEY}"
}
}
}
}`url` 需要配 `type`
Claude Code 只有在 type 为 "http" 时才把 url 当作远程服务器。没有 type 的 url 会被报为配置错误。
验证
claude mcp list
claude mcp get imagifly在会话中执行 /mcp 可以看到连接状态和工具列表。你应该能看到 generate_image、get_image_generation、generate_video、get_video_generation、list_image_models 和 list_video_models。
试一试
Generate a 16:9 image of a paper boat on a rainy windowsill, then show me the image URL.Agent 会调用 generate_image,轮询 get_image_generation 直到任务成功,然后返回 URL。