Danbooru Tag RAG MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Danbooru Tag RAG MCP ServerGenerate a prompt for a magical girl with flowing pink hair."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Danbooru Tag RAG MCP Server
Danbooruタグのセマンティック検索を提供するMCP (Model Context Protocol) サーバーです。
概要
このMCPサーバーは、自然言語のクエリからDanbooruタグを検索する機能を提供します。SDXLアニメモデルはDanbooruタグで学習されているため、適切なタグを使用することで画像生成の精度が向上します。
特徴
セマンティック検索: キーワード一致ではなく、意味的に関連するタグを検索
日本語・英語対応: multilingual-e5-small モデルによる多言語サポート
ローカル実行: 外部APIを使用せず、完全にローカルで動作
軽量: LanceDBによる効率的なベクトル検索
Related MCP server: RAG-MCP Knowledge Base Server
技術スタック
コンポーネント | 技術 | 理由 |
MCP SDK | mcp (公式SDK) | 標準プロトコル準拠 |
ベクトルDB | LanceDB | 軽量、ローカル実行に最適 |
埋め込みモデル | multilingual-e5-small | 日英対応、高精度、CPU対応 |
パッケージ管理 | uv | モダンで高速 |
インストール
Claude Desktopの設定ファイル(claude_desktop_config.json)に以下を追加:
{
"mcpServers": {
"danbooru-rag": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Zaozaotvk40/danbooru-rag-mcp.git", "danbooru-rag-mcp"]
}
}
}初回起動時にインデックスが自動構築されます(約60,000タグ、数分かかります)。
使用例
Claude Desktopでこのツールを有効にすると、自然言語でプロンプト生成を依頼できます。
例1: キャラクター描写
あなた: 「青い髪のツインテールの女の子が魔法を使っているシーンのプロンプトを作って」
Claude: semantic_searchで関連タグを検索し、以下のようなプロンプトを生成します:
→ 1girl, blue hair, twintails, magic, casting spell, glowing, magical effects, ...例2: 風景シーン
あなた: 「夕焼けのファンタジー風景のプロンプトをお願い」
Claude: 関連タグを検索して組み合わせます:
→ scenery, sunset, fantasy, sky, clouds, orange sky, landscape, no humans, ...例3: 複雑なシーン
あなた: 「カフェで本を読んでいる眼鏡の女の子、窓から光が差し込んでいる感じで」
Claude: 複数の要素を検索して統合します:
→ 1girl, glasses, book, reading, cafe, indoors, window, sunlight, sitting, ...Claudeが自動的にsemantic_searchツールを使用し、Danbooruタグに基づいた画像生成プロンプトを作成します。
プロジェクト構造
danbooru-rag-mcp/
├── README.md # このファイル
├── pyproject.toml # パッケージ設定
├── danbooru-tags.txt # ソースデータ
├── src/
│ └── danbooru_rag/
│ ├── __init__.py # パッケージ初期化
│ ├── __main__.py # モジュールエントリーポイント
│ ├── config.py # 設定定数
│ ├── embeddings.py # 埋め込み生成
│ ├── database.py # LanceDB操作
│ ├── builder.py # インデックス自動構築
│ └── server.py # MCPサーバー本体
├── scripts/
│ └── build_index.py # インデックス手動構築
└── tests/
└── ... # テストデータベース保存先:
Windows:
%LOCALAPPDATA%\danbooru-rag\lancedbmacOS:
~/Library/Application Support/danbooru-rag/lancedbLinux:
~/.local/share/danbooru-rag/lancedb
設計判断
なぜmultilingual-e5-smallか?
日本語・英語両対応: ユーザーがどちらの言語でクエリしても対応
高精度: all-MiniLM-L6-v2より高いベンチマークスコア
CPU対応: GPUなしでも実用的な速度で動作
E5プレフィックス: query:/passage: プレフィックスで精度向上
なぜLanceDBか?
サーバー不要: ファイルベースでローカル実行に最適
Pythonネイティブ: 簡単にインストール・使用可能
高速: ベクトル検索に最適化
なぜ出現頻度100以下をフィルタリングするか?
学習データの品質: 低頻度タグはSDXLモデルの学習が不十分
インデックス効率: 99,999件 → 約60,000件に削減
検索精度向上: ノイズとなる低頻度タグを除外
開発
テスト実行
uv run pytest tests/コード品質
# 型チェック
uv run mypy src/
# フォーマット
uv run ruff format src/
# リント
uv run ruff check src/ライセンス
MIT License
データソース
danbooru-tags.txt は ComfyUI-Custom-Scripts で利用されている以下のデータをベースにしています:
オリジナルのタグ名はアンダーバー区切り(例: blue_hair)ですが、本プロジェクトではスペース区切り(例: blue hair)に変換して使用しています。
謝辞
ComfyUI-Custom-Scripts - Danbooruタグデータの提供元
Model Context Protocol - LLMツール統合の標準プロトコル
LanceDB - 高速ベクトルデータベース
Sentence Transformers - 埋め込みモデルライブラリ
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Zaozaotvk40/danbooru-rag-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server