Skip to main content
Glama
daniel-levesque

AWS Documentation MCP Server

search_documentation

Search across all AWS documentation using the official API to find relevant pages for your technical queries. Input specific terms or phrases to retrieve URLs, titles, and context snippets for accurate 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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of results to return
search_phraseYesSearch phrase to use

Implementation Reference

  • The handler function for the 'search_documentation' tool. It is registered via @mcp.tool() decorator and implements the core logic: constructs search request to AWS docs search API, handles HTTP/JSON errors, parses suggestions into SearchResult models.
    @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 model defining the output schema for search_documentation tool results, used in the return type List[SearchResult]. Defines fields: rank_order (int), url (str), title (str), context (Optional[str]).
    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()
  • Input schema defined by function parameters using pydantic Field: search_phrase (str, required), limit (int, default=10, 1-50). Return type List[SearchResult].
    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]:

Other Tools

Related 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