Gelbooru MCP
This server connects AI assistants to the Gelbooru API, enabling image search, tag exploration, and Stable Diffusion prompt generation from real character appearance data.
Search Posts (
search_posts): Search images using full Gelbooru tag syntax — AND/OR/NOT logic, wildcards, meta-tags (rating, score, resolution, user), sorting (score, random, updated), and pagination.Search Tags (
search_tags): Look up tags by exact name, wildcard pattern, or ID. Returns post counts, tag types, and supports sorting by date, count, or name.Search Users (
search_users): Find user accounts by exact username or wildcard pattern.Get Comments (
get_comments): Retrieve all comments on a specific post by ID.Get Deleted Posts (
get_deleted_posts): List deleted posts, optionally filtered by alast_idto track recently removed content.Get Character Tags (
get_character_tags): Analyze top-scored posts for a character and return frequently occurring tags categorized into eye, hair, and other (clothing/accessories) buckets with frequency scores. Results are disk-cached for 24 hours.Build Stable Diffusion Prompt (
build_prompt): Auto-generate a ready-to-use prompt string (e.g.misty (pokemon), green eyes, orange hair, side ponytail, ...) from real Gelbooru tag frequency data, with optional inclusion of clothing/accessory tags.
gelbooru-mcp
A Python MCP server that wraps the Gelbooru API. Connect it to any MCP-compatible client (Claude Desktop, Cursor, etc.) to search posts, look up tags, and generate Stable Diffusion prompts from real character appearance data — all directly from your AI assistant.
✨ Features
🎨 Stable Diffusion Prompt Generation
Character Prompts: Auto-generate accurate SD prompts from real Gelbooru tag frequency data
Appearance Breakdown: Separate eye, hair, and clothing/accessory tag categories
Smart Caching: Results cached for 24 hours — no repeated API hits
🔍 Post & Tag Search
Advanced Filtering: Search by tags, score, resolution, rating, uploader, pool, and more
Full Tag Syntax: AND, OR, wildcard, exclusion, meta-tags, sorting, and pagination
Tag Lookup: Check tag existence, post counts, and discover related tags
👥 Community Tools
User Search: Find Gelbooru user accounts by name or wildcard pattern
Comments: Retrieve post comments for any post ID
Deleted Posts: Track removed content above a given post ID
Related MCP server: MyAnimeList MCP Server
📦 Installation
Prerequisites
Python 3.10+
git
Quick Start
Clone the repository:
git clone https://github.com/citronlegacy/gelbooru-mcp.git
cd gelbooru-mcpRun the installer:
chmod +x install.sh && ./install.sh
# or without chmod:
bash install.shOr install manually:
pip install mcpNote: Add
.gelbooru_cache/and.venv/to your.gitignoreto avoid committing cached data or your virtual environment.
Getting a Gelbooru API Key
Visit your Gelbooru account options page
Log in to your Gelbooru account
Copy your API Key and User ID
Set them as environment variables (see below)
🔑 Authentication
API credentials are optional but strongly recommended — unauthenticated requests are throttled and limited to 2 tags per query. Gelbooru Patreon supporters receive unlimited requests.
export GELBOORU_API_KEY="your_api_key"
export GELBOORU_USER_ID="your_user_id"Both values are on your Gelbooru account options page. Without them the server still works but requests may be throttled. Patreon supporters of Gelbooru are not rate-limited.
▶️ Running the Server
python gelbooru_mcp.py
# or via the venv created by install.sh:
.venv/bin/python gelbooru_mcp.py⚙️ Configuration
Claude Desktop
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"gelbooru-mcp": {
"command": "/absolute/path/to/.venv/bin/python",
"args": ["/absolute/path/to/gelbooru_mcp.py"],
"env": {
"GELBOORU_API_KEY": "your_api_key",
"GELBOORU_USER_ID": "your_user_id"
}
}
}
}Other MCP Clients
Configure according to your client's documentation:
Command:
/absolute/path/to/.venv/bin/pythonArgs:
/absolute/path/to/gelbooru_mcp.pyTransport: stdio
💡 Usage Examples
Generate a Stable Diffusion prompt for a character
"Build me a Stable Diffusion prompt for Rem from Re:Zero."
The LLM calls build_prompt with character_name: "rem_(re:zero)" and gets back:
rem (re:zero), blue eyes, blue hair, short hair, maid, maid headdress, maid apron, ...Find high-quality wallpaper images
"Show me the top-rated scenery images that are at least 1920px wide."
The LLM calls search_posts with tags: "scenery width:>=1920 sort:score:desc".
Look up how popular a tag is
"How many posts does the tag 'misty_(pokemon)' have on Gelbooru?"
The LLM calls search_tags with name: "misty_(pokemon)" and reads the count field.
🛠️ Available Tools
Tool | Description | Key Parameters |
| Generate a Stable Diffusion prompt string for a character |
|
| Get structured tag breakdown with frequency counts |
|
| Search posts with full tag syntax support |
|
| Look up tags by name, pattern, or ID |
|
| Find Gelbooru user accounts |
|
| Retrieve comments for a post |
|
| List recently deleted posts |
|
📖 Tools Reference
build_prompt
Fetches the most-tagged rating:general solo posts for a character and assembles a ready-to-paste Stable Diffusion prompt string. Internally calls get_character_tags so results are cached after the first fetch.
Parameters
Parameter | Type | Required | Default | Description |
| string | ✅ | — | Gelbooru character tag, e.g. |
| integer | ❌ |
| Posts to analyse. More = slower first fetch, more reliable tags. Cached afterward. |
| boolean | ❌ |
| Include non-eye/hair tags (clothing, accessories, etc.). Set to |
Example response
{
"prompt": {
"character": "misty (pokemon)",
"posts_analysed": 284,
"cache_hit": false,
"prompt_string": "misty (pokemon), green eyes, orange hair, side ponytail, gym leader, shorts, suspenders",
"tags": {
"eye": ["green eyes"],
"hair": ["orange hair", "side ponytail"],
"other": ["gym leader", "shorts", "suspenders"]
}
}
}LLM Tip: Always use Gelbooru's underscore format (
misty_(pokemon)notMisty (Pokemon)). If unsure of the exact tag, callsearch_tagswithname_patternfirst.
get_character_tags
Same data source as build_prompt but returns the full structured tag breakdown with frequency counts. Use this when you want to inspect, filter, or reformat tags yourself.
Parameters
Parameter | Type | Required | Default | Description |
| string | ✅ | — | Gelbooru character tag, e.g. |
| integer | ❌ |
| Number of top-scored posts to analyse. |
Example response
{
"character_tags": {
"name": "rem_(re:zero)",
"posts_analysed": 300,
"cache_hit": true,
"eye": [
{ "tag": "blue eyes", "count": 261, "frequency": 0.87 }
],
"hair": [
{ "tag": "blue hair", "count": 274, "frequency": 0.913 },
{ "tag": "short hair", "count": 198, "frequency": 0.66 }
],
"other": [
{ "tag": "maid", "count": 231, "frequency": 0.77 }
]
}
}frequency is the fraction of analysed posts that had that tag (0.0–1.0). Tags near 1.0 are near-universal; tags below 0.3 are situational.
Cache environment variables:
Env var | Default | Description |
|
| Custom cache folder path |
|
| Cache lifetime in seconds |
search_posts
Search Gelbooru posts using any tag combination. Supports the full Gelbooru tag syntax including meta-tags, sorting, and filtering.
Parameters
Parameter | Type | Required | Default | Description |
| string | ❌ | — | Tag query string (see Tag Syntax Reference below) |
| integer | ❌ |
| Posts to return (max |
| integer | ❌ |
| Page number (0-indexed) for pagination |
| integer | ❌ | — | Fetch a single post by its Gelbooru post ID |
| integer | ❌ | — | Fetch posts by change ID (Unix timestamp) |
get_deleted_posts
Retrieve posts that have been deleted from Gelbooru, optionally filtered to those above a given post ID.
Parameters
Parameter | Type | Required | Default | Description |
| integer | ❌ | — | Only return deleted posts whose ID is above this value. Useful for syncing a local mirror. |
| integer | ❌ |
| Posts to return (max |
search_tags
Look up Gelbooru tags by name, wildcard pattern, or ID. Useful for checking tag existence, finding post counts, discovering related tags, or autocomplete.
Parameters
Parameter | Type | Required | Default | Description |
| string | ❌ | — | Exact tag name, e.g. |
| string | ❌ | — | Space-separated list of exact tag names, e.g. |
| string | ❌ | — | SQL LIKE wildcard: |
| integer | ❌ | — | Look up a tag by its database ID |
| integer | ❌ | — | Return tags with ID greater than this value |
| integer | ❌ |
| Tags to return (max |
| string | ❌ | — |
|
| string | ❌ | — | Sort field: |
LLM Tip: If the user gives a character name in natural language (e.g. "Misty from Pokemon"), use
name_patternwith%misty%_(pokemon)%to find the correct Gelbooru tag before callingget_character_tagsorbuild_prompt.
search_users
Search for Gelbooru user accounts by name.
Parameters
Parameter | Type | Required | Default | Description |
| string | ❌ | — | Exact username |
| string | ❌ | — | SQL LIKE wildcard username search |
| integer | ❌ |
| Results to return (max |
| integer | ❌ |
| Page number for pagination |
get_comments
Retrieve comments on a specific post.
Parameters
Parameter | Type | Required | Default | Description |
| integer | ✅ | — | The Gelbooru post ID to fetch comments for |
🏷️ Tag Syntax Reference
Syntax | Meaning |
| Posts with both tag1 AND tag2 |
| Posts with tag1 OR tag2 OR tag3 |
| Exclude posts with tag1 |
| Wildcard prefix (tags ending with tag1) |
| Wildcard suffix (tags starting with tag1) |
| Filter by rating: |
| Exclude a rating |
| Score at least 50 |
| Image width ≥ 1920px |
| Image height > 1080px |
| Uploaded by user "bob" |
| Posts favourited by user with ID 1 |
| Posts in pool ID 2 |
| Sort by score (desc or asc) |
| Random order on every request |
| Random order with a fixed seed (0–10000) |
| Sort by most recently updated |
🤖 Notes for LLMs
Character tag format: Gelbooru uses
character_(series)format with underscores. Always convert natural language names before passing to tools — "Rem from Re:Zero" →rem_(re:zero), "Saber from Fate" →saber_(fate).Workflow for character prompts: If the exact tag is unknown, call
search_tagswithname_patternfirst → confirm the tag exists and has posts → then callbuild_prompt.Pagination:
search_postsreturns max 100 results per call. Usepidto walk through pages.get_character_tagsandbuild_prompthandle their own pagination internally.Cache:
get_character_tagsandbuild_promptcache results for 24 hours. Thecache_hitfield in the response indicates whether live or cached data was used.Ratings: Gelbooru uses
general,questionable, andexplicit.get_character_tagsandbuild_promptalways filter torating:generalfor cleaner, more representative character data.
⚠️ Known Limitations
Tag search limit: Gelbooru enforces a maximum of 2 tags per unauthenticated search query. For complex multi-tag queries, set
GELBOORU_API_KEYandGELBOORU_USER_ID.get_character_tagsaccuracy: Results depend on how consistently a character is tagged on Gelbooru. Niche or recently added characters may have fewer posts and less reliable frequency data.rating:generalonly for character tools:build_promptandget_character_tagsintentionally restrict torating:generalfor clean, representative appearance data. Explicit posts are excluded by design.Cache is per
(character_name, max_images)pair: Changingmax_imagesbusts the cache for that character.
🐛 Troubleshooting
Server won't start:
Ensure Python 3.10+ is installed:
python --versionVerify the virtual environment was created:
ls .venv/Re-run the installer:
bash install.sh
API rate limiting / throttled requests:
Set
GELBOORU_API_KEYandGELBOORU_USER_IDenvironment variablesGelbooru Patreon supporters receive unlimited requests
Character not found / empty results:
Confirm the tag exists with
search_tagsusingname_patternCheck spelling — Gelbooru uses
character_(series)underscore formatSome characters may have very few consistently tagged posts
Tag syntax errors / too many tags:
Unauthenticated users are limited to 2 tags per query
Authenticate with API credentials for complex multi-tag searches
🤝 Contributing
Pull requests are welcome! If you find a character tag being miscategorised (e.g. a hair style tag missing from the hair bucket, or a noise tag slipping through the purge filter), please open an issue or PR with the tag and which list it belongs in.
Development Setup
Fork the repository
Create a feature branch
Make your changes
Submit a pull request
📄 License
MIT License — see LICENSE for details.
🔗 Links
Maintenance
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server for the DeepGHS anime AI ecosystem. Dataset discovery, tag search, character dataset finder, and training pipeline code generation.Last updated81MIT
- AlicenseBqualityDmaintenanceMCP Server for interacting with the MyAnimeList API, allowing LLM clients to access and interact with anime, manga and more.Last updated152MIT
- AlicenseAqualityBmaintenanceMulti-provider image generation MCP server that enables image generation from Claude Desktop, Claude Code, or any MCP client using OpenAI, Google Gemini, Stable Diffusion, or a placeholder provider.Last updated101MIT
- AlicenseBqualityAmaintenanceAn MCP server that connects AI assistants to the PixelLab pixel art generation API. Generate sprites, tilesets, characters, animations, and more directly from Claude, Cursor, or any MCP-compatible client.Last updated84291MIT
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
An MCP server that gives your AI access to the source code and docs of all public github repos
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/citronlegacy/gelbooru-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server