Skip to main content
Glama
daniel-levesque

AWS Documentation MCP Server

search_documentation

Search AWS documentation using the official AWS Documentation Search API to find relevant pages when you don't have specific URLs. Use technical terms, service names, and filters to improve results.

Instructions

Search AWS documentation using the official AWS Documentation Search API.

Usage

This tool searches across all AWS documentation for pages matching your search phrase. Use it to find relevant documentation when you don't have a specific URL.

Search Tips

  • Use specific technical terms rather than general phrases

  • Include service names to narrow results (e.g., "S3 bucket versioning" instead of just "versioning")

  • Use quotes for exact phrase matching (e.g., "AWS Lambda function URLs")

  • Include abbreviations and alternative terms to improve results

  • Use guide_type and product_type filters found from a SearchResponse's "facets" property:

    • Filter only for broad search queries with patterns:

      • "What is [service]?" -> product_types: ["Amazon Simple Storage Service"]

      • "How to use <service 1> with <service 2>?" -> product_types: [<service 1>, <service 2>]

      • "[service] getting started" -> product_types: [] + guide_types: ["User Guide, "Developer Guide"]

      • "API reference for [service]" -> product_types: [] + guide_types: ["API Reference"]

Result Interpretation

Each SearchResponse includes:

  • search_results: List of documentation pages, each with:

    • rank_order: The relevance ranking (lower is more relevant)

    • url: The documentation page URL

    • title: The page title

    • context: A brief excerpt or summary (if available)

  • facets: Available filters (product_types, guide_types) for refining searches

  • query_id: Unique identifier for this search session

Args: ctx: MCP context for logging and error handling search_phrase: Search phrase to use search_intent: The intent behind the search requested by the user limit: Maximum number of results to return product_types: Filter by AWS product/service guide_types: Filter by guide type

Returns: List of search results with URLs, titles, query ID, context snippets, and facets for filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_phraseYesSearch phrase to use
search_intentNoFor the search_phrase parameter, describe the search intent of the user. CRITICAL: Do not include any PII or customer data, describe only the AWS-related intent for search.
limitNoMaximum number of results to return
product_typesNoFilter results by AWS product/service (e.g., ["Amazon Simple Storage Service"])
guide_typesNoFilter results by guide type (e.g., ["User Guide", "API Reference", "Developer Guide"])

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
facetsNo
query_idYes
search_resultsYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the core logic of searching AWS documentation via the official API, handling errors, parsing JSON response, extracting results, and returning a list of SearchResult objects. Includes input schema definitions via Pydantic Field.
    @mcp.tool()
    async def search_documentation(
        ctx: Context,
        search_phrase: str = Field(description='Search phrase to use'),
        limit: int = Field(
            default=10,
            description='Maximum number of results to return',
            ge=1,
            le=50,
        ),
    ) -> List[SearchResult]:
        """Search AWS documentation using the official AWS Documentation Search API.
    
        ## Usage
    
        This tool searches across all AWS documentation for pages matching your search phrase.
        Use it to find relevant documentation when you don't have a specific URL.
    
        ## Search Tips
    
        - Use specific technical terms rather than general phrases
        - Include service names to narrow results (e.g., "S3 bucket versioning" instead of just "versioning")
        - Use quotes for exact phrase matching (e.g., "AWS Lambda function URLs")
        - Include abbreviations and alternative terms to improve results
    
        ## Result Interpretation
    
        Each result includes:
        - rank_order: The relevance ranking (lower is more relevant)
        - url: The documentation page URL
        - title: The page title
        - context: A brief excerpt or summary (if available)
    
        Args:
            ctx: MCP context for logging and error handling
            search_phrase: Search phrase to use
            limit: Maximum number of results to return
    
        Returns:
            List of search results with URLs, titles, and context snippets
        """
        logger.debug(f'Searching AWS documentation for: {search_phrase}')
    
        request_body = {
            'textQuery': {
                'input': search_phrase,
            },
            'contextAttributes': [{'key': 'domain', 'value': 'docs.aws.amazon.com'}],
            'acceptSuggestionBody': 'RawText',
            'locales': ['en_us'],
        }
    
        search_url_with_session = f'{SEARCH_API_URL}?session={SESSION_UUID}'
    
        async with httpx.AsyncClient() as client:
            try:
                response = await client.post(
                    search_url_with_session,
                    json=request_body,
                    headers={
                        'Content-Type': 'application/json',
                        'User-Agent': DEFAULT_USER_AGENT,
                        'X-MCP-Session-Id': SESSION_UUID,
                    },
                    timeout=30,
                )
            except httpx.HTTPError as e:
                error_msg = f'Error searching AWS docs: {str(e)}'
                logger.error(error_msg)
                await ctx.error(error_msg)
                return [SearchResult(rank_order=1, url='', title=error_msg, context=None)]
    
            if response.status_code >= 400:
                error_msg = f'Error searching AWS docs - status code {response.status_code}'
                logger.error(error_msg)
                await ctx.error(error_msg)
                return [
                    SearchResult(
                        rank_order=1,
                        url='',
                        title=error_msg,
                        context=None,
                    )
                ]
    
            try:
                data = response.json()
            except json.JSONDecodeError as e:
                error_msg = f'Error parsing search results: {str(e)}'
                logger.error(error_msg)
                await ctx.error(error_msg)
                return [
                    SearchResult(
                        rank_order=1,
                        url='',
                        title=error_msg,
                        context=None,
                    )
                ]
    
        results = []
        if 'suggestions' in data:
            for i, suggestion in enumerate(data['suggestions'][:limit]):
                if 'textExcerptSuggestion' in suggestion:
                    text_suggestion = suggestion['textExcerptSuggestion']
                    context = None
    
                    # Add context if available
                    if 'summary' in text_suggestion:
                        context = text_suggestion['summary']
                    elif 'suggestionBody' in text_suggestion:
                        context = text_suggestion['suggestionBody']
    
                    results.append(
                        SearchResult(
                            rank_order=i + 1,
                            url=text_suggestion.get('link', ''),
                            title=text_suggestion.get('title', ''),
                            context=context,
                        )
                    )
    
        logger.debug(f'Found {len(results)} search results for: {search_phrase}')
        return results
  • Pydantic BaseModel defining the structure of each search result returned by the tool, used for output validation and typing.
    class SearchResult(BaseModel):
        """Search result from AWS documentation search."""
    
        rank_order: int
        url: str
        title: str
        context: Optional[str] = None
  • The @mcp.tool() decorator registers the search_documentation function as an MCP tool.
    @mcp.tool()
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 the tool's behavior: it searches documentation, returns ranked results with URLs/titles/context, provides facets for filtering, and includes a query ID. However, it doesn't mention rate limits, authentication needs, or error handling, which are minor gaps.

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, Search Tips, Result Interpretation) and is appropriately sized. However, it includes some redundancy (e.g., repeating parameter info in 'Args' that's already in the schema) and could be slightly more front-loaded, though overall it's efficient.

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 (search with filters), no annotations, and an output schema, the description is complete. It explains the tool's purpose, usage, behavioral aspects, and result interpretation thoroughly. The output schema handles return values, so the description doesn't need to detail them extensively, making it well-rounded.

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 parameters thoroughly. The description adds minimal value beyond the schema by briefly mentioning parameters in the 'Args' section and providing usage examples in search tips, but doesn't significantly enhance parameter understanding beyond what's in the structured data.

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 searches AWS documentation using the official API, specifying the resource (AWS documentation) and distinguishing it from sibling tools like 'read_documentation' (which likely reads specific pages) and 'recommend' (which may suggest content). It explicitly mentions searching across all AWS documentation for pages matching a search phrase.

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 guidance on when to use this tool ('when you don't have a specific URL') and includes detailed search tips with examples. It also explains how to interpret results and use facets for refining searches, offering clear alternatives and context for effective usage.

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