Skip to main content
Glama
ryu1maniwa

OpenTelemetry Documentation MCP Server

by ryu1maniwa

search_documentation

Search OpenTelemetry documentation to find relevant pages when you don't have a specific URL. Use technical terms and OpenTelemetry concepts to improve search results.

Instructions

Search OpenTelemetry documentation using Google Custom Search.

Usage

This tool searches across OpenTelemetry 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 OpenTelemetry concepts to narrow results (e.g., "tracing instrumentation" instead of just "tracing")

  • Use quotes for exact phrase matching (e.g., "SDK configuration")

  • Include abbreviations and alternative terms to improve results (e.g., "OTEL collector")

API Limits

The search uses Google's Custom Search API which has usage limits:

  • Free tier: 100 queries per day

  • Results are limited to 10 per page

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 (will be capped at 10 due to API limitations)

Returns: List of search results with URLs, titles, and context snippets

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main execution logic for the 'search_documentation' tool. This async function handles the Google Custom Search API call to opentelemetry.io documentation, processes results using parse_search_results, and returns a list of SearchResult objects. The @mcp.tool() decorator registers it as an MCP tool with input schema from Pydantic Fields.
    @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 OpenTelemetry documentation using Google Custom Search.
    
        ## Usage
    
        This tool searches across OpenTelemetry 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 OpenTelemetry concepts to narrow results (e.g., "tracing instrumentation" instead of just "tracing")
        - Use quotes for exact phrase matching (e.g., "SDK configuration")
        - Include abbreviations and alternative terms to improve results (e.g., "OTEL collector")
    
        ## API Limits
    
        The search uses Google's Custom Search API which has usage limits:
        - Free tier: 100 queries per day
        - Results are limited to 10 per page
    
        ## 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 (will be capped at 10 due to API limitations)
    
        Returns:
            List of search results with URLs, titles, and context snippets
        """
        logger.debug(f'Searching OpenTelemetry documentation for: {search_phrase}')
    
        # Get API key from environment variable
        api_key = os.getenv('GOOGLE_API_KEY')
        if not api_key:
            error_msg = (
                'Google API key not found. To use the search_documentation tool, you need to set the '
                'GOOGLE_API_KEY environment variable. You can get an API key from the Google Cloud Console '
                '(https://console.cloud.google.com/apis/credentials) and add it to your MCP configuration.'
            )
            logger.error(error_msg)
            await ctx.error(error_msg)
            return [SearchResult(rank_order=1, url='', title=error_msg, context=None)]
    
        # Cap limit at 10 due to Google CSE API constraints
        if limit > 10:
            logger.warning(f'Limiting search results to 10 (API limit), requested: {limit}')
            limit = 10
    
        params = {
            'key': api_key,
            'cx': OPENTELEMETRY_SEARCH_CX,
            'q': search_phrase,
            'num': limit,
        }
    
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(
                    GOOGLE_SEARCH_API_URL,
                    params=params,
                    headers={'User-Agent': DEFAULT_USER_AGENT},
                    timeout=30,
                )
            except httpx.HTTPError as e:
                error_msg = f'Error searching OpenTelemetry 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 OpenTelemetry 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 = parse_search_results(data)
    
        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 search_documentation tool: rank_order, url, title, and optional context snippet.
    class SearchResult(BaseModel):
        """Search result from OpenTelemetry 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()
  • Helper function that parses the raw Google Custom Search JSON response into a list of SearchResult models, used by the search_documentation handler.
    def parse_search_results(data: Dict[str, Any]) -> List[SearchResult]:
        """Parse Google Custom Search results into structured format.
    
        Args:
            data: Raw API response data from Google Custom Search
    
        Returns:
            List of SearchResult objects in a standard format
        """
        results = []
    
        if 'items' in data:
            for i, item in enumerate(data['items']):
                results.append(
                    SearchResult(
                        rank_order=i + 1,
                        url=item.get('link', ''),
                        title=item.get('title', ''),
                        context=item.get('snippet'),
                    )
                )
    
        return results
Behavior4/5

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

Since no annotations are provided, the description carries the full burden of behavioral disclosure. It does an excellent job describing key behavioral traits: it discloses the underlying API (Google Custom Search), usage limits (100 queries/day free tier), result limitations (10 per page), and what information each result contains. The only minor gap is it doesn't explicitly mention whether this is a read-only operation (though searching implies it is) or error handling specifics.

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, API Limits, Result Interpretation) and front-loads the core purpose. However, it could be slightly more concise - some information like the 'Returns' section is somewhat redundant with the 'Result Interpretation' section. Overall, most sentences earn their place by providing valuable 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 that this is a search tool with 2 parameters, 100% schema coverage, and an output schema exists, the description provides excellent contextual completeness. It covers purpose, usage guidelines, behavioral traits (API limits, result format), and search optimization tips. The existence of an output schema means the description doesn't need to explain return values in detail, which it appropriately avoids.

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 both parameters thoroughly. The description adds minimal value beyond the schema: it mentions that 'limit' will be capped at 10 due to API limitations (which is useful context), but doesn't provide additional semantic context for 'search_phrase' beyond what's in the schema. 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: 'Search OpenTelemetry documentation using Google Custom Search' with the specific verb 'search' and resource 'OpenTelemetry documentation'. It distinguishes from the sibling tool 'read_documentation' by specifying this is for searching when you don't have a specific URL, while 'read_documentation' would presumably be for reading specific documentation pages.

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: 'Use it to find relevant documentation when you don't have a specific URL.' It also includes a 'Search Tips' section with detailed advice on how to formulate effective queries, and mentions API limits that inform usage decisions. The contrast with the sibling 'read_documentation' is implied through the 'when you don't have a specific URL' statement.

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/ryu1maniwa/opentelemetry-documentation-mcp-server'

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