Insert-data-in-to-Neo4j-mcp-server

nargesghv/Insert-data-in-to-Neo4j-mcp-server

3.2

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.

Tools
  1. 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

  1. Download and install Neo4j Desktop from neo4j.com.

  2. Create a new database using the Neo4j Desktop UI or Neo4j Browser:

    CREATE DATABASE mydb IF NOT EXISTS;
    
  3. Set credentials during creation (neo4j username and password).

  4. Get the Bolt connection URI, typically:

    bolt://localhost:7687
    

๐Ÿงฉ Step 2: Project Configuration

  1. Clone or create this project directory.

  2. Create a .env file in the project root:

    uri=bolt://localhost:7687
    username=neo4j
    pwd=your_password
    
  3. 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 and PydanticOutputParser
  • Tool chain with GPTโ€‘4o to convert NL to structured node
  • FastMCP server exposing the createNode 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)

  1. Launch Claude Desktop.

  2. Connect it to your running MCP server (via standard I/O or HTTP).

  3. Send a message like:

    Create a person node with name Alice and age 30
    
  4. 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


โœ… 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!