nargesghv/Insert-data-in-to-Neo4j-mcp-server
If you are the rightful owner of Insert-data-in-to-Neo4j-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project integrates natural language processing with a Neo4j graph database using a Model Context Protocol (MCP) server.
createNode
Tool to create nodes in the Neo4j database from natural language input.
๐ Inserting Nodes and realations in to Neo4j(Graph Database) by applying MCP Server
A project that accepts natural language (NL) queries from Claude Desktop via MCP and uses GPT-4o + LangChain to extract structured node information and store it in a Neo4j database.
๐ Features
- Neo4j graph database: stores nodes extracted from NL input.
- MCP server (FastMCP): offers an LLM-exposable tool
createNode
. - LangChain + GPTโ4o: parses NL into structured
Neo4jNode
. - Claude Desktop integration: uses MCP protocol to call your tool interactively.
๐ ๏ธ Prerequisites
- Python 3.10+
- Neo4j Community or Enterprise Edition (locally or via Aura)
- Claude Desktop installed
uv
CLI (optional but helpful for running MCP apps)
๐๏ธ Step 1: Install & Set Up Neo4j
-
Download and install Neo4j Desktop from neo4j.com.
-
Create a new database using the Neo4j Desktop UI or Neo4j Browser:
CREATE DATABASE mydb IF NOT EXISTS;
-
Set credentials during creation (
neo4j
username and password). -
Get the Bolt connection URI, typically:
bolt://localhost:7687
๐งฉ Step 2: Project Configuration
-
Clone or create this project directory.
-
Create a
.env
file in the project root:uri=bolt://localhost:7687 username=neo4j pwd=your_password
-
Install dependencies:
pip install neo4j neo4j_graphrag langchain langchain-core langchain-openai mcp python-dotenv
๐งฑ Step 3: Code Overview
The server.py
file includes:
- Prompt definition using LangChain's
PromptTemplate
andPydanticOutputParser
- Tool chain with GPTโ4o to convert NL to structured node
FastMCP
server exposing thecreateNode
tool- Neo4jWriter to persist graph nodes
๐งช Step 4: Run the MCP Server
You can run the MCP server using Python directly:
fastmcp install server.py
Or optionally using uv
:
uv add mcp
uv run python server.py
๐ฌ Step 5: Use with Claude Desktop (Client)
-
Launch Claude Desktop.
-
Connect it to your running MCP server (via standard I/O or HTTP).
-
Send a message like:
Create a person node with name Alice and age 30
-
The tool will:
-
Generate a
Neo4jNode
from GPTโ4o -
Write it to the Neo4j database
-
Respond with:
โ Node successfully added to db โ Label: Person, Properties: name:Alice, age:30
-
๐ Step 6: Inspect Data in Neo4j
You can explore the created nodes using Neo4j Browser or Neo4j Bloom:
MATCH (n) RETURN n;
๐ง Step 7: Customize & Extend
- Add more tools (e.g.,
createRelationship
,queryGraph
) - Integrate a FastAPI or Gradio UI for user interaction
- Use Claude with structured function calling via MCP
๐ References
- Neo4j Quickstart Docs
- Neo4j Cypher Manual
- FastMCP GitHub
- LangGraph MCP Protocol Guide
- Model Context Protocol
โ Summary
This project brings together:
- ๐ฌ Natural Language โ Graph with GPTโ4o
- ๐ก MCP tool exposed to Claude Desktop
- ๐ Neo4j for persistent graph storage
- ๐ Fully extendable graph-based RAG architecture
For any issues or ideas, feel free to open an issue or PR!