search_mcp_docs
Search MCP Protocol and FastMCP documentation to find relevant guides for building MCP servers, with ranked results and optional source filtering.
Instructions
Search MCP protocol AND FastMCP framework documentation with ranked results.
This tool searches across both documentation sources simultaneously:
MCP Protocol (modelcontextprotocol.io):
Official protocol specification and architecture
Transports (stdio, streamable HTTP)
Tools, Resources, and Prompts primitives
Lifecycle, capabilities negotiation, and security
FastMCP Framework (gofastmcp.com):
Python framework for building MCP servers
Decorators, type hints, and Pydantic integration
Authentication, deployment, and production patterns
Client SDK and cloud deployment
Use this to find documentation for building MCP servers with either approach.
Args: query: Search query string (e.g., "tool input schema", "stdio transport") k: Maximum number of results to return (default: 5) source: Optional filter - "mcp" for protocol docs only, "fastmcp" for framework docs only. If None, searches both sources.
Returns: List of dictionaries containing: - url: Document URL - title: Display title - score: Relevance score (higher is better) - snippet: Contextual content preview - source: Documentation source ("mcp" or "fastmcp")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| k | No | ||
| source | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- Main handler function for the search_mcp_docs tool. Accepts query, k (max results), and source filter. Uses BM25 search index to rank results, applies optional source filtering, hydrates top results with content snippets, and returns a list of dicts with url, title, score, snippet, and source.
def search_mcp_docs( query: str, k: int = 5, source: SourceFilter = None ) -> list[dict[str, Any]]: """Search MCP protocol AND FastMCP framework documentation with ranked results. This tool searches across both documentation sources simultaneously: **MCP Protocol (modelcontextprotocol.io):** - Official protocol specification and architecture - Transports (stdio, streamable HTTP) - Tools, Resources, and Prompts primitives - Lifecycle, capabilities negotiation, and security **FastMCP Framework (gofastmcp.com):** - Python framework for building MCP servers - Decorators, type hints, and Pydantic integration - Authentication, deployment, and production patterns - Client SDK and cloud deployment Use this to find documentation for building MCP servers with either approach. Args: query: Search query string (e.g., "tool input schema", "stdio transport") k: Maximum number of results to return (default: 5) source: Optional filter - "mcp" for protocol docs only, "fastmcp" for framework docs only. If None, searches both sources. Returns: List of dictionaries containing: - url: Document URL - title: Display title - score: Relevance score (higher is better) - snippet: Contextual content preview - source: Documentation source ("mcp" or "fastmcp") """ cache.ensure_ready() index = cache.get_index() if index is None: return [] # Request more results if filtering, to ensure we get k results after filtering search_k = k * 3 if source else k results = index.search(query, k=search_k) # Apply source filter if specified if source: results = [(score, doc) for score, doc in results if _matches_source_filter(doc.uri, source)] # Limit to requested k after filtering results = results[:k] url_cache = cache.get_url_cache() # Hydrate top results with content for snippets top = results[: min(len(results), cache.SNIPPET_HYDRATE_MAX)] for _, doc in top: cached = url_cache.get(doc.uri) if cached is None or not cached.content: cache.ensure_page(doc.uri) # Build response with snippets and source return_docs: list[dict[str, Any]] = [] for score, doc in results: page = url_cache.get(doc.uri) snippet = text_processor.make_snippet(page, doc.display_title) return_docs.append( { "url": doc.uri, "title": doc.display_title, "score": round(score, 3), "snippet": snippet, "source": _get_source_from_url(doc.uri), } ) return return_docs - Type alias for the source filter parameter: allows 'mcp', 'fastmcp', or None to search both.
SourceFilter = Literal["mcp", "fastmcp"] | None - src/mcp_server_builder/server.py:15-15 (registration)Registers search_mcp_docs as a FastMCP tool on the server instance.
mcp.tool()(docs.search_mcp_docs) - Helper that maps a URL to its documentation source ('mcp' for modelcontextprotocol.io, 'fastmcp' for gofastmcp.com, or 'unknown').
def _get_source_from_url(url: str) -> str: """Extract source identifier from URL domain.""" for domain, source in _DOMAIN_SOURCE_MAP.items(): if domain in url: return source return "unknown" def _matches_source_filter(url: str, source_filter: SourceFilter) -> bool: """Check if URL matches the source filter.""" if source_filter is None: return True return _get_source_from_url(url) == source_filter - Helper that checks whether a URL matches the requested source filter.
def _matches_source_filter(url: str, source_filter: SourceFilter) -> bool: """Check if URL matches the source filter.""" if source_filter is None: return True return _get_source_from_url(url) == source_filter