这是一个使用 Go 实现的 MCP(模型上下文协议)服务器,它通过 OpenAI 的 DALL-E API 生成图像。该服务器演示了如何构建可以被像 Claude 这样的大型语言模型使用的 MCP 工具。
go build -o ./bin/imagegen-go ./main
在您的 Claude Desktop 配置中添加此服务器,路径为 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"imagegen-go": {
"command": "/path/to/imagegen-go/bin/imagegen-go",
"env": {
"OPENAI_API_KEY": "your-api-key",
"DEFAULT_DOWNLOAD_PATH":"/path/to/downloads"
}
}
}
}
示例提示: “你能生成一张具有电影风格的河边住宅的图像吗?”
此服务器实现了 MCP 工具能力,并提供了一个工具:
generate-image:根据文本提示使用 OpenAI 的 DALL-E 生成图像MIT 许可证