Skip to main content
Glama
Jij-Inc

Jij MCP Server

Official
by Jij-Inc

fetch_as_markdown

Convert website HTML to Markdown format by fetching content from a URL, enabling structured text extraction for documentation or analysis.

Instructions

Fetch a website, convert its HTML content to Markdown, and return it.

Args:
    url (str): URL of the website to fetch.
    headers (Optional[dict[str, str]]): Custom headers for the request.

Returns:
    FetchResponse: An object containing the Markdown content or an error message.
                   On success, isError is false and content contains the Markdown text.
                   On failure, isError is true and errorMessage contains the error details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
headersNo

Implementation Reference

  • The main handler function for the 'fetch_as_markdown' MCP tool, registered with @mcp.tool(). It constructs FetchRequestArgs and delegates to Fetcher.markdown.
    @mcp.tool()
    async def fetch_as_markdown(
        url: str, headers: typ.Optional[dict[str, str]] = None
    ) -> FetchResponse:
        """
        Fetch a website, convert its HTML content to Markdown, and return it.
    
        Args:
            url (str): URL of the website to fetch.
            headers (Optional[dict[str, str]]): Custom headers for the request.
    
        Returns:
            FetchResponse: An object containing the Markdown content or an error message.
                           On success, isError is false and content contains the Markdown text.
                           On failure, isError is true and errorMessage contains the error details.
        """
        args = FetchRequestArgs(url=url, headers=headers)
        return await Fetcher.markdown(args)
  • Pydantic schema for input arguments (url and optional headers) used by fetch_as_markdown.
    class FetchRequestArgs(BaseModel):
        """Input arguments schema for fetch tools."""
    
        url: HttpUrl = Field(..., description="URL of the content to fetch.")
        headers: Optional[dict[str, str]] = Field(
            default=None, description="Optional headers to include in the request."
        )
  • Pydantic schema for the response, including content, error flag, and message.
    class FetchResponse(BaseModel):
        content: list[dict[str, str]]  # MCP標準のcontent形式に合わせる
        isError: bool = False
        errorMessage: Optional[str] = None
  • Core helper method that fetches HTML, converts it to markdown using markdownify.MarkdownConverter (customized to skip images), handles encoding and errors.
    async def markdown(payload: FetchRequestArgs) -> FetchResponse:
        """Fetches content and converts it to Markdown."""
        try:
            response = await Fetcher._fetch(payload)
            html_content = await response.aread()
            # Decode carefully before passing to markdownify
            try:
                html_text = html_content.decode("utf-8")
            except UnicodeDecodeError:
                detected_encoding = response.encoding or "iso-8859-1"
                html_text = html_content.decode(detected_encoding, errors="replace")
    
            # Use custom NoImagesConverter to ignore images
            converter = NoImagesConverter()
            md = converter.convert(html_text)
    
            return FetchResponse(content=[{"type": "text", "text": md}], isError=False)
        except Exception as e:
            return FetchResponse(content=[], isError=True, errorMessage=str(e))
  • Custom MarkdownConverter subclass that skips image tags during HTML to Markdown conversion.
    class NoImagesConverter(MarkdownConverter):
        """
        Create a custom MarkdownConverter that ignores all images during conversion
        """
    
        def convert_img(self, el, text, parent_tags):
            # Return empty string instead of converting the image
            return ""
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the tool's core behavior (fetching, HTML-to-Markdown conversion, error handling) but lacks details about rate limits, authentication needs, timeout behavior, or what happens with malformed URLs. The error response structure is described, which adds value.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement followed by Args and Returns sections. Every sentence adds value, though the Returns section could be more concise by avoiding repetition of error details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 2 parameters, no annotations, and no output schema, the description provides adequate coverage of the core functionality and parameters. However, it lacks details about behavioral constraints (e.g., network timeouts, size limits) and doesn't fully explain the FetchResponse structure beyond success/error states.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It clearly explains both parameters: 'url' as the website URL to fetch and 'headers' as optional custom request headers. This adds meaningful context beyond the bare schema, though it doesn't specify header format examples or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('fetch', 'convert', 'return') and resource ('website HTML content to Markdown'). It distinguishes itself from sibling tools by focusing on web content conversion rather than quantum computing or modeling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context (fetching and converting web content) but doesn't explicitly state when to use this tool versus alternatives. No guidance on prerequisites, limitations, or comparison with other web-fetching tools is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Jij-Inc/Jij-MCP-Server'

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