π MCP Server for Neo4j Knowledge Graph Integration with Claude Desktop
A TypeScript-based Model Context Protocol (MCP) server that enables Claude Desktop to interact directly with Neo4j knowledge graphs. Built with modern technologies for performance, reliability, and ease of use.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Available Tools
- Examples
- Architecture
- Development
- Docker
- Contributing
- License
- π Universal Neo4j Connectivity - Works with local, Docker, cloud, and AuraDB instances
- π οΈ Comprehensive Toolset - 12 essential tools for knowledge graph operations
- β‘ High Performance - Built with Bun runtime and optimized TypeScript
- π Secure by Design - Robust validation, error handling, and connection management
- π Rich Query Analysis - Query profiling, execution plans, and optimization tips
- π― Type Safety - 100% TypeScript with comprehensive type definitions
- π Real-time Operations - Streaming support for large datasets
- π Schema Introspection - Complete database schema analysis and visualization
- Node.js >= 18.0.0 or Bun >= 1.0.0
- Neo4j Database (local installation, Docker, or cloud instance)
- Claude Desktop with MCP support
# Clone the repository
git clone https://github.com/michaelhil/neo4j2llm.git
cd neo4j2llm
# Install dependencies
bun install
# Build the project
bun run build
# Run the MCP server
bun run src/index.ts# Clone and install
git clone https://github.com/michaelhil/neo4j2llm.git
cd neo4j2llm
npm install
# Build and run
npm run build
npm start# Pull and run the container
docker run -it --rm \\
-e NEO4J_URI=bolt://host.docker.internal:7687 \\
-e NEO4J_USERNAME=neo4j \\
-e NEO4J_PASSWORD=password \\
michaelhil/neo4j2llm:latestCreate a .env file in the root directory:
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your_password
NEO4J_DATABASE=neo4jAdd to your Claude Desktop MCP settings:
{
"mcpServers": {
"neo4j2llm": {
"command": "bun",
"args": ["run", "/path/to/neo4j2llm/src/index.ts"],
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your_password"
}
}
}
}The server supports multiple Neo4j deployment types:
| Type | URI Format | Example |
|---|---|---|
| Local Bolt | bolt://host:port |
bolt://localhost:7687 |
| Local HTTP | http://host:port |
http://localhost:7474 |
| Neo4j Cloud | neo4j://host:port |
neo4j://xxx.databases.neo4j.io:7687 |
| AuraDB | neo4j+s://host:port |
neo4j+s://xxx.databases.neo4j.io:7687 |
Once configured, you can use natural language with Claude to interact with your Neo4j database:
Connect to my Neo4j database at bolt://localhost:7687 with username neo4j and password mypassword
Show me all Person nodes in the database
What labels and relationship types exist in my database?
Create a new Person node with name "Alice" and age 30
Explain the execution plan for: MATCH (p:Person)-[:KNOWS]->(f:Person) RETURN p, f
Establish connection to Neo4j database instance.
Parameters:
uri(required): Neo4j connection URIusername(required): Database usernamepassword(required): Database passworddatabase(optional): Target database namemaxConnectionPoolSize(optional): Max connection pool sizeconnectionTimeout(optional): Connection timeout in milliseconds
Example:
{
"uri": "bolt://localhost:7687",
"username": "neo4j",
"password": "password",
"database": "movies"
}Close connection to Neo4j database.
Example:
// No parameters requiredTest connection health and get database information.
Parameters:
includePerformanceTest(optional): Include response time measurement
Example:
{
"includePerformanceTest": true
}Execute Cypher query against Neo4j database.
Parameters:
cypher(required): Cypher query stringparameters(optional): Query parameterstimeout(optional): Query timeout in millisecondsincludeStats(optional): Include execution statisticslimit(optional): Maximum records to return
Example:
{
"cypher": "MATCH (p:Person {name: $name}) RETURN p",
"parameters": {"name": "Alice"},
"limit": 100,
"includeStats": true
}Get execution plan for Cypher query without executing it.
Parameters:
cypher(required): Cypher query to explainparameters(optional): Query parameters
Example:
{
"cypher": "MATCH (p:Person)-[:KNOWS]->(f) RETURN p, f",
"parameters": {}
}Execute and profile Cypher query to analyze performance.
Parameters:
cypher(required): Cypher query to profileparameters(optional): Query parameters
Example:
{
"cypher": "MATCH (p:Person) WHERE p.age > $minAge RETURN count(p)",
"parameters": {"minAge": 25}
}Retrieve complete database schema including labels, relationships, properties, constraints, and indexes.
Parameters:
includeStatistics(optional): Include schema statisticsincludePropertyInfo(optional): Include detailed property information
Example:
{
"includeStatistics": true,
"includePropertyInfo": true
}Get all node labels with their counts and sample properties.
Parameters:
includeCounts(optional): Include node counts for each labelincludeSampleProperties(optional): Include sample property namessortBy(optional): Sort by 'name' or 'count'limit(optional): Maximum number of labels to return
Example:
{
"includeCounts": true,
"sortBy": "count",
"limit": 50
}Get all relationship types with their counts and sample properties.
Parameters:
includeCounts(optional): Include relationship countsincludeSampleProperties(optional): Include sample property namessortBy(optional): Sort by 'name' or 'count'limit(optional): Maximum number of types to return
Example:
{
"includeCounts": true,
"includeSampleProperties": true,
"sortBy": "name"
}Create multiple nodes with specified labels and properties.
Create relationships between existing nodes with specified properties.
Export query results in JSON, CSV, or Cypher format.
Parameters:
nodes(required): Array of nodes to createreturnCreated(optional): Return information about created nodesbatchSize(optional): Number of nodes to create per batch
Example - Creating Nodes:
{
"nodes": [
{
"labels": ["Person"],
"properties": {"name": "Alice", "age": 30}
},
{
"labels": ["Person", "Developer"],
"properties": {"name": "Bob", "age": 25, "skill": "TypeScript"}
}
],
"returnCreated": true,
"batchSize": 100
}Example - Creating Relationships:
{
"relationships": [
{
"type": "KNOWS",
"properties": {"since": "2020"},
"startNode": {
"labels": ["Person"],
"properties": {"name": "Alice"}
},
"endNode": {
"labels": ["Person"],
"properties": {"name": "Bob"}
}
}
],
"returnCreated": true
}Example - Exporting Data:
{
"query": "MATCH (p:Person) RETURN p.name, p.age",
"format": "json",
"limit": 100
}// Connect to database
await neo4j_connect({
"uri": "bolt://localhost:7687",
"username": "neo4j",
"password": "password"
})
// Get database schema
await neo4j_get_schema({
"includeStatistics": true
})
// List all labels
await neo4j_get_labels({
"includeCounts": true,
"sortBy": "count"
})// Profile a complex query
await neo4j_profile_query({
"cypher": `
MATCH (p:Person)-[:WORKS_FOR]->(c:Company)
WHERE c.industry = $industry
RETURN p.name, c.name
ORDER BY p.name
`,
"parameters": {"industry": "Technology"}
})// Create nodes
await neo4j_create_nodes({
"nodes": [
{
"labels": ["Company"],
"properties": {"name": "TechCorp", "industry": "Technology"}
},
{
"labels": ["Person"],
"properties": {"name": "Alice", "role": "Engineer"}
}
],
"returnCreated": true
})
// Query the created data
await neo4j_execute_query({
"cypher": "MATCH (p:Person {name: 'Alice'}) RETURN p",
"includeStats": true
})βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β β β β β
β Claude Desktop βββββΊβ neo4j2LLM βββββΊβ Neo4j β
β β β MCP Server β β Database β
β β β β β β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
- π§ Runtime: Bun (primary) / Node.js (compatible)
- π Language: TypeScript (100%)
- π Protocol: Model Context Protocol (MCP)
- ποΈ Database: Neo4j (all versions)
- π§ͺ Testing: Bun test runner
- π¦ Building: Vite
- π Linting: ESLint + TypeScript rules
neo4j2LLM/
βββ src/
β βββ core/ # Core types, errors, validation
β βββ connection/ # Neo4j connection management
β βββ services/ # Business logic services
β βββ tools/ # MCP tool implementations
β β βββ connection/ # Connection management tools
β β βββ query/ # Query execution tools
β β βββ schema/ # Schema introspection tools
β β βββ creation/ # Data creation tools
β βββ index.ts # MCP server entry point
βββ docs/ # Documentation
βββ tests/ # Test suites
βββ docker/ # Docker configuration
- ποΈ Factory Pattern: All services use factory functions for clean instantiation
- π‘οΈ Type Safety: Comprehensive TypeScript interfaces and validation
- π Functional Programming: Immutable data structures and pure functions
- π¦ Error Handling: Robust error categorization and recovery
- β‘ Performance: Connection pooling, query optimization, and streaming support
# Clone and install
git clone https://github.com/michaelhil/neo4j2llm.git
cd neo4j2llm
bun install
# Start development server
bun run dev
# Run tests
bun test
# Type checking
bun run type-check
# Linting
bun run lintbun run dev # Development server with hot reload
bun run build # Build for production
bun test # Run test suite
bun test:watch # Run tests in watch mode
bun run lint # Lint code
bun run lint:fix # Fix linting issues
bun run type-check # TypeScript type checking# Run all tests
bun test
# Run specific test file
bun test src/tools/connection/connect.test.ts
# Run tests with coverage
bun test --coverage# Build the Docker image
docker build -t neo4j2llm .
# Run the container
docker run -it --rm \\
-e NEO4J_URI=bolt://host.docker.internal:7687 \\
-e NEO4J_USERNAME=neo4j \\
-e NEO4J_PASSWORD=password \\
neo4j2llmversion: '3.8'
services:
neo4j:
image: neo4j:latest
environment:
NEO4J_AUTH: neo4j/password
ports:
- "7474:7474"
- "7687:7687"
neo4j2llm:
build: .
environment:
NEO4J_URI: bolt://neo4j:7687
NEO4J_USERNAME: neo4j
NEO4J_PASSWORD: password
depends_on:
- neo4jWe welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- TypeScript for all code (no JavaScript files)
- ESLint for code quality
- Prettier for formatting
- Comprehensive tests for new features
- Documentation for all public APIs
This project is licensed under the MIT License - see the LICENSE file for details.
- Neo4j Team for the excellent graph database
- Anthropic for Claude and the MCP protocol
- Bun Team for the blazing fast runtime
- TypeScript Team for type safety excellence
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
Made with β€οΈ for the Knowledge Graph community