Neo4j MCP Server
Provides tools to connect to a Neo4j pet care graph database, run custom Cypher queries, inspect schema and statistics, and retrieve user pets, pet medical history, vet appointments, and product interaction data.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Neo4j MCP Server for Pet Care Database
A modular Model Context Protocol (MCP) server that provides tools to interact with a Neo4j database containing pet care information including users, pets, vet visits, medications, and product interactions.
šļø Modular Architecture
This implementation follows a clean, modular architecture for maintainability and extensibility:
mcp_graph/
āāā src/ # Main source code
ā āāā database/ # Database layer
ā ā āāā connection.py # Neo4j connection management
ā ā āāā queries.py # Cypher query builders
ā āāā models/ # Data models
ā ā āāā base.py # Base model classes
ā ā āāā users.py # User models
ā ā āāā pets.py # Pet models
ā ā āāā vets.py # Vet and medical models
ā ā āāā products.py # Product models
ā āāā tools/ # MCP tools
ā ā āāā base.py # Base tool classes
ā ā āāā connection_tools.py # Connection tools
ā ā āāā query_tools.py # Query tools
ā ā āāā pet_tools.py # Pet-specific tools
ā āāā utils/ # Utilities
ā ā āāā validators.py # Input validation
ā āāā server.py # Main server orchestration
āāā main.py # Entry point
āāā config.py # Configuration
āāā requirements.txt # DependenciesRelated MCP server: Gremlin MCP Server
Features
This MCP server provides the following tools:
connect_neo4j: Connect to the Neo4j database
run_cypher_query: Execute custom Cypher queries
get_database_info: Get schema and statistics information
get_user_pets: Get all pets owned by a specific user
get_pet_medical_history: Get complete medical history for a pet
get_vet_appointments: Get vet appointments with optional filters
get_product_interactions: Get product interaction data for analysis
search_pets_by_criteria: Search pets by species, breed, weight, gender, etc.
Database Schema
The Neo4j database contains the following node types and relationships:
Nodes
User: Pet owners (id, username)
Pet: Individual pets (name, species, breed, birth_date, weight_kg, gender, color, microchip_id)
VetVisit: Medical visits (date, reason, diagnosis, treatment, follow_up_date, notes)
Vet: Veterinarians (name, clinic)
Medication: Prescribed treatments (medication_name, dosage, frequency, start_date, duration_days, reason, notes)
ProductInteraction: Product interactions (date, interaction_type, quantity, feedback, rating, notes)
Product: Products (product_name, brand, category, attributes)
Relationships
(:User)-[:OWNS]->(:Pet): User owns pets(:Pet)-[:HAS_VISIT]->(:VetVisit): Pet has vet visits(:VetVisit)-[:WITH_VET]->(:Vet): Vet visit with veterinarian(:Pet)-[:HAS_MEDICATION]->(:Medication): Pet has medications(:Pet)-[:INTERACTED_WITH]->(:ProductInteraction): Pet interacts with products(:ProductInteraction)-[:ABOUT_PRODUCT]->(:Product): Product interaction details
Connection Details
Neo4j URI:
neo4j+s://b2f690c8.databases.neo4j.ioQuery API URL:
https://b2f690c8.databases.neo4j.io/db/neo4j/query/v2Instance ID:
b2f690c8Database:
neo4j
Installation
For Users/Agents
Install the package via pip:
pip install neo4j-mcp-toolsFor Development
Clone the repository:
git clone https://github.com/nbhuyyar-chwy/Graph_MCP.git cd Graph_MCPInstall dependencies:
pip install -r requirements.txtInstall in development mode:
pip install -e .
Usage
For AI Agents
Add this to your MCP client configuration to reference @neo4j-tools:
{
"mcpServers": {
"neo4j-tools": {
"command": "neo4j-mcp-server",
"args": [],
"env": {
"NEO4J_URI": "neo4j+s://your-instance.databases.neo4j.io",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your_password_here",
"NEO4J_DATABASE": "neo4j"
}
}
}
}The agent can then use any of the 11 available tools through @neo4j-tools.
Command Line Usage
After installation, start the server:
neo4j-mcp-server
# Or with custom settings:
neo4j-mcp-server --port 8001 --log-level DEBUGManual Setup (Development)
Set up environment variables: Create a
.envfile with your Neo4j credentials:NEO4J_USERNAME=your_username NEO4J_PASSWORD=your_passwordRun the server:
python main.py
Usage Examples
Connect to Database
# Tool: connect_neo4j
{
"username": "neo4j",
"password": "your_password"
}Get User's Pets
# Tool: get_user_pets
{
"username": "sarah"
}Get Pet Medical History
# Tool: get_pet_medical_history
{
"pet_name": "Max",
"owner_username": "sarah"
}Search Pets by Criteria
# Tool: search_pets_by_criteria
{
"species": "Dog",
"min_weight": 5,
"max_weight": 30,
"gender": "Male"
}Custom Cypher Query
# Tool: run_cypher_query
{
"query": "MATCH (u:User)-[:OWNS]->(p:Pet) WHERE p.species = $species RETURN u.username, p.name",
"parameters": {"species": "Cat"}
}Get Vet Appointments
# Tool: get_vet_appointments
{
"vet_name": "Dr. Chen",
"start_date": "2024-01-01",
"end_date": "2024-12-31"
}Get Product Interactions
# Tool: get_product_interactions
{
"product_name": "Blue Buffalo",
"min_rating": 4
}Security Notes
Store credentials in environment variables, not in code
The server connects using encrypted connection (neo4j+s://)
All queries are parameterized to prevent injection attacks
Dependencies
mcp>=1.0.0: Model Context Protocol frameworkneo4j>=5.15.0: Neo4j Python driverpython-dotenv>=1.0.0: Environment variable managementtyping-extensions>=4.8.0: Type hints supportasyncio-throttle>=1.0.2: Async rate limiting
Error Handling
The server includes comprehensive error handling for:
Connection failures
Authentication errors
Invalid queries
Missing parameters
Network timeouts
All errors are returned as descriptive text messages to help with debugging.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
Related MCP Connectors
Astra DB tools for agents: schema, find, vector search, guarded writes, and interactive views.
Graph-vector database: run Helix queries, read query insights and health, manage databases
Knowledge graph for AI agents. Query concepts, walk edges, get advisories.
A private graph database you query in plain English or Cypher. Hosted, nothing to install.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI agents to store, retrieve, and connect information in a Neo4j graph database as persistent memory, with semantic relationships, natural language search, and temporal tracking across conversations.9142 npm67MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Gremlin-compatible graph databases through natural language, supporting schema discovery, complex graph queries, relationship analysis, and data import/export operations.20 npm9MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Neo4j graph databases through natural language, supporting Cypher queries, schema management, data manipulation, and graph algorithms.MIT
- AlicenseNot gradedqualityCmaintenanceEnables LLMs to interact with Neo4j graph databases using natural language to execute Cypher queries and introspect database schemas. It supports both read and write operations for local, Docker, and cloud-based instances like Neo4j Aura.MIT