Skip to main content
Glama

get_comments

Retrieve comments for a specific Gelbooru post by providing the post ID to access user discussions and feedback.

Instructions

Retrieve comments for a specific Gelbooru post.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYesThe post ID whose comments you want to retrieve.

Implementation Reference

  • The handler function for get_comments tool. It constructs API parameters (page='dapi', s='comment', q='index', post_id from arguments) and calls the _get helper function to fetch comments from Gelbooru API.
    elif name == "get_comments":
        params = {"page": "dapi", "s": "comment", "q": "index", "post_id": arguments["post_id"]}
        result = await loop.run_in_executor(None, _get, params)
  • Tool registration for get_comments. Defines the tool schema with a required post_id parameter (integer) describing which post's comments to retrieve.
    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"],
        },
    ),
  • The _get helper function that performs synchronous HTTP GET requests to the Gelbooru API, handles authentication via environment variables, and returns parsed JSON responses.
    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}

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