Skip to content

neo4j-graphacademy/genai-mcp-neo4j-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Developing with Neo4j MCP Tools

Learn how to use the Model Context Protocol to create intelligent AI applications

Set up the Neo4j Cypher MCP Server

The server is written in Python, so you will use the uvx command to install the server from PyPI and run the server locally, and configure VS Code to communicate with the server using the Standard Input/Output (stdio) transport method.

Step 1: Install the server

To install the Neo4j Cypher MCP server in VS Code, open the .vscode/mcp.json file and add the server configuration:

mcp.json
{
  "servers": {
    "neo4j-cypher": {
      "command": "uvx",
      "args": [
        "mcp-neo4j-cypher"
      ]
    }
  }
}

Step 2: Set environment variables

The Neo4j Cypher MCP server will require environment variables to allow it to connect to an instance.

  • NEO4J_URI - The connection URI for your Neo4j database (e.g., neo4j+s://dbid.databases.neo4j.io)

  • NEO4J_USERNAME - Your Neo4j username (typically neo4j)

  • NEO4J_PASSWORD - Your Neo4j password

You can set these variables by adding a new env section to the neo4j-cypher entry in the mcp.json file.

mcp.json
{
  "servers": {
    "neo4j-cypher": {
      "command": "uvx",
      "args": [
        "mcp-neo4j-cypher"
      ],
      "env": {
        "NEO4J_URI": "neo4j+s://dbid.databases.neo4j.io:7687",
        "NEO4J_USERNAME": "neo4j",
        "NEO4J_PASSWORD": "<your password here>",
        "NEO4J_DATABASE": "neo4j"
      }
    }
  }
}
Tip

You can also use the VS Code MCP: Add Server command to setup the .vscode/mcp.json file, and then add the env section manually.

Tip
You can obtain a Neo4j Aura instance by enrolling to the Developing with Neo4j MCP Tools course on Neo4j GraphAcademy.

Managing the Server

Once configured, you can manage the MCP server using VS Code’s built-in commands:

  • Run MCP: List Servers from the Command Palette to view all configured servers

  • Start, Stop, or Restart servers as needed

  • Show Output to view server logs for troubleshooting

  • Browse Resources to see what the server provides

Using the tools

Now, when you ask GitHub Copilot Chat to interact with your Neo4j database, the following sequence will occur:

  1. Copilot analyzes the request and determines that a Neo4j tool is needed.

  2. Copilot requests permission to use the Neo4j tools (such as get_schema or execute_cypher).

  3. Once you have granted permission, Copilot invokes the tool with the appropriate parameters.

  4. The MCP server connects to your Neo4j database, executes the operation, and returns the result.

VS Code will ask your permission before running a tool, providing the options to run the tool once or always run the tool without asking permission.

This step is so important. Anyone can build or deploy an MCP server, so it is crucial that potentially destructive steps are approved by a human. Make sure you trust the developer of the server and the capabilities of the tool, especially when working with database operations.