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

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

Overview

Performs semantic search within JSON file contents using RAG (Retrieval-Augmented Generation).

Description

JSONSearchTool extends RagTool to enable meaning-based search within JSON files. It indexes JSON content via the inherited add() method from RagTool for semantic retrieval. The tool supports two modes: a dynamic mode where the JSON file path is specified at runtime via JSONSearchToolSchema, and a fixed mode where a specific JSON file is pre-configured at construction using FixedJSONSearchToolSchema. Search results can be tuned with similarity_threshold and limit parameters. This enables natural language queries against structured JSON data without requiring exact key lookups or complex query logic.

Usage

Use this tool when a CrewAI agent needs to semantically query JSON data, such as finding relevant entries in configuration files, API response caches, or structured datasets.

Code Reference

Source Location

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

Signature

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

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

Import

from crewai_tools import JSONSearchTool

I/O Contract

Inputs

Name Type Required Description
search_query str Yes The semantic search query
json_path str Yes (at init or runtime) File path or URL of the JSON file to search
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 content from the JSON file matching the query

Usage Examples

Dynamic JSON Path

from crewai_tools import JSONSearchTool

tool = JSONSearchTool()
result = tool.run(search_query="user preferences", json_path="/path/to/config.json")

Fixed JSON Path

from crewai_tools import JSONSearchTool

tool = JSONSearchTool(json_path="/path/to/data.json")
result = tool.run(search_query="billing information")

Related Pages

Page Connections

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