这是一个模型控制协议(MCP)服务器,用于将SVG图像转换成各种网页应用所需的favicon格式(ICO和PNG)。
https://github.com/user-attachments/assets/7dcab05c-2340-4f8b-befc-7614b495685f
github.com/mark3labs/mcp-go v0.13.0github.com/sergeymakinen/go-icogithub.com/tdewolff/canvasgit clone https://github.com/elliotxx/favicon-mcp-server.git
cd favicon-mcp-server
go mod download
go run main.go
svg_data:作为字符串提供的SVG图标内容。output_formats:指定所需输出格式的字符串数组(ico,png)。默认值:["ico", "png"]。服务器返回请求格式下的Base64编码的favicon数据:
{
"content": [
{
"type": "text",
"text": "成功生成了Favicon"
}
],
"meta": {
"ico": "base64_encoded_ico_data",
"png": "base64_encoded_png_data"
}
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "svg_to_favicon",
"arguments": {
"svg_data": "<svg width=\"32\" height=\"32\"><rect width=\"32\" height=\"32\" fill=\"red\"/></svg>"
}
}
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "svg_to_favicon",
"arguments": {
"svg_file": "path/to/your/icon.svg"
}
}
}
Base64编码输出(默认):
文件输出:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "svg_to_favicon",
"arguments": {
"svg_data": "<svg width=\"32\" height=\"32\"><rect width=\"32\" height=\"32\" fill=\"red\"/></svg>",
"output_dir": "path/to/output/directory",
"output_formats": ["ico", "png"]
}
}
}
使用文件输出时:
favicon.icofavicon-{size}x{size}.png(例如,favicon-32x32.png)最简单的直接SVG输入测试方法:
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"svg_to_favicon","arguments":{"svg_data":"<svg width=\"32\" height=\"32\"><rect width=\"32\" height=\"32\" fill=\"red\"/></svg>"}}}' | go run main.go
如果你更喜欢使用测试文件:
test.jsonecho $(tr -d '\n' < test/test.json) | go run main.go
svg_data:SVG内容作为字符串svg_file:SVG文件路径output_dir:保存输出文件的目录output_formats:所需格式的数组(["ico", "png"])该项目遵循标准的Go项目布局,并使用Go模块进行依赖管理。
favicon-mcp-server/
├── main.go # 主服务器实现
├── go.mod # Go模块定义
├── go.sum # Go模块校验和
└── README.md # 本文件
go build
git checkout -b feature/amazing-feature)git commit -m '添加一些惊人的功能')git push origin feature/amazing-feature)要将此MCP服务器与Windsurf集成,请按照以下步骤操作:
~/.codeium/windsurf/mcp_config.json文件。"mcpServers": {
"favicon-mcp-server": {
"command": "go",
"args": ["run", "main.go"],
"cwd": "/path/to/favicon-mcp-server",
"env": {}
}
}
请将/path/to/favicon-mcp-server替换为你项目的实际路径。
3. 刷新Windsurf:
- 在MCP工具栏中点击“刷新”按钮以加载新配置。
要将此MCP服务器与Cursor集成,请按照以下步骤操作:
go run main.go
- 确保可执行文件的路径正确。
4. 启用服务器: - 添加服务器后,点击“启用”以激活它。
通过以上步骤,你可以将Favicon MCP Server与Windsurf和Cursor集成,增强你的开发工作流程,利用AI驱动的工具。
本项目采用MIT许可证 - 查看LICENSE文件获取详细信息。