Skip to main content
Glama
gemini2026

Documentation Search MCP Server

by gemini2026

filtered_search

Search documentation with filters for content type, difficulty, code examples, and version to find precise information for programming tasks.

Instructions

Search with advanced filtering options.

Args:
    query: The search query
    library: The library to search in
    content_type: Filter by content type ("tutorial", "reference", "example", "guide")
    difficulty_level: Filter by difficulty ("beginner", "intermediate", "advanced")
    has_code_examples: Filter for content with code examples (true/false)
    version: Library version to search (e.g., "4.2", "stable", "latest"). Default: "latest"
    auto_detect_version: Automatically detect installed package version. Default: False

Returns:
    Filtered search results matching specified criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
libraryYes
content_typeNo
difficulty_levelNo
has_code_examplesNo
versionNolatest
auto_detect_versionNo

Implementation Reference

  • The main handler function for the 'filtered_search' MCP tool. It constructs SearchFilters from parameters and delegates to the FilteredSearch instance's search_with_filters method. Includes the @mcp.tool() registration decorator.
    @mcp.tool()
    async def filtered_search(
        query: str,
        library: str,
        content_type: Optional[str] = None,
        difficulty_level: Optional[str] = None,
        has_code_examples: Optional[bool] = None,
        version: str = "latest",
        auto_detect_version: bool = False,
    ):
        """
        Search with advanced filtering options.
    
        Args:
            query: The search query
            library: The library to search in
            content_type: Filter by content type ("tutorial", "reference", "example", "guide")
            difficulty_level: Filter by difficulty ("beginner", "intermediate", "advanced")
            has_code_examples: Filter for content with code examples (true/false)
            version: Library version to search (e.g., "4.2", "stable", "latest"). Default: "latest"
            auto_detect_version: Automatically detect installed package version. Default: False
    
        Returns:
            Filtered search results matching specified criteria
        """
        from .smart_search import filtered_search, SearchFilters
    
        await enforce_rate_limit("filtered_search")
    
        filters = SearchFilters(
            content_type=content_type,
            difficulty_level=difficulty_level,
            has_code_examples=has_code_examples,
        )
    
        try:
            results = await filtered_search.search_with_filters(query, library, filters)
    
            return {
                "query": query,
                "library": library,
                "filters_applied": {
                    "content_type": content_type,
                    "difficulty_level": difficulty_level,
                    "has_code_examples": has_code_examples,
                },
                "total_results": len(results),
                "results": [
                    {
                        "title": result.title,
                        "url": result.url,
                        "snippet": (
                            result.snippet[:200] + "..."
                            if len(result.snippet) > 200
                            else result.snippet
                        ),
                        "relevance_score": result.relevance_score,
                        "content_type": result.content_type,
                        "difficulty_level": result.difficulty_level,
                        "estimated_read_time": f"{result.estimated_read_time} min",
                    }
                    for result in results[:10]
                ],
            }
        except Exception as e:
            return {"error": f"Filtered search failed: {str(e)}", "results": []}
  • FilteredSearch class that wraps SmartSearch and applies post-search filtering based on content_type, difficulty_level, and has_code_examples.
    class FilteredSearch:
        """Search with advanced filtering capabilities"""
    
        def __init__(self, smart_search: SmartSearch):
            self.smart_search = smart_search
    
        async def search_with_filters(
            self, query: str, library: str, filters: SearchFilters
        ) -> List[SearchResult]:
            """Perform search with applied filters"""
    
            # Get base search results
            results = await self.smart_search.semantic_search(query, library)
    
            # Apply filters
            filtered_results = []
            for result in results:
                if self.passes_filters(result, filters):
                    filtered_results.append(result)
    
            return filtered_results
    
        def passes_filters(self, result: SearchResult, filters: SearchFilters) -> bool:
            """Check if a result passes all filters"""
    
            if filters.content_type and result.content_type != filters.content_type:
                return False
    
            if (
                filters.difficulty_level
                and result.difficulty_level != filters.difficulty_level
            ):
                return False
    
            if filters.has_code_examples is not None:
                has_code = result.code_snippets_count > 0
                if filters.has_code_examples != has_code:
                    return False
    
            if (
                filters.max_reading_time
                and result.estimated_read_time > filters.max_reading_time
            ):
                return False
    
            # Language filter would need more sophisticated detection
            # For now, skip language filtering
    
            return True
  • Dataclass defining the filter parameters used by FilteredSearch.
    @dataclass
    class SearchFilters:
        """Filters for refining search results"""
    
        content_type: Optional[str] = None  # "tutorial", "reference", "example"
        difficulty_level: Optional[str] = None  # "beginner", "intermediate", "advanced"
        has_code_examples: Optional[bool] = None
        max_reading_time: Optional[int] = None  # in minutes
        language: Optional[str] = None  # programming language
  • Global instance of FilteredSearch used by the tool handler.
    smart_search = SmartSearch()
    filtered_search = FilteredSearch(smart_search)
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'advanced filtering options' and describes parameters, but lacks behavioral details like whether this is a read-only operation, performance characteristics, error handling, or authentication needs. For a search tool with 7 parameters and no annotations, this is inadequate.

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 (Args, Returns) and uses bullet-like formatting. It's appropriately sized for a tool with many parameters, though the opening sentence is somewhat generic. Most sentences earn their place by explaining parameters.

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?

Given 7 parameters, no annotations, and no output schema, the description is moderately complete. It covers parameter semantics thoroughly but lacks behavioral context and output details. For a search tool, more information on result format or limitations would improve completeness.

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

Parameters5/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 fully. It provides detailed semantics for all 7 parameters, including explanations, enums (e.g., content_type values), defaults, and examples (e.g., version: '4.2'). This adds significant value beyond the bare schema.

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

Purpose4/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 with advanced filtering options.' This specifies the verb (search) and resource (content with filtering), though it doesn't explicitly differentiate from sibling tools like 'semantic_search' or 'get_docs'. The purpose is clear but lacks sibling differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'semantic_search' or 'get_docs'. It mentions advanced filtering but doesn't specify scenarios, prerequisites, or exclusions. Usage is implied through parameter descriptions but not explicitly stated.

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/gemini2026/documentation-search-mcp'

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