Design
抓取远程图片 URL,提取主色调,导出可直接用于代码的配色文件,并查看对比度结果
用三种语言从你的代码中调用此工具。
curl -X POST 'https://api.elysiatools.com/zh/api/tools/color-palette-extractor-from-image-url' \
-H 'Content-Type: application/json' \
-d '{"imageUrl":"data:image/svg+xml;utf8,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%221200%22%20height=%22630%22%20viewBox=%220%200%201200%20630%22%3E%3Crect%20width=%221200%22%20height=%22630%22%20fill=%22%232563eb%22/%3E%3Crect%20x=%2270%22%20y=%2270%22%20width=%22360%22%20height=%22490%22%20rx=%2236%22%20fill=%22%23f8fafc%22/%3E%3Crect%20x=%22490%22%20y=%2270%22%20width=%22640%22%20height=%22220%22%20rx=%2232%22%20fill=%22%23111827%22/%3E%3Crect%20x=%22490%22%20y=%22330%22%20width=%22280%22%20height=%22150%22%20rx=%2228%22%20fill=%22%23f59e0b%22/%3E%3Crect%20x=%22810%22%20y=%22330%22%20width=%22320%22%20height=%22150%22%20rx=%2228%22%20fill=%22%2310b981%22/%3E%3C/svg%3E","paletteSize":6,"exportPackageName":"launch-hero-palette"}'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST https://api.elysiatools.com/zh/api/tools/color-palette-extractor-from-image-url| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| imageUrl | text | 是 | 抓取远程图片,提取主色,并生成可下载的配色包 |
| paletteSize | number | 否 | — |
| exportPackageName | text | 否 | — |
HTML 结果
{
"result": "<div>Processed HTML content</div>",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}将此工具加入你的 Model Context Protocol 服务,让 AI 智能体可以列出并调用它。
将以下内容加入你的 MCP 客户端配置:
{
"mcpServers": {
"elysiatools-color-palette-extractor-from-image-url": {
"name": "color-palette-extractor-from-image-url",
"description": "抓取远程图片 URL,提取主色调,导出可直接用于代码的配色文件,并查看对比度结果",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=color-palette-extractor-from-image-url",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}连接到 SSE 端点后,列出已开放的工具:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}通过工具 id 调用,参数由其参数表构建:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "color-palette-extractor-from-image-url",
"arguments": {
"imageUrl": "data:image/svg+xml;utf8,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%221200%22%20height=%22630%22%20viewBox=%220%200%201200%20630%22%3E%3Crect%20width=%221200%22%20height=%22630%22%20fill=%22%232563eb%22/%3E%3Crect%20x=%2270%22%20y=%2270%22%20width=%22360%22%20height=%22490%22%20rx=%2236%22%20fill=%22%23f8fafc%22/%3E%3Crect%20x=%22490%22%20y=%2270%22%20width=%22640%22%20height=%22220%22%20rx=%2232%22%20fill=%22%23111827%22/%3E%3Crect%20x=%22490%22%20y=%22330%22%20width=%22280%22%20height=%22150%22%20rx=%2228%22%20fill=%22%23f59e0b%22/%3E%3Crect%20x=%22810%22%20y=%22330%22%20width=%22320%22%20height=%22150%22%20rx=%2228%22%20fill=%22%2310b981%22/%3E%3C/svg%3E",
"paletteSize": 6,
"exportPackageName": "launch-hero-palette"
}
}
}有问题或反馈?请联系 [email protected]