reference-search-mcp
reference-search-mcp
自分用のツール:絵師が絵の参考を探すためのものです。AI コーディングエージェントは先に AGENTS.md を読んでください。
AI から使われる参考図検索 MCP サーバーです。自然言語クエリを受け取って → キーワードに解析して → 複数の画像ソースを並列検索 → サムネイルの重複を除去 → 番号付きのグリッド画像に合成 → マルチモーダルモデルがツール呼び出しで選別(裸の JSON 出力ではなく)→ クライアント駆動で反復(a、b、c… ラウンド、ラウンドをまたいで重複排除)→ ID ごとに元画像をダウンロードしてファイルパスを返します。
调用方 AI (MCP 客户端)
│ image_search_start("找适合播客封面的太空插画素材")
▼
[reference-search-mcp] ┌──────────────────────┐
├─ LLM 层 (pi) NL → 关键词 (submit_keywords 工具) │ 搜索适配器(并行) │
├─ providers DDG / Bing / Wikimedia / Openverse / Serper │ ddg ─┐ │
├─ 去重 pHash(跨轮 seen 集合) │ bing ─┤ 结果合并 │
├─ 拼图 sharp 编号拼图 round-a.png(a1..aN) │ wikimedia ─┘ │
├─ 视觉筛选 pi vision 模型看拼图,调用 select_images / └──────────────────────┘
│ reject_images / refine_search 工具
▼
{ round:"a", gridPath, selectedIds:["a3","a17"], metadata:[...] }
│ image_search_iterate("不要 a3,多找像 b7 的") → round b(重复图自动剔除)
│ image_search_collect(session, ["b1","c12"]) → 本地文件路径 + manifest.jsonなぜ結果を構造化 JSON ではなく「ツール呼び出し」で渡すのか
グリッド画像の選出は、のselect_images/reject_images/refine_search` などの関数呼び出しで表現します:
引数スキーマはモデルプロバイダーが強制的に検証します――必然的に正しい JSON になり、Markdown コードフェンス、散文の混入、キー名の揺れという問題がありません。
複数の意図を一度に表現できます(選択+オプション拒否+次ラウンドのキーワード提案)。
無効な ID(例:
a99)を渡すと、実行側がエラーを返すので、モデルは次のラウンドで自分で修正します;MCP の外側と同じ構造です。外側では呼び出し側の AI がツールを通じて私たちを使い、内側では私たちがツールを通じてモデルを使います。
LLM レイヤーは pi(@earendil-works/pi-ai、MIT)に基づいています。複数プロバイダーのAPI(Anthropic / OpenAI / DeepSeek / Gemini / 通义 / Kimi / MiniMax…)を統一し、認証の自動解決、組み込みのモデルカタログ、リトライと JSON の修理ツールを提供します。重装備のエージェントフレームワークは導入していません。サーバー側の LLM は、キーワード解析・フィードバック解釈・グリッド選出という3つの限定的な関数だけを担い、実際の反復ループは呼び出し側の AI が駆動します。
Related MCP server: mcp-universal-crawler
クイックスタート
要件:Node ≥ 22.19。
npm install --ignore-scripts
npm run build1. LLM を設定する(pi 認証、どちらかを選択)
# 方式 A:环境变量(任意 pi 支持的提供商)
export DEEPSEEK_API_KEY=sk-... # 文本解析(便宜)
export ANTHROPIC_API_KEY=sk-ant-... # 视觉筛选
# 或 OPENAI_API_KEY / GEMINI_API_KEY / OPENROUTER_API_KEY ...
# 方式 B:pi 的登录体系(支持订阅制)
npx @earendil-works/pi-coding-agent /login # 或直接 pi /loginモデル選択(任意):
export PI_TEXT_MODEL=deepseek/deepseek-chat
export PI_VISION_MODEL=anthropic/claude-sonnet-4-5
export PI_THINKING=off # off|minimal|low|medium|high自作の OpenAI 互換エンドポイント(Qwen-VL / GLM-4V / Ollama など):
export PI_CUSTOM_PROVIDER_API=openai-completions
export PI_CUSTOM_PROVIDER_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
export PI_CUSTOM_PROVIDER_MODELS=qwen-vl-max,qwen-turbo
export PI_CUSTOM_PROVIDER_API_KEY=sk-...DeepSeek ビジョンモデル(deepseek-v4-flash-vision-exec、pi の組み込みカタログに存在しないため、自作エンドポイントを利用):
export DEEPSEEK_API_KEY=sk-...
export PI_TEXT_MODEL=deepseek/deepseek-v4-flash
export PI_VISION_MODEL=deepseek-vision/deepseek-v4-flash-vision-exp
export PI_CUSTOM_PROVIDER_ID=deepseek-vision
export PI_CUSTOM_PROVIDER_API=openai-completions
export PI_CUSTOM_PROVIDER_BASE_URL=https://api.deepseek.com
export PI_CUSTOM_PROVIDER_MODELS=deepseek-v4-flash-vision-exp
export PI_CUSTOM_PROVIDER_API_KEY_ENV=DEEPSEEK_API_KEY**LLM の資格情報がなくても使えます(フォールバックモード)**です。start/iterate 時に明示的に keywords を渡すと、自動解析と選別を省略してすべての候補を返します。
2. 画像ソースを設定する
export PROVIDERS=ddg,bing,wikimedia # 默认;并行查询
export OPENVERSE_TOKEN=... # 启用 openverse(CC 图库)
export SERPER_API_KEY=... # 启用 serper(Google 图搜)
export SAFE_SEARCH=true3. MCP クライアントに接続する
Claude Code:
{
"mcpServers": {
"reference-search": {
"command": "node",
"args": ["D:/path/to/reference-search-mcp/dist/index.js"],
"env": { "DEEPSEEK_API_KEY": "...", "ANTHROPIC_API_KEY": "..." }
}
}
}自作の stdio クライアント:node dist/index.js、標準の MCP プロトコルで、ツールは JSON テキストブロックを返します。
デュアルモード:この MCP は「視覚能力の外部委託」
この MCP の本質は、テキストのみのモデルに「目」を与えることです。検索、グリッド化、番号付けは機械的な部分であり、視覚による選別(グリッド画像を見て番号を選ぶ)は「外部委託された視覚能力」です。呼び出し側がマルチモーダルかどうかで、サーバーが代わりに見るかどうかが決まります:
モード | 呼び出し側 | サーバーの動作 | 応答 |
| テキストのみのモデル | テキストからキーワード解析+視覚選別 | 視覚モデルの「画像を見てのレポート」として、 |
| マルチモーダルモデル | 機械的な部分だけを行い、視覚モデルを呼ばない(視覚 API を1回節約) | グリッド画像のパスと全候補の番号を返し、呼び出し側は自ら見て、自分で ID を選ぶ |
| 任意 | 視覚モデルの設定があれば選定、なければフォールバック | server / client と同様 |
collect はそもそも任意の有効な ID を受け取れます。マルチモーダルの呼び出し側は selectedIds を無視して自分で選ぶこともできます。また、各呼び出しでも filter: false で全体指定を上書きできます。
ツール契約
ツール | 引数 | 戻り値のポイント |
|
|
|
|
| 次のラウンド |
|
|
|
|
| 各ラウンドの選択/拒否、現在のキーワード、収集済み一覧 |
ID ルール:ラウンドの英字+番号。a3=第1ラウンドの3番目、b12=第2ラウンドの12番目です。すべての参照と collect はこのルールに従います。
設定リファレンス
変数 | デフォルト | 説明 |
|
| 使用する画像ソース(カンマ区切り) |
| — | 任意の画像ソースの資格情報 |
| 6 / 8 | 各ラウンド48マス; |
| 120 | セッションと一時グリッド画像の自動クリーンアップ |
| システムのtemp / | データと収集成果物の保存先 |
| 15000 | 取得タイムアウト |
| 3 | 内部ツールループの最ラウンド |
|
|
|
| 自動で選択 | LLM モデルの選択 |
アーキテクチャ
src/
mcp/ # MCP server(stdio)与 4 个工具注册
llm/ # pi-ai 之上的工具调用循环:parseKeywords / interpretFeedback / filterGrid
providers/ # SearchProvider 接口 + ddg/bing/wikimedia/openverse/serper 适配器,并行容错
grid/ # sharp 拼图构建(编号徽章/占位格)、pHash 去重
session/ # 会话状态机(轮次 a/b/c、seen 哈希、TTL 清理)
collect/ # 整图下载(UA/Referer/重试/校验)、manifest 生成
service.ts # 编排:search → dedupe → grid → filter → round stateテストとスクリプト
npm test # 34 个测试:单测 + 真实 MCP stdio 集成测试
npm run smoke -- --query "space nebula" --keywords "nebula,art" --collect "a1,a2" [--iterate "更多星球"]
npm run handshake -- --query "cat" --keywords "cat" # MCP stdio 握手冒烟(先 build)
npx tsx scripts/debug-pi.ts # 诊断:pi 层工具调用(DeepSeek 文本)
npx tsx scripts/debug-vision.ts # 诊断:视觉模型对最近一轮拼图的原始响应注意点
版权:
metadata/manifestはライセンス情報(Wikimedia/Openverse が提供)をそのまま通します。商用素材はご自身で配元の認証を確認してください。ホットリンク保護:一部のサイト(Etsy など)は第三者のダウンロードを拒否します。collect は ID ごとに失敗を報告します。403 の場合はブラウザで直接 URL を開いてください。
巡回対策:アダプタは UA、リクエスト間隔、リトライ回避を備えています。単一のソースが失敗しても全体には影響しません。
フォールバックモード:LLM 資格情報がない場合、
keywordsを明示的に渡す必要があり、自動的なフィルタリングは行われません(全候補が返されます)。
Available Tools
4 toolsimage_search_collectDownload the full images for chosen cell idsA
Download the full-resolution images for a list of round-qualified ids (e.g. ['a3', 'b12']) to the output directory. Returns local file paths plus a manifest with source URLs and licenses.
| Name | Required | Description | Default |
|---|---|---|---|
| ids | Yes | ||
| session_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral burden. It discloses the action (downloads to output directory) and the return format (local paths and manifest with URLs/licenses). It does not mention file overwriting, network requirements, or session validity, but these are minor gaps for a download tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences that are tightly written: the first states the core action, the second states the return value. No filler, and the most important information is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the essential function but omits the purpose of session_id and its relation to the broader search workflow. Without annotations or an output schema, an agent may not know if session_id must come from a prior start/iterate call or whether the output directory is session-scoped. This is incomplete for a multi-step tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description explains 'ids' with an example and meaning (round-qualified ids), but 'session_id' is not explained at all. Since schema description coverage is 0%, the description should have delineated both parameters; it partially compensates but leaves a critical gap on how session_id is used.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb (download), resource (full-resolution images), and target (list of ids) with an example. It clearly distinguishes from siblings (start/iterate/status) which are about session management, not downloading.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage by mentioning 'round-qualified ids' and downloading, but it never explicitly says when to use this tool versus siblings or that it should follow a prior step. The workflow relationship to image_search_start/iterate/status is left to inference, with no exclusions or explicit conditions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
image_search_iterateIterate on an existing search sessionA
Give feedback referencing round-qualified ids (e.g. 'keep a3, more like b7, no photos') plus optional explicit keywords. Produces the next round (b, c, ...) with dedup against all previously shown images. The LLM interprets the feedback into keyword additions/removals via refine_search.
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | ||
| filter | No | false = skip the server-side vision filter for this round | |
| criteria | No | ||
| feedback | Yes | Natural-language feedback; may reference cell ids like a3 / b12 | |
| keywords | No | Explicit keyword replacement; skips LLM feedback interpretation | |
| session_id | Yes | ||
| safe_search | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses dedup against previously shown images and that the LLM interprets feedback into keyword changes via refine_search. However, it doesn't mention side effects like session mutation, reversibility, or any potential rate limits. It covers some key behaviors but not all.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences with zero waste. The primary usage is front-loaded, and the key behaviors (dedup, LLM interpretation) are clearly stated. Very efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with 7 parameters, no output schema, and no annotations, the description is relatively brief. It covers core mechanics but omits details on several parameters and doesn't describe the return value or any side effects. It's adequate but not fully complete for complex usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is only 43%, so the description must compensate for undocumented parameters like count, criteria, safe_search, and session_id. It adds meaning for feedback (referencing cell ids) and keywords (explicit replacement) but does not explain the remaining parameters. The description fails to bridge the coverage gap for those.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: it iterates on an existing search session by taking feedback referencing round-qualified ids, producing the next round with dedup. It distinguishes from siblings by implying it's not for starting a new session (image_search_start) but for refinement, and the title reinforces 'existing'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It gives clear usage instructions: provide feedback with round-qualified ids and optionally explicit keywords. It implies when to use (with an existing session) but does not explicitly mention when not to use or name alternatives. Context from siblings suggests this is for continuation, but the description alone doesn't state exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
image_search_startStart an image search sessionA
Parse a natural-language query into keywords (unless keywords are given), search all configured image providers in parallel, dedupe, render a numbered composite grid (round 'a', cell ids a1..aN), and run a multimodal filter that returns the selected cell ids. Returns the grid file path, the selected ids, the metadata table, and the keywords actually used.
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Max candidates in this round (default: grid capacity) | |
| query | Yes | Natural-language image request, e.g. 'space nebula illustrations for a podcast cover' | |
| filter | No | false = skip the server-side vision filter and return all candidates (use when the calling model is multimodal and will look at the grid itself); default follows FILTER_MODE | |
| criteria | No | Style / quality criteria for filtering, e.g. 'flat vector, no text, dark background' | |
| keywords | No | Explicit search keywords; skips LLM parsing when given | |
| safe_search | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It details the process steps, the return values (grid file path, selected ids, metadata table, keywords used), and explains special behaviors like the 'filter' parameter (false skips filter) and 'keywords' parameter (skips LLM parsing). It also notes the default for filter follows FILTER_MODE. This is transparent, though it does not mention session state persistence or file system side effects beyond returning a path.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences. The first enumerates the pipeline steps without redundancy, and the second lists the return values. It is front-loaded with the core action and contains no filler or repetitive language.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the tool's behavior, parameters, and return values. It does not explain the overall session workflow (e.g., that image_search_iterate follows), but that is arguably outside the scope of a single tool description. The return list compensates for the absent output schema. Completeness is high for the tool's complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 83%, so most parameters are described in the schema. The description adds meaningful context beyond the schema by explaining that 'count' defaults to grid capacity, 'filter=false' skips the vision filter, and 'keywords' skips LLM parsing. It also clarifies the filter default via FILTER_MODE. This enriches the parameter understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a clear verb and resource: 'start an image search session.' It then describes the full pipeline (parse query, search parallel, dedupe, render grid, filter, return results). The action is specific and distinct from siblings like iterate, collect, and status, making it obvious this tool initiates the session.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description does not explicitly state when to use this tool versus its siblings. It does not mention 'use this to begin a session' or direct the agent to image_search_iterate for refinement. While the name implies it is the starting point, there is no explicit guidance on choosing it over alternatives or any exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
image_search_statusShow session stateB
Rounds so far, per-round selections/rejections, current keywords, and collected ids.
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description bears full responsibility for disclosing side effects. It lists what data is returned but does not explicitly state that the operation is read-only or free of side effects. The verb 'show' implies a non-mutating action, but this is not made explicit, leaving some ambiguity.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that front-loads the core purpose ('show session state') and then lists all contents in a compact list. There is no superfluous information, and every item contributes to understanding the returned data.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple status tool with one parameter and no output schema, the description lists the key fields returned, which is helpful. However, it lacks an explicit read-only statement and does not mention error conditions (e.g., invalid session_id), which are important given the absence of annotations. It is adequate but not fully complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description completely ignores the only parameter, session_id, and the schema provides no description for it either. The agent gets no additional context about the format, origin, or purpose of session_id beyond its name, which is insufficient given the 0% schema description coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'show' and the resource 'session state', and then enumerates the specific contents ('rounds so far, per-round selections/rejections, current keywords, and collected ids'). This distinguishes it from sibling tools that start, iterate, or collect, as it is the only one that reports on state.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is given on when to use this tool versus its siblings. It does not mention that it should be used between iterations, nor does it reference alternatives or conditions that would select it. The only hint is the name 'status', which implies a read operation, but there is no explicit context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.1.0- First observed
image_search_collect - First observed
image_search_iterate - First observed
image_search_start - First observed
image_search_status
TDQS
Scored across 4 tools
Each tool has a unique and clearly defined role: start initializes a search, iterate refines it with feedback, collect downloads selected results, and status reports the current state. No two tools overlap in purpose.
All tools follow the exact same `image_search_<verb>` pattern, with verbs that accurately describe the action (start, iterate, collect, status). The naming is uniformly styled and predictable.
Four tools is perfectly scoped for an iterative image search workflow. Each tool covers a necessary step without redundancy, making the set concise and well-balanced.
The tools cover the full lifecycle: initiating a search, refining it through feedback, collecting final results, and monitoring progress. No obvious gaps exist for the intended use case, as the start tool integrates search and multimodal filtering.
Maintenance
Related MCP Connectors
Search Google straight from your AI agent. Web results, images, videos, news, products, scholarly ar
Agent-native search engine with live web research optimized for AI agents.
- GoroOAuthai.usegoro
62 real-world tools for agents: search, scraping, social, enrichment, image, video, voice.
A design-style library for AI agents: search real styles, fetch a ready-to-apply design spec.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to search, download, and analyze Google images via SerpAPI.35 npm19ISC
- AlicenseNot gradedqualityDmaintenanceEnables AI to autonomously search, filter, and download images from the web using natural language commands, with intelligent scoring and local storage.MIT
- FlicenseAqualityBmaintenanceEnables agents to generate images through the GPT Image Playground via a browser extension, supporting task submission, status tracking, and downloading generated images with reference image support.31-
- AlicenseNot gradedqualityBmaintenanceEnables agents to perform structured shopping actions and retrieve targeted product images for visual comparison, matching, and aesthetic recommendations.MIT