This MCP server provides a Neo4j-based implementation of the Model Context Protocol, allowing you to create and manage knowledge graphs for AI applications with environment variable support and improved configuration options.
The server can be configured using the following environment variables:
NEO4J_URL
- Neo4j connection URL (default: "bolt://localhost:7687")NEO4J_USER
- Neo4j username (default: "neo4j")NEO4J_PASSWORD
- Neo4j password (default: "neo4j")First, ensure you have Node.js installed on your system. Then install and start the MCP server:
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm start
You can run the server with custom Neo4j connection details:
NEO4J_URL="bolt://192.168.0.157:28687" \
NEO4J_USER="neo4j" \
NEO4J_PASSWORD="your-password" \
node dist/servers/mcp-neo4j-memory/main.js
The Neo4j MCP server provides the following capabilities for managing your knowledge graph:
To create new entities in the knowledge graph:
// Example API request to create entities
const response = await fetch('http://localhost:3000/mcp', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'create_entities',
entities: [
{ name: 'Person', properties: { age: 30, occupation: 'Engineer' } },
{ name: 'Company', properties: { founded: 2010, industry: 'Technology' } }
]
})
});
To establish relationships between entities:
// Example API request to create relations
const response = await fetch('http://localhost:3000/mcp', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'create_relations',
relations: [
{
source: 'Person',
relation: 'WORKS_AT',
target: 'Company'
}
]
})
});
To search for nodes in the knowledge graph:
// Example API request to search nodes
const response = await fetch('http://localhost:3000/mcp', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'search_nodes',
query: 'Engineer'
})
});
To read the entire knowledge graph:
// Example API request to read the graph
const response = await fetch('http://localhost:3000/mcp', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'read_graph'
})
});
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-neo4j-memory" '{"command":"node","args":["dist/servers/mcp-neo4j-memory/main.js"],"env":{"NEO4J_URL":"bolt://localhost:7687","NEO4J_USER":"neo4j","NEO4J_PASSWORD":"neo4j"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-neo4j-memory": {
"command": "node",
"args": [
"dist/servers/mcp-neo4j-memory/main.js"
],
"env": {
"NEO4J_URL": "bolt://localhost:7687",
"NEO4J_USER": "neo4j",
"NEO4J_PASSWORD": "neo4j"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp-neo4j-memory": {
"command": "node",
"args": [
"dist/servers/mcp-neo4j-memory/main.js"
],
"env": {
"NEO4J_URL": "bolt://localhost:7687",
"NEO4J_USER": "neo4j",
"NEO4J_PASSWORD": "neo4j"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect