Skip to main content
Glama
daniel-levesque

AWS Documentation MCP Server

read_documentation

Retrieve AWS documentation pages and convert them to markdown format for easier reading and integration. Supports chunked reading for long documents.

Instructions

Fetch and convert an AWS documentation page to markdown format.

Usage

This tool retrieves the content of an AWS documentation page and converts it to markdown format. For long documents, you can make multiple calls with different start_index values to retrieve the entire content in chunks.

URL Requirements

  • Must be from the docs.aws.amazon.com domain

  • Must end with .html

Example URLs

  • https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html

  • https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html

Output Format

The output is formatted as markdown text with:

  • Preserved headings and structure

  • Code blocks for examples

  • Lists and tables converted to markdown format

Handling Long Documents

If the response indicates the document was truncated, you have several options:

  1. Continue Reading: Make another call with start_index set to the end of the previous response

  2. Stop Early: For very long documents (>30,000 characters), if you've already found the specific information needed, you can stop reading

Args: ctx: MCP context for logging and error handling url: URL of the AWS documentation page to read max_length: Maximum number of characters to return start_index: On return output starting at this character index

Returns: Markdown content of the AWS documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL of the AWS documentation page to read
max_lengthNoMaximum number of characters to return.
start_indexNoOn return output starting at this character index, useful if a previous fetch was truncated and more content is required.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler implementation that fetches the documentation page, handles errors, extracts content from HTML if needed, formats the result with pagination support, and returns markdown content.
    async def read_documentation_impl(
        ctx: Context,
        url_str: str,
        max_length: int,
        start_index: int,
        session_uuid: str,
    ) -> str:
        """The implementation of the read_documentation tool."""
        logger.debug(f'Fetching documentation from {url_str}')
    
        url_with_session = f'{url_str}?session={session_uuid}'
    
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(
                    url_with_session,
                    follow_redirects=True,
                    headers={
                        'User-Agent': DEFAULT_USER_AGENT,
                        'X-MCP-Session-Id': session_uuid,
                    },
                    timeout=30,
                )
            except httpx.HTTPError as e:
                error_msg = f'Failed to fetch {url_str}: {str(e)}'
                logger.error(error_msg)
                await ctx.error(error_msg)
                return error_msg
    
            if response.status_code >= 400:
                error_msg = f'Failed to fetch {url_str} - status code {response.status_code}'
                logger.error(error_msg)
                await ctx.error(error_msg)
                return error_msg
    
            page_raw = response.text
            content_type = response.headers.get('content-type', '')
    
        if is_html_content(page_raw, content_type):
            content = extract_content_from_html(page_raw)
        else:
            content = page_raw
    
        result = format_documentation_result(url_str, content, start_index, max_length)
    
        # Log if content was truncated
        if len(content) > start_index + max_length:
            logger.debug(
                f'Content truncated at {start_index + max_length} of {len(content)} characters'
            )
    
        return result
  • Registration and handler for the read_documentation tool in the global AWS documentation server. Includes schema validation for URL (docs.aws.amazon.com, .html), parameters with Pydantic Fields, and delegation to the core impl.
    @mcp.tool()
    async def read_documentation(
        ctx: Context,
        url: str = Field(description='URL of the AWS documentation page to read'),
        max_length: int = Field(
            default=5000,
            description='Maximum number of characters to return.',
            gt=0,
            lt=1000000,
        ),
        start_index: int = Field(
            default=0,
            description='On return output starting at this character index, useful if a previous fetch was truncated and more content is required.',
            ge=0,
        ),
    ) -> str:
        """Fetch and convert an AWS documentation page to markdown format.
    
        ## Usage
    
        This tool retrieves the content of an AWS documentation page and converts it to markdown format.
        For long documents, you can make multiple calls with different start_index values to retrieve
        the entire content in chunks.
    
        ## URL Requirements
    
        - Must be from the docs.aws.amazon.com domain
        - Must end with .html
    
        ## Example URLs
    
        - https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
        - https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html
    
        ## Output Format
    
        The output is formatted as markdown text with:
        - Preserved headings and structure
        - Code blocks for examples
        - Lists and tables converted to markdown format
    
        ## Handling Long Documents
    
        If the response indicates the document was truncated, you have several options:
    
        1. **Continue Reading**: Make another call with start_index set to the end of the previous response
        2. **Stop Early**: For very long documents (>30,000 characters), if you've already found the specific information needed, you can stop reading
    
        Args:
            ctx: MCP context for logging and error handling
            url: URL of the AWS documentation page to read
            max_length: Maximum number of characters to return
            start_index: On return output starting at this character index
    
        Returns:
            Markdown content of the AWS documentation
        """
        # Validate that URL is from docs.aws.amazon.com and ends with .html
        url_str = str(url)
        if not re.match(r'^https?://docs\.aws\.amazon\.com/', url_str):
            await ctx.error(f'Invalid URL: {url_str}. URL must be from the docs.aws.amazon.com domain')
            raise ValueError('URL must be from the docs.aws.amazon.com domain')
        if not url_str.endswith('.html'):
            await ctx.error(f'Invalid URL: {url_str}. URL must end with .html')
            raise ValueError('URL must end with .html')
    
        return await read_documentation_impl(ctx, url_str, max_length, start_index, SESSION_UUID)
  • Registration and handler for the read_documentation tool in the AWS China documentation server. Includes schema validation for URL (docs.amazonaws.cn, .html), parameters with Pydantic Fields, and delegation to the core impl.
    @mcp.tool()
    async def read_documentation(
        ctx: Context,
        url: Union[AnyUrl, str] = Field(description='URL of the AWS China documentation page to read'),
        max_length: int = Field(
            default=5000,
            description='Maximum number of characters to return.',
            gt=0,
            lt=1000000,
        ),
        start_index: int = Field(
            default=0,
            description='On return output starting at this character index, useful if a previous fetch was truncated and more content is required.',
            ge=0,
        ),
    ) -> str:
        """Fetch and convert an AWS China documentation page to markdown format.
    
        ## Usage
    
        This tool retrieves the content of an AWS China documentation page and converts it to markdown format.
        For long documents, you can make multiple calls with different start_index values to retrieve
        the entire content in chunks.
    
        ## URL Requirements
    
        - Must be from the docs.amazonaws.cn domain
        - Must end with .html
    
        ## Example URLs
    
        - https://docs.amazonaws.cn/en_us/AmazonS3/latest/userguide/bucketnamingrules.html
        - https://docs.amazonaws.cn/en_us/lambda/latest/dg/lambda-invocation.html
    
        ## Output Format
    
        The output is formatted as markdown text with:
        - Preserved headings and structure
        - Code blocks for examples
        - Lists and tables converted to markdown format
    
        ## Handling Long Documents
    
        If the response indicates the document was truncated, you have several options:
    
        1. **Continue Reading**: Make another call with start_index set to the end of the previous response
        2. **Stop Early**: For very long documents (>30,000 characters), if you've already found the specific information needed, you can stop reading
    
        Args:
            ctx: MCP context for logging and error handling
            url: URL of the AWS China documentation page to read
            max_length: Maximum number of characters to return
            start_index: On return output starting at this character index
    
        Returns:
            Markdown content of the AWS China documentation
        """
        # Validate that URL is from docs.amazonaws.cn and ends with .html
        url_str = str(url)
        if not re.match(r'^https?://docs\.amazonaws\.cn/', url_str):
            error_msg = f'Invalid URL: {url_str}. URL must be from the docs.amazonaws.cn domain'
            await ctx.error(error_msg)
            return error_msg
        if not url_str.endswith('.html'):
            error_msg = f'Invalid URL: {url_str}. URL must end with .html'
            await ctx.error(error_msg)
            return error_msg
    
        return await read_documentation_impl(ctx, url_str, max_length, start_index, SESSION_UUID)
  • Pydantic schema definitions for input parameters of read_documentation tool using Field for validation and descriptions.
        ctx: Context,
        url: str = Field(description='URL of the AWS documentation page to read'),
        max_length: int = Field(
            default=5000,
            description='Maximum number of characters to return.',
            gt=0,
            lt=1000000,
        ),
        start_index: int = Field(
            default=0,
            description='On return output starting at this character index, useful if a previous fetch was truncated and more content is required.',
            ge=0,
        ),
    ) -> str:
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: URL domain/format requirements, pagination/truncation handling for long documents, output format details (markdown with preserved structure), and practical usage patterns. It doesn't mention rate limits, authentication needs, or error handling, but provides substantial operational context.

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 clear sections (Usage, URL Requirements, Example URLs, Output Format, Handling Long Documents) that make it easy to scan. While somewhat lengthy, each section adds value. The front-loaded purpose statement is clear, and the content earns its place by providing necessary operational guidance.

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

Completeness5/5

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

Given the tool's complexity (URL validation, pagination, format conversion) and the presence of an output schema (which handles return value documentation), the description is remarkably complete. It covers purpose, usage constraints, examples, output format, handling of edge cases (long documents), and parameter interaction. No significant gaps remain for agent understanding.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds some context about how parameters work together (start_index for pagination, max_length for truncation) and provides example URLs, but doesn't add significant semantic meaning beyond what's in the parameter descriptions. This meets the baseline expectation when schema coverage is complete.

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: 'Fetch and convert an AWS documentation page to markdown format.' This specifies both the action (fetch and convert) and the resource (AWS documentation page), with the format conversion being a key distinguishing feature. It differentiates from sibling tools like 'search_documentation' by focusing on retrieving and formatting specific pages rather than searching.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance in multiple sections. It specifies when to use this tool (for AWS docs from docs.aws.amazon.com ending in .html) and when to make multiple calls (for long documents). It also mentions alternatives implicitly by distinguishing from sibling tools and provides practical handling options for long documents (continue reading or stop early).

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/daniel-levesque/aws-documentation-mcp-server'

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