Skip to main content
Glama

get_deleted_posts

Retrieve deleted posts from Gelbooru by specifying a starting post ID to fetch content removed above that threshold.

Instructions

Retrieve deleted posts. Pass last_id to get everything deleted above that post ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
last_idNoReturn deleted posts whose ID is above this value.
limitNo

Implementation Reference

  • Handler implementation for get_deleted_posts - constructs API parameters with deleted='show' and optional last_id/limit filters, then calls the _get helper to fetch results from Gelbooru API.
    elif name == "get_deleted_posts":
        params = {"page": "dapi", "s": "post", "q": "index", "deleted": "show"}
        if "last_id" in arguments:
            params["last_id"] = arguments["last_id"]
        if "limit" in arguments:
            params["limit"] = arguments["limit"]
        result = await loop.run_in_executor(None, _get, params)
  • Tool registration with schema definition for get_deleted_posts - defines input parameters (last_id, limit) and their validation rules.
    Tool(
        name="get_deleted_posts",
        description=(
            "Retrieve deleted posts. Pass last_id to get everything deleted "
            "above that post ID."
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "last_id": {
                    "type": "integer",
                    "description": "Return deleted posts whose ID is above this value.",
                },
                "limit": {"type": "integer", "default": 20, "minimum": 1, "maximum": 100},
            },
        },
    ),
  • Helper function _get that performs HTTP GET requests to the Gelbooru API, handles authentication, JSON parsing, and error handling. Used by get_deleted_posts to fetch data.
    def _get(params: dict) -> Any:
        """Perform a synchronous HTTP GET and return parsed JSON."""
        params = {**params, "json": "1"}   # copy — never mutate the caller's dict
        _build_auth(params)
        url = f"{BASE_URL}?{urlencode(params)}"
        req = Request(url, headers={"User-Agent": "GelbooruMCP/1.0"})
        try:
            with urlopen(req, timeout=15) as resp:
                raw = resp.read().decode("utf-8")
        except URLError as exc:
            return {"error": str(exc)}
        try:
            return json.loads(raw)
        except json.JSONDecodeError:
            # Some endpoints return XML/empty on error; surface the raw text
            return {"raw": raw}
  • MCP server list_tools handler that registers all available tools including get_deleted_posts, making it discoverable to clients.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
        return [
            Tool(
                name="search_posts",
                description=(
                    "Search Gelbooru posts by tags, page, limit, or ID. "
                    "Supports all Gelbooru tag syntax: AND (tag1 tag2), OR ({t1~t2}), "
                    "NOT (-tag), wildcards (*tag / tag*), meta-tags like "
                    "rating:safe/questionable/explicit, score:>=N, width:>=N, "
                    "user:name, sort:random, sort:score:desc, etc."
                ),
                inputSchema={
                    "type": "object",
                    "properties": {
                        "tags": {
                            "type": "string",
                            "description": (
                                "Tag query string. Examples: 'cat_ears blue_eyes', "
                                "'touhou -rating:explicit', 'score:>=50 sort:score:desc'"
                            ),
                        },
                        "limit": {
                            "type": "integer",
                            "description": "Number of posts to return (default 20, max 100).",
                            "default": 20,
                            "minimum": 1,
                            "maximum": 100,
                        },
                        "pid": {
                            "type": "integer",
                            "description": "Page number (0-indexed).",
                            "default": 0,
                        },
                        "id": {
                            "type": "integer",
                            "description": "Fetch a single post by its Gelbooru ID.",
                        },
                        "cid": {
                            "type": "integer",
                            "description": "Fetch posts by change ID (Unix timestamp).",
                        },
                    },
                },
            ),
            Tool(
                name="get_deleted_posts",
                description=(
                    "Retrieve deleted posts. Pass last_id to get everything deleted "
                    "above that post ID."
                ),
                inputSchema={
                    "type": "object",
                    "properties": {
                        "last_id": {
                            "type": "integer",
                            "description": "Return deleted posts whose ID is above this value.",
                        },
                        "limit": {"type": "integer", "default": 20, "minimum": 1, "maximum": 100},
                    },
                },
            ),
            Tool(
                name="search_tags",
                description=(
                    "Search Gelbooru tags by name, pattern, or ID. "
                    "Useful for autocomplete, tag counts, and tag type lookup."
                ),
                inputSchema={
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string",
                            "description": "Exact tag name to look up.",
                        },
                        "names": {
                            "type": "string",
                            "description": "Space-separated list of tag names, e.g. 'cat dog fox'.",
                        },
                        "name_pattern": {
                            "type": "string",
                            "description": (
                                "Wildcard tag search using SQL LIKE syntax. "
                                "Use % for multi-char wildcard, _ for single-char. "
                                "Example: '%choolgirl%'"
                            ),
                        },
                        "id": {
                            "type": "integer",
                            "description": "Look up a tag by its database ID.",
                        },
                        "after_id": {
                            "type": "integer",
                            "description": "Return tags whose ID is greater than this value.",
                        },
                        "limit": {"type": "integer", "default": 20, "minimum": 1, "maximum": 100},
                        "order": {
                            "type": "string",
                            "enum": ["ASC", "DESC"],
                            "description": "Sort direction.",
                        },
                        "orderby": {
                            "type": "string",
                            "enum": ["date", "count", "name"],
                            "description": "Field to sort by.",
                        },
                    },
                },
            ),
            Tool(
                name="search_users",
                description="Search Gelbooru users by name or name pattern.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string",
                            "description": "Exact username to search for.",
                        },
                        "name_pattern": {
                            "type": "string",
                            "description": "Wildcard username search (SQL LIKE syntax).",
                        },
                        "limit": {"type": "integer", "default": 20, "minimum": 1, "maximum": 100},
                        "pid": {"type": "integer", "default": 0},
                    },
                },
            ),
            Tool(
                name="get_comments",
                description="Retrieve comments for a specific Gelbooru post.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "post_id": {
                            "type": "integer",
                            "description": "The post ID whose comments you want to retrieve.",
                        },
                    },
                    "required": ["post_id"],
                },
            ),
            Tool(
                name="get_character_tags",
                description=(
                    "Given a character name (e.g. 'misty_(pokemon)'), fetches the top "
                    "highest-scored general/solo posts across multiple pages and returns "
                    "the most frequently occurring tags split into three semantic buckets: "
                    "eye colour/shape, hair colour/style, and other character traits. "
                    "Each tag includes a frequency score. Results are cached to disk for 24 hours."
                ),
                inputSchema={
                    "type": "object",
                    "properties": {
                        "character_name": {
                            "type": "string",
                            "description": (
                                "The Gelbooru tag for the character, e.g. 'misty_(pokemon)', "
                                "'rem_(re:zero)', 'saber_(fate)'. Use underscores as Gelbooru does."
                            ),
                        },
                        "max_images": {
                            "type": "integer",
                            "description": (
                                "How many top-scored posts to analyse across all pages "
                                "(default 300). More images = slower but more reliable results. "
                                "Fetched in pages of 100."
                            ),
                            "default": 300,
                            "minimum": 10,
                        },
                    },
                    "required": ["character_name"],
                },
            ),
            Tool(
                name="build_prompt",
                description=(
                    "Given a character name, returns a ready-to-use image-generation prompt "
                    "string like 'misty (pokemon), green eyes, orange hair, side ponytail, ...'. "
                    "Internally calls get_character_tags with caching, then assembles the prompt "
                    "with tags ordered by frequency (eye → hair → other)."
                ),
                inputSchema={
                    "type": "object",
                    "properties": {
                        "character_name": {
                            "type": "string",
                            "description": (
                                "The Gelbooru tag for the character, e.g. 'misty_(pokemon)'. "
                                "Use underscores as Gelbooru does."
                            ),
                        },
                        "max_images": {
                            "type": "integer",
                            "description": "Posts to analyse (default 300). Cached after first fetch.",
                            "default": 300,
                            "minimum": 10,
                        },
                        "include_other": {
                            "type": "boolean",
                            "description": (
                                "Whether to include non-eye/hair tags (clothing, accessories, etc.) "
                                "in the prompt. Default true."
                            ),
                            "default": True,
                        },
                    },
                    "required": ["character_name"],
                },
            ),
        ]

Latest Blog Posts

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