存图时同时生成两样东西:dHash 视觉指纹(64 位,抗缩放和压缩,实测同图缩放 50%、JPEG 压到 q40 后距离仍为 0)和语义向量(百炼 text-embedding-v3,1024 维)。两条路各管一件事——dHash 找「看起来一样」的图,向量找「说的是同一件事」的图。不用装 torch,不用 GPU,4 核 CPU 跑得动。
一行命令,工具自动出现在 Agent 的工具列表里。
# Claude Code / Cursor / 任何 MCP 客户端 claude mcp add --transport http mycel-vision https://pianam.cn/vision-mcp/mcp
标准 JSON-RPC 2.0。initialize 握手不消耗额度,只有 tools/call 计数。
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'存一张图进视觉记忆。必须提供 description(这张图是什么),它是后续语义检索的唯一依据。会自动生成 dHash 视觉指纹并建语义索引。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
| image_url | string | 可选 | — | 图片 http(s) 地址,与 image_base64 二选一 |
| image_base64 | string | 可选 | — | 图片 base64(可带 data:image/...;base64, 前缀) |
| description | string | 必填 | — | 必填。这张图是什么,越具体越好检索,例如「后台登录页报错弹窗:账号或密码错误」 |
| title | string | 可选 | — | 短标题,可选 |
| tags | array<string> | 可选 | — | 标签,便于过滤 |
| source | string | 可选 | — | 来源标记,如 screenshot / web / upload |
| ocr_text | string | 可选 | — | 图中文字(你自己 OCR 后传入,本服务不内置 OCR) |
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vision_remember","arguments":{"image_url":"https://pianam.cn/favicon.ico","description":"网站 favicon:深色圆角方块里的叶子标志,Mycel 品牌图标","title":"Mycel favicon","tags":["brand","logo","ui"],"source":"docs-demo"}}}'{
"id": 4,
"dhash": "00023478c8c0a000",
"size": [
48,
48
],
"bytes": 304,
"semantic_index": true,
"duplicate_of": 3,
"tenant_items": 2,
"evicted": [],
"note": "语义向量已建索引"
}duplicate_of 不为 null 表示库内已有视觉上几乎相同的图(dHash 距离 ≤3),返回的是那条的 id。此时图仍会入库,由你决定要不要删。
按语义描述检索视觉记忆,可叠加时间范围与标签过滤。返回按相关度排序的条目。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
| query | string | 可选 | — | 要找什么,自然语言描述,例如「登录报错的弹窗」 |
| since | string | 可选 | — | 起始时间,格式 YYYY-MM-DD 或 YYYY-MM-DD HH:MM:SS |
| until | string | 可选 | — | 结束时间 |
| tags | string | 可选 | — | 标签过滤,逗号分隔 |
| limit | integer | 可选 | — | 返回条数,默认 10,最大 50 |
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vision_recall","arguments":{"query":"品牌标志 叶子","limit":3}}}'{
"query": "品牌标志 叶子",
"count": 3,
"items": [
{
"id": 5,
"description": "iOS 主屏图标,同一个叶子标志的 180x180 版本",
"tags": [
"brand",
"ui"
],
"dhash": "02294383367c58a0",
"size": [
180,
180
],
"created_at": "2026-11-26 17:25:19",
"score": 0.7108
},
{
"id": 4,
"description": "网站 favicon:深色圆角方块里的叶子标志,Mycel 品牌图标",
"tags": [
"brand",
"logo",
"ui"
],
"dhash": "00023478c8c0a000",
"size": [
48,
48
],
"created_at": "2026-11-26 17:25:18",
"score": 0.6832
}
]
}score 是余弦相似度,1.0 为完全一致。query 留空则退化为按时间倒序列出。embedding 服务不可用时会自动降级成关键词 LIKE 匹配,score 固定 0。此处截断到 2 条,线上返回 3 条。
找视觉上相似的图。用 dHash 汉明距离,零成本。给 item_id 找库内相似项,或直接给图找库内匹配。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
| item_id | integer | 可选 | — | 以库内某条为基准 |
| image_url | string | 可选 | — | 以外部图片为基准 |
| image_base64 | string | 可选 | — | 以 base64 图片为基准 |
| threshold | integer | 可选 | — | 汉明距离上限,默认 10。0-3 几乎相同,4-12 小改动 |
| limit | integer | 可选 | — | 返回条数,默认 10 |
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vision_similar","arguments":{"item_id":4,"threshold":40,"limit":3}}}'{
"dhash": "00023478c8c0a000",
"threshold": 40,
"count": 2,
"items": [
{
"id": 3,
"description": "站点 favicon 图标",
"dhash": "00023478c8c0a000",
"size": [
48,
48
],
"distance": 0
},
{
"id": 5,
"description": "iOS 主屏图标,同一个叶子标志的 180x180 版本",
"dhash": "02294383367c58a0",
"size": [
180,
180
],
"distance": 37
}
]
}distance 是汉明距离(0-64)。0-3 同一张图,4-12 局部改动,12 以上是不同画面。threshold 默认 10,这里放宽到 40 才把不同设计的图标也捞出来。
比较两张图,判断是否同一画面、有没有改动。适合页面视觉回归、UI 改动核对。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
| a | 任意 | 必填 | — | 第一张:item id,或 {image_url|image_base64, description} |
| b | 任意 | 必填 | — | 第二张:item id,或 {image_url|image_base64, description} |
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vision_compare","arguments":{"a":4,"b":5}}}'{
"a": {
"id": 4,
"dhash": "00023478c8c0a000",
"size": [
48,
48
],
"description": "网站 favicon:深色圆角方块里的叶子标志,Mycel 品牌图标",
"created_at": "2026-11-26 17:25:18"
},
"b": {
"id": 5,
"dhash": "02294383367c58a0",
"size": [
180,
180
],
"description": "iOS 主屏图标,同一个叶子标志的 180x180 版本",
"created_at": "2026-11-26 17:25:19"
},
"hamming_distance": 37,
"verdict": "内容明显不同",
"hint": "距离 0-3 视为同一张;4-12 通常是小改动(改字、换色、局部增删);12 以上是不同画面"
}a / b 都可以传库内 id,也可以传 {image_url} 或 {image_base64} 的临时图,混着传也行。
按时间倒序列出视觉记忆,用于回顾某段时间看过什么。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
| since | string | 可选 | — | 起始时间 |
| until | string | 可选 | — | 结束时间 |
| limit | integer | 可选 | — | 返回条数,默认 20,最大 100 |
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vision_timeline","arguments":{"limit":3}}}'{
"count": 3,
"items": [
{
"id": 5,
"created_at": "2026-11-26 17:25:19",
"source": "docs-demo",
"title": "Mycel 主屏图标",
"description": "iOS 主屏图标,同一个叶子标志的 180x180 版本",
"tags": [
"brand",
"ui"
],
"dhash": "02294383367c58a0",
"size": [
180,
180
],
"bytes": 2026
},
{
"id": 4,
"created_at": "2026-11-26 17:25:18",
"source": "docs-demo",
"title": "Mycel favicon",
"description": "网站 favicon:深色圆角方块里的叶子标志,Mycel 品牌图标",
"tags": [
"brand",
"logo",
"ui"
],
"dhash": "00023478c8c0a000",
"size": [
48,
48
],
"bytes": 304
}
]
}此处截断到 2 条,线上返回 3 条。时间格式统一为 YYYY-MM-DD HH:MM:SS,时区东八区。
查看当前租户的视觉记忆用量:条数、存储占用、近 14 天分布、可用能力。
无参数。这个工具不需要任何入参,直接调。
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vision_stats","arguments":{}}}'{
"tenant_items": 3,
"tenant_bytes": 2634,
"tenant_limit": 1000,
"by_day": [
{
"date": "2026-11-26",
"count": 3
}
],
"global_items": 3,
"capabilities": {
"visual_fingerprint": "dHash 64-bit(零成本,找近似图)",
"semantic": "百炼 text-embedding-v3(找语义相关)",
"ocr": "未内置,可通过 ocr_text 参数传入第三方 OCR 结果"
}
}tenant_items 是当前租户(API Key 或 IP)的条数,global_items 是全站条数。单租户满 1000 条后,新存的会自动淘汰最旧的一条。
删除指定条目,释放存储。只影响当前租户。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
| ids | array<integer> | 必填 | — | 要删除的 id 列表 |
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vision_forget","arguments":{"ids":[5]}}}'{
"removed": [
5
],
"count": 1
}只删当前租户自己的条目,跨租户删不动。文件同步删除,存储占用立即释放。
超额返回 -32002,带 X-API-Key 继续用。密钥在 pianam.cn 注册后于控制台创建。
Claude Code、Cursor、Cherry Studio 等支持 streamable HTTP 的客户端,一行命令把 7 个工具挂到 Agent 上。
# Claude Code / Cursor / 任何 MCP 客户端 claude mcp add --transport http mycel-vision https://pianam.cn/vision-mcp/mcp
端点 https://pianam.cn/vision-mcp/mcp,POST 一个 JSON-RPC 就返回数据,响应是 SSE(data: 行内是 JSON)。
curl -s https://pianam.cn/vision-mcp/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'