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.
📘 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
uvCLI (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 (
neo4jusername and password). -
Get the Bolt connection URI, typically:
bolt://localhost:7687
🧩 Step 2: Project Configuration
-
Clone or create this project directory.
-
Create a
.envfile 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
PromptTemplateandPydanticOutputParser - Tool chain with GPT‑4o to convert NL to structured node
FastMCPserver exposing thecreateNodetool- 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
Neo4jNodefrom 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!