Skip to main content
Glama
vikramdse

Library Docs MCP Server

get_docs

Search documentation for Langchain, Llama-Index, MCP, and OpenAI libraries to find specific information using queries.

Instructions

Search the docs for a given query and library.
Supports langchain, llama-index, mcp, and openai.

Args:
    query: The query to search for (e.g. "Chroma DB")
    library: The library to search in (e.g. "langchain")

Returns:
    Text from the docs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
libraryYes

Implementation Reference

  • server.py:56-82 (handler)
    The main handler function for the 'get_docs' MCP tool. Decorated with @mcp.tool() for registration. Takes a query and library, constructs a site-specific search query, uses Serper API to find relevant docs pages, fetches their content using BeautifulSoup, and returns the concatenated text.
    @mcp.tool()
    async def get_docs(query: str, library: str):
        """
        Search the docs for a given query and library.
        Supports langchain, llama-index, mcp, and openai.
    
        Args:
            query: The query to search for (e.g. "Chroma DB")
            library: The library to search in (e.g. "langchain")
        
        Returns:
            Text from the docs
        """
        if library not in docs_urls:
            raise ValueError(f"Library {library} not supported by this tool")
    
        query = f"site:{docs_urls[library]} {query}" # Serper search format for searching in specified site
        results = await search_web(query)
    
        if len(results["organic"]) == 0:
            return "No results found"
        
        text = ""
        for result in results["organic"]:
            text += await fetch_url(result["link"])
        
        return text
  • Helper function to perform web search using Serper API for the given query, returning search results or empty on timeout.
    async def search_web(query: str) -> dict | None:
        payload = json.dumps({"q": query, "num": 2})
    
        headers = {
            "X-API-KEY": os.getenv("SERPER_API_KEY"),
            "Content-Type": "application/json"
        }
    
        async with httpx.AsyncClient() as client:
            try:
                response = await client.post(
                    SERPER_URL, headers=headers, data=payload, timeout=30.0
                )
                response.raise_for_status()
                return response.json()
            except httpx.TimeoutException:
                return {"organic": []}
  • Helper function to fetch content from a URL, parse with BeautifulSoup to extract text, handling timeouts.
    async def fetch_url(url: str):
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(url, timeout=30.0)
                soup = BeautifulSoup(response.text, "html.parser")
                text = soup.get_text()
                return text
            except httpx.TimeoutException:
                return "Timeout error"
  • Dictionary mapping supported libraries to their documentation base URLs, used to construct site-specific search queries.
    docs_urls = {
        "langchain": "python.langchain.com/docs",
        "llama-index": "docs.llamaindex.ai/en/stable",
        "mcp": "modelcontextprotocol.io",
        "openai": "platform.openai.com/docs"
    }
  • Tool schema and description provided in the docstring, defining input parameters (query: str, library: str) and output (text from docs).
    """
    Search the docs for a given query and library.
    Supports langchain, llama-index, mcp, and openai.
    
    Args:
        query: The query to search for (e.g. "Chroma DB")
        library: The library to search in (e.g. "langchain")
    
    Returns:
        Text from the docs
    """
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions 'Supports langchain, llama-index, mcp, and openai,' adding some context about supported libraries. However, it fails to disclose critical behavioral traits such as search scope (e.g., full-text vs. titles), result format details, pagination, rate limits, or error handling, leaving significant gaps for a search tool.

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 appropriately sized and structured: it starts with a clear purpose statement, followed by library support, and then details args and returns in a bullet-like format. Every sentence adds value, with no redundant information, though the 'Returns' section could be more specific, slightly reducing efficiency.

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 the tool's moderate complexity (2 parameters, no annotations, no output schema), the description is minimally adequate. It covers purpose, parameters, and return type at a high level, but lacks depth in behavioral transparency, usage guidelines, and output details (e.g., result structure or examples). It meets basic needs but has clear gaps for effective agent use.

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 0%, so the schema provides no parameter details. The description compensates by explaining both parameters: 'query' as 'The query to search for' with an example, and 'library' as 'The library to search in' with an example and list of supported values. This adds meaningful semantics beyond the bare schema, but it doesn't fully detail constraints or formats, meeting the baseline for partial compensation.

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 the docs for a given query and library.' It specifies the verb ('search'), resource ('docs'), and scope ('query and library'). However, without sibling tools, it cannot demonstrate differentiation, so it doesn't reach a score of 5.

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 minimal guidance: it lists supported libraries ('langchain, llama-index, mcp, and openai'), which implies when to use it for those libraries. However, it lacks explicit when/when-not instructions, prerequisites, or alternatives, offering only basic context without exclusions or detailed usage scenarios.

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/vikramdse/docs-mcp-server'

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