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 XML Search Tool

From Leeroopedia
Revision as of 11:09, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/CrewAIInc_CrewAI_XML_Search_Tool.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Tools, RAG, Document_Search
Last Updated 2026-02-11 00:00 GMT

Overview

XMLSearchTool performs RAG-based semantic search over XML file content using vector embeddings.

Description

The XMLSearchTool extends RagTool and uses the dual-schema pattern: XMLSearchToolSchema requires both search_query and xml (file path or URL), while FixedXMLSearchToolSchema requires only search_query (used when a specific XML file is pre-configured). During initialization, if an xml path is provided, the tool adds it to the RAG index, updates the description to reference the specific file, and switches to the fixed schema. The _run method accepts a search_query and optional xml path; if a new file is specified at runtime, it is added to the index before delegating the semantic search to the parent RagTool._run with optional similarity_threshold and limit parameters.

Usage

Use this tool when a CrewAI agent needs to semantically search through XML files such as configuration files, data feeds, or API responses.

Code Reference

Source Location

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

Signature

class FixedXMLSearchToolSchema(BaseModel):
    search_query: str = Field(..., description="Mandatory search query ...")

class XMLSearchToolSchema(FixedXMLSearchToolSchema):
    xml: str = Field(..., description="File path or URL of a XML file to be searched")

class XMLSearchTool(RagTool):
    name: str = "Search a XML's content"
    description: str = "A tool that can be used to semantic search a query from a XML's content."
    args_schema: type[BaseModel] = XMLSearchToolSchema

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

Import

from crewai_tools import XMLSearchTool

I/O Contract

Inputs

Name Type Required Description
search_query str Yes The semantic search query to run against the XML content
xml str No File path or URL of an XML file to search (can be set at init or runtime)
similarity_threshold float No Minimum similarity score for results
limit int No Maximum number of results to return

Outputs

Name Type Description
_run() returns str Semantically relevant text passages from the XML file

Usage Examples

Basic Usage

from crewai_tools import XMLSearchTool

tool = XMLSearchTool(xml="/path/to/data.xml")
result = tool._run(search_query="configuration settings")

Dynamic File

from crewai_tools import XMLSearchTool

tool = XMLSearchTool()
result = tool._run(search_query="api response", xml="https://example.com/feed.xml")

Related Pages

Page Connections

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