This repository was archived by the owner on Nov 10, 2025. It is now read-only.
feat: neo4j search tool #488
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Neo4jSearchTool for Semantic Search in Neo4j Graph Databases
Summary
The
Neo4jSearchTool, a new RAG-based tool that enables semantic search capabilities over Neo4j graph databases. The tool extends the existingRagToolinfrastructure and follows the same pattern asMySQLSearchToolandPGSearchTool, providing CrewAI agents with the ability to intelligently query and search graph data using natural language queries.What This PR Adds
Key Features
✅ Semantic Search Over Graph Data: Leverages RAG technology to enable natural language queries over Neo4j graph databases
✅ Cypher Query Support: Executes Cypher queries to extract nodes, relationships, and properties from Neo4j
✅ Flexible Connection Options: Supports Bolt, Neo4j URI, and secure TLS/SSL connection schemes
✅ Customizable LLM/Embeddings: Full support for custom model providers and embedding configurations
✅ RAG Integration: Seamlessly integrates with existing CrewAI RAG infrastructure for vector search and retrieval
Implementation Details
Core Components
Neo4jSearchTool (
crewai_tools/tools/neo4j_search_tool/neo4j_search_tool.py)RagToolclassNeo4jLoader (
crewai_tools/rag/loaders/neo4j_loader.py)BaseLoaderinterfaceDataType Integration
NEO4Jenum value toDataTypeDependencies
neo4j>=5.0.0as an optional dependency inpyproject.tomlTesting
The PR includes comprehensive test coverage in
tests/tools/test_neo4j_search_tool.py:All tests pass successfully with mocked Neo4j connections to avoid requiring actual database instances.
Usage Example
Files Changed
New Files
crewai_tools/tools/neo4j_search_tool/neo4j_search_tool.py- Main tool implementationcrewai_tools/tools/neo4j_search_tool/README.md- Comprehensive documentationcrewai_tools/rag/loaders/neo4j_loader.py- Neo4j database loadertests/tools/test_neo4j_search_tool.py- Test suiteModified Files
crewai_tools/rag/data_types.py- Added NEO4J data type enumcrewai_tools/__init__.py- Added Neo4jSearchTool exportcrewai_tools/tools/__init__.py- Added Neo4jSearchTool importpyproject.toml- Added neo4j optional dependencyBenefits
Compatibility
pip install neo4jorpip install 'crewai-tools[neo4j]')Testing Instructions
All 6 tests should pass.
Note
Introduces
Neo4jSearchToolwith aNeo4jLoader,DataType.NEO4Jmappings, optionalneo4jdependency, exports, docs, and a full test suite.crewai_tools/tools/neo4j_search_tool/neo4j_search_tool.pyimplementingNeo4jSearchTool(extendsRagTool, supports semantic search via Cypher; adds credentials handling and_run/add).crewai_tools/rag/loaders/neo4j_loader.py(Neo4jLoader) to execute Cypher via Neo4j driver and format results.crewai_tools/rag/data_types.pyto includeDataType.NEO4Jwith chunker (TextChunker) and loader (Neo4jLoader) mappings.Neo4jSearchToolincrewai_tools/__init__.pyandcrewai_tools/tools/__init__.py.neo4j>=5.0.0inpyproject.toml.tests/tools/test_neo4j_search_tool.pycovering init, add, search (with params), no-results, and description.crewai_tools/tools/neo4j_search_tool/README.mdandPR_DESCRIPTION.mdwith usage and configuration.Written by Cursor Bugbot for commit a0a64e8. This will update automatically on new commits. Configure here.