Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CrewAIInc CrewAI Code Docs Search Tool

From Leeroopedia
Knowledge Sources
Domains Tools, RAG, Documentation_Search
Last Updated 2026-02-11 00:00 GMT

Overview

Concrete tool for performing semantic search within code documentation sites using RAG provided by CrewAI.

Description

The CodeDocsSearchTool class extends RagTool to enable semantic searches within code documentation sites using natural language queries. It provides two operational modes: a fixed documentation URL mode where docs_url is set during initialization (using FixedCodeDocsSearchToolSchema), and a dynamic mode where docs_url is passed at runtime (using CodeDocsSearchToolSchema). The add method registers documentation URLs with the RAG system using DataType.DOCS_SITE, and the _run method performs semantic searches with optional similarity_threshold and result limit parameters. The tool description is dynamically generated based on whether a fixed docs_url is provided.

Usage

Use this tool when CrewAI agents need to reference API docs, programming guides, or technical specifications during development or troubleshooting tasks.

Code Reference

Source Location

  • Repository: CrewAI
  • File: lib/crewai-tools/src/crewai_tools/tools/code_docs_search_tool/code_docs_search_tool.py
  • Lines: 1-51

Signature

class CodeDocsSearchTool(RagTool):
    name: str = "Search a Code Docs content"
    description: str = "A tool that can be used to semantic search a query from a Code Docs content."
    args_schema: type[BaseModel] = CodeDocsSearchToolSchema

    def __init__(self, docs_url: str | None = None, **kwargs): ...
    def add(self, docs_url: str) -> None: ...
    def _run(self, search_query: str, docs_url: str | None = None,
             similarity_threshold: float | None = None, limit: int | None = None) -> str: ...

Import

from crewai_tools import CodeDocsSearchTool

I/O Contract

Inputs

Name Type Required Description
search_query str Yes Natural language query to search the documentation content
docs_url str or None No URL of the documentation site (constructor for fixed, runtime for dynamic)
similarity_threshold float or None No Minimum similarity score for results
limit int or None No Maximum number of results to return

Outputs

Name Type Description
_run() returns str Semantically relevant documentation content matching the search query

Usage Examples

Basic Usage

from crewai_tools import CodeDocsSearchTool

# Fixed docs URL mode
tool = CodeDocsSearchTool(docs_url="https://docs.crewai.com")
result = tool.run(search_query="How to create a custom tool")

# Dynamic docs URL mode
tool = CodeDocsSearchTool()
result = tool.run(search_query="authentication", docs_url="https://docs.example.com")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment