Skip to main content
Glama

get_docs

Search documentation for AI development libraries including LangChain, LlamaIndex, and OpenAI Agents SDK to find code examples and API references.

Instructions

搜索给定查询和库的最新文档。
支持 langchain、llama-index、autogen、agno、openai-agents-sdk、mcp-doc、camel-ai 和 crew-ai。

参数:
query: 要搜索的查询 (例如 "React Agent")
library: 要搜索的库 (例如 "agno")

返回:
文档中的文本

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
libraryYes

Implementation Reference

  • main.py:64-89 (handler)
    The main asynchronous handler function for the 'get_docs' tool. It validates the library, constructs a site-specific search query, fetches search results using Serper API, retrieves content from top results using BeautifulSoup, and returns the concatenated text.
    @mcp.tool()  
    async def get_docs(query: str, library: str):
      """
        搜索给定查询和库的最新文档。
        支持 langchain、llama-index、autogen、agno、openai-agents-sdk、mcp-doc、camel-ai 和 crew-ai。
    
        参数:
        query: 要搜索的查询 (例如 "React Agent")
        library: 要搜索的库 (例如 "agno")
    
        返回:
        文档中的文本
      """
      if library not in docs_urls:
        raise ValueError(f"Library {library} not supported by this tool")
      
      query = f"site:{docs_urls[library]} {query}"
      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
  • main.py:64-64 (registration)
    The @mcp.tool() decorator registers the get_docs function as an MCP tool.
    @mcp.tool()  
  • main.py:36-53 (helper)
    Helper function to perform web search using Serper API, used by get_docs.
    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": []}
  • main.py:54-63 (helper)
    Helper function to fetch and parse HTML content from a URL, used by get_docs.
    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"
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/GobinFan/python-mcp-server-client'

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