Skip to main content
Glama
aserper

RTFD (Read The F*****g Docs)

by aserper

fetch_docker_image_docs

Retrieve Docker image documentation from DockerHub to understand container usage, environment variables, volume mounts, and configuration examples.

Instructions

        Fetch actual Docker image documentation and README from DockerHub.

        USE THIS WHEN: You need usage instructions, environment variables, volume mounts, or examples.

        BEST FOR: Understanding how to use a Docker image and configure it properly.
        Better than using curl or WebFetch because it:
        - Extracts README content from DockerHub
        - Includes image description and key details
        - Formats content in readable Markdown
        - Prioritizes important sections (Usage, Environment Variables, Examples)

        Typical content includes:
        - How to run the container
        - Available environment variables
        - Volume mount points
        - Port configurations
        - Usage examples and docker-compose snippets

        Args:
            image: Docker image name (e.g., "nginx", "postgres", "redis")
            max_bytes: Maximum content size, default 20KB (increase for detailed docs)

        Returns:
            JSON with README content, size, and source info

        Example: fetch_docker_image_docs("nginx") → Returns README with usage instructions
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes
max_bytesNo

Implementation Reference

  • The main MCP tool handler function `fetch_docker_image_docs` that orchestrates fetching the Docker image documentation by delegating to the private `_fetch_image_docs` helper and serializing the response.
    async def fetch_docker_image_docs(image: str, max_bytes: int = 20480) -> CallToolResult:
        """
        Fetch actual Docker image documentation and README from DockerHub.
    
        USE THIS WHEN: You need usage instructions, environment variables, volume mounts, or examples.
    
        BEST FOR: Understanding how to use a Docker image and configure it properly.
        Better than using curl or WebFetch because it:
        - Extracts README content from DockerHub
        - Includes image description and key details
        - Formats content in readable Markdown
        - Prioritizes important sections (Usage, Environment Variables, Examples)
    
        Typical content includes:
        - How to run the container
        - Available environment variables
        - Volume mount points
        - Port configurations
        - Usage examples and docker-compose snippets
    
        Args:
            image: Docker image name (e.g., "nginx", "postgres", "redis")
            max_bytes: Maximum content size, default 20KB (increase for detailed docs)
    
        Returns:
            JSON with README content, size, and source info
    
        Example: fetch_docker_image_docs("nginx") → Returns README with usage instructions
        """
        result = await self._fetch_image_docs(image, max_bytes)
        return serialize_response_with_meta(result)
  • Core helper method `_fetch_image_docs` that fetches image metadata, extracts and formats README/description content, handles truncation, and returns structured documentation data.
    async def _fetch_image_docs(self, image: str, max_bytes: int = 20480) -> dict[str, Any]:
        """Fetch documentation for a Docker image.
    
        Args:
            image: Image name (e.g., 'nginx', 'postgres', 'myuser/myimage')
            max_bytes: Maximum content size in bytes
    
        Returns:
            Dict with documentation content
        """
        try:
            metadata = await self._fetch_image_metadata(image)
    
            # Check if we got an error
            if "error" in metadata:
                return {
                    "image": image,
                    "content": "",
                    "error": metadata["error"],
                    "size_bytes": 0,
                    "source": None,
                }
    
            # Extract readme if available
            readme = metadata.get("readme", "")
            description = metadata.get("description", "")
    
            # Combine description and readme
            content = ""
            if description:
                content = f"## Description\n\n{description}\n\n"
            if readme:
                content += f"## README\n\n{readme}"
            elif not description:
                content = "No documentation available for this image."
    
            # Truncate if necessary
            content_bytes = content.encode("utf-8")
            if len(content_bytes) > max_bytes:
                content = content[:max_bytes]
                truncated = True
            else:
                truncated = False
    
            return {
                "image": image,
                "content": content,
                "size_bytes": len(content.encode("utf-8")),
                "source": "dockerhub",
                "truncated": truncated,
            }
    
        except Exception as exc:
            return {
                "image": image,
                "content": "",
                "error": f"Failed to fetch docs: {exc!s}",
                "size_bytes": 0,
                "source": None,
            }
  • Tool registration within the `get_tools` method where `fetch_docker_image_docs` is conditionally added to the tools dictionary if fetching is enabled.
    tools = {
        "search_docker_images": search_docker_images,
        "docker_image_metadata": docker_image_metadata,
    }
    if is_fetch_enabled():
        tools["fetch_docker_image_docs"] = fetch_docker_image_docs
        tools["fetch_dockerfile"] = fetch_dockerfile
    
    return tools
  • Tool name registration in the `get_metadata` method where "fetch_docker_image_docs" is conditionally appended to the list of exposed tool names.
    def get_metadata(self) -> ProviderMetadata:
        tool_names = ["search_docker_images", "docker_image_metadata"]
        if is_fetch_enabled():
            tool_names.append("fetch_docker_image_docs")
            tool_names.append("fetch_dockerfile")
    
        return ProviderMetadata(
            name="dockerhub",
            description="DockerHub Docker image search and metadata",
            expose_as_tool=True,
            tool_names=tool_names,
            supports_library_search=False,  # DockerHub search is image-centric, not lib-doc
            required_env_vars=[],
            optional_env_vars=[],
        )

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/aserper/RTFD'

If you have feedback or need assistance with the MCP directory API, please join our Discord server