|
| 1 | +--- |
| 2 | +title: Using Neo4j with Hypermode |
| 3 | +sidebarTitle: Neo4j |
| 4 | +description: Connect your Hypermode agent to Neo4j for graph database operations |
| 5 | +--- |
| 6 | + |
| 7 | +<div className="flex items-center gap-3 mb-6"> |
| 8 | + <img |
| 9 | + src="/images/agents/connections/icons/neo4j-auradb.png" |
| 10 | + alt="Neo4j" |
| 11 | + width={48} |
| 12 | + height={48} |
| 13 | + /> |
| 14 | + <div> |
| 15 | + <h2 className="text-2xl font-bold m-0">Neo4j</h2> |
| 16 | + <p className="text-gray-600 m-0"> |
| 17 | + Graph database platform for connected data |
| 18 | + </p> |
| 19 | + </div> |
| 20 | +</div> |
| 21 | + |
| 22 | +## Overview |
| 23 | + |
| 24 | +Neo4j is a powerful graph database that excels at managing highly connected data |
| 25 | +and complex relationships. This guide will walk you through connecting your |
| 26 | +Hypermode agent to Neo4j. |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +Before connecting Neo4j to Hypermode, you'll need: |
| 31 | + |
| 32 | +1. A [Neo4j account](https://neo4j.com/) |
| 33 | +2. A Neo4j instance (we'll use Neo4j Sandbox for this guide) |
| 34 | +3. A [Hypermode workspace](https://hypermode.com/) |
| 35 | + |
| 36 | +## Setting up Neo4j |
| 37 | + |
| 38 | +### Step 1: Create a Neo4j Sandbox |
| 39 | + |
| 40 | +First, you need to go to https://sandbox.neo4j.com/ and create an account. When |
| 41 | +you get to making a database, select a blank sandbox. |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +<Note> |
| 46 | + Neo4j Sandbox provides free temporary instances perfect for testing. For |
| 47 | + production use, consider Neo4j Aura or a self-hosted instance. |
| 48 | +</Note> |
| 49 | + |
| 50 | +### Step 2: Get your connection details |
| 51 | + |
| 52 | +Once created (it may take a moment), you can navigate to the HTTP tab and grab |
| 53 | +the URL. Note you will have to modify this to use the Neo4j HTTP v2 endpoint: |
| 54 | + |
| 55 | +- Remove `/db/neo4j/tx/commit` |
| 56 | +- Replace it with `/db/neo4j/query/v2` |
| 57 | + |
| 58 | +For example: |
| 59 | + |
| 60 | +- Original: `http://52.54.53.148:7474/db/neo4j/tx/commit` |
| 61 | +- Modified: `http://52.54.53.148:7474/db/neo4j/query/v2` |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +### Step 3: Get authentication credentials |
| 66 | + |
| 67 | +Save this URL and then move to the connection details to grab the username and |
| 68 | +password. |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +Now we've got the URL, username, and password we can create a new agent in |
| 73 | +Hypermode. |
| 74 | + |
| 75 | +## Creating your Neo4j agent |
| 76 | + |
| 77 | +### Step 1: Create a new agent |
| 78 | + |
| 79 | +From the Hypermode interface, create a new agent: |
| 80 | + |
| 81 | +1. Click the agent dropdown menu |
| 82 | +2. Select "Create new Agent" |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +### Step 2: Configure agent settings |
| 87 | + |
| 88 | +Use these recommended settings for your Neo4j agent: |
| 89 | + |
| 90 | +- **Agent Name**: GraphExplorer |
| 91 | +- **Agent Title**: Neo4j Graph Analysis Agent |
| 92 | +- **Description**: Analyzes graph relationships and patterns in Neo4j |
| 93 | +- **Instructions**: You have a connection to a Neo4j graph database. You can |
| 94 | + create nodes with any labels and properties, create relationships of any type, |
| 95 | + and run Cypher queries. Neo4j is schemaless, so you can dynamically add data |
| 96 | + without predefined structures. |
| 97 | +- **Model**: GPT-4.1 |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +### Step 3: View your agent profile |
| 102 | + |
| 103 | +Once created, navigate to your agent's settings page: |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +## Connecting to Neo4j |
| 108 | + |
| 109 | +### Step 1: Add the Neo4j connection |
| 110 | + |
| 111 | +Navigate to the **Connections** tab and add Neo4j: |
| 112 | + |
| 113 | +1. Click "Add connection" |
| 114 | +2. Search for "Neo4j" in the available connections |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +### Step 2: Configure credentials |
| 119 | + |
| 120 | +Enter your Neo4j credentials: |
| 121 | + |
| 122 | +- **URL**: Your modified HTTP v2 endpoint |
| 123 | + (`http://52.54.53.148:7474/db/neo4j/query/v2`) |
| 124 | +- **Username**: Your Neo4j username (usually `neo4j`) |
| 125 | +- **Password**: Your Neo4j password |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | +<Warning> |
| 130 | + Ensure you're using the HTTP v2 endpoint format. The connection will fail with |
| 131 | + the default transaction endpoint. |
| 132 | +</Warning> |
| 133 | + |
| 134 | +## Understanding Neo4j's schemaless nature |
| 135 | + |
| 136 | +Unlike traditional databases, Neo4j doesn't require you to define schemas |
| 137 | +upfront. This means: |
| 138 | + |
| 139 | +- **Flexible node creation**: Add nodes with any labels and properties on the |
| 140 | + fly |
| 141 | +- **Dynamic relationships**: Create relationships of any type between nodes |
| 142 | +- **Evolving data models**: Your graph structure can grow and change organically |
| 143 | +- **No migrations needed**: Add new node types or properties without schema |
| 144 | + updates |
| 145 | + |
| 146 | +This flexibility makes Neo4j perfect for: |
| 147 | + |
| 148 | +- Exploratory data analysis |
| 149 | +- Rapidly evolving data models |
| 150 | +- Complex, heterogeneous datasets |
| 151 | +- Real-world relationship modeling |
| 152 | + |
| 153 | +## Example graph model |
| 154 | + |
| 155 | +Here's a simple example of how nodes and relationships work in Neo4j: |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | +This model shows: |
| 160 | + |
| 161 | +- **Nodes**: Person, Company, and Product (represented as circles) |
| 162 | +- **Relationships**: WORKS_AT, MAKER_OF, BY_COMPANY (represented as arrows) |
| 163 | +- Each node can have properties (like name, age, price) |
| 164 | +- Relationships can also have properties (like since, role) |
| 165 | + |
| 166 | +## Testing the connection |
| 167 | + |
| 168 | +### Test 1: Create your first nodes |
| 169 | + |
| 170 | +Start a new thread with your agent and create some nodes dynamically: |
| 171 | + |
| 172 | +```text |
| 173 | +Create nodes for this scenario: |
| 174 | +- A Person named "Alice" who is 28 years old |
| 175 | +- A Company named "TechCorp" founded in 2020 |
| 176 | +- A Product named "GraphApp" with a price of $99 |
| 177 | +``` |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | +### Test 2: Create relationships |
| 182 | + |
| 183 | +Now connect your nodes based on our model: |
| 184 | + |
| 185 | +```text |
| 186 | +Create these relationships: |
| 187 | +- Alice WORKS_AT TechCorp (since 2021) |
| 188 | +- Alice is MAKER_OF GraphApp |
| 189 | +- GraphApp is BY_COMPANY TechCorp |
| 190 | +``` |
| 191 | + |
| 192 | + |
| 193 | + |
| 194 | +### Test 3: Visualize in Neo4j Browser |
| 195 | + |
| 196 | +After your agent creates the data, switch to Neo4j Browser to see the results: |
| 197 | + |
| 198 | +1. **Click the "Open" button** in your Neo4j Sandbox |
| 199 | +2. **Run the visualization query**: |
| 200 | + |
| 201 | +```cypher |
| 202 | + MATCH (n) RETURN n |
| 203 | +``` |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | +### Test 4: Query your graph |
| 208 | + |
| 209 | +Back in your agent thread, use Cypher to explore your data: |
| 210 | + |
| 211 | +```text |
| 212 | +Run a Cypher query to find all products made by people who work at TechCorp, showing the full relationship path. |
| 213 | +``` |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | +## Example: Building a dynamic knowledge graph |
| 218 | + |
| 219 | +Here's how to leverage Neo4j's schemaless nature to build a flexible knowledge |
| 220 | +graph: |
| 221 | + |
| 222 | +```text |
| 223 | +Let's expand our graph with more data: |
| 224 | +1. Add another Person "Bob" who also works at TechCorp |
| 225 | +2. Add a new Company "StartupInc" |
| 226 | +3. Add Products "DataTool" and "AIAssistant" |
| 227 | +4. Create relationships showing Bob made DataTool, and StartupInc made AIAssistant |
| 228 | +5. Add a COMPETES_WITH relationship between the two companies |
| 229 | +``` |
| 230 | + |
| 231 | +Your agent can dynamically add: |
| 232 | + |
| 233 | +- New node types as you discover them |
| 234 | +- Properties specific to each entity |
| 235 | +- Relationships that make sense in context |
| 236 | +- No need to predefine any structure! |
| 237 | + |
| 238 | +## What you can do |
| 239 | + |
| 240 | +With your Neo4j connection and its three core tools, your agent can: |
| 241 | + |
| 242 | +- **Create Node**: Dynamically add entities with any labels and properties |
| 243 | +- **Create Relationship**: Connect nodes with typed relationships and properties |
| 244 | +- **Run Cypher Query**: Perform complex graph operations including: |
| 245 | + - Pattern matching and traversal |
| 246 | + - Aggregations and analytics |
| 247 | + - Graph algorithms |
| 248 | + - Data updates and deletions |
| 249 | + - Schema-free exploration |
| 250 | + |
| 251 | +## Troubleshooting |
| 252 | + |
| 253 | +### Common issues |
| 254 | + |
| 255 | +#### Connection refused error |
| 256 | + |
| 257 | +- Verify you're using the HTTP v2 endpoint format |
| 258 | +- Check if your sandbox is still active (they expire after 3 days) |
| 259 | +- Ensure the URL includes the correct port (usually 7474) |
| 260 | + |
| 261 | +#### Authentication failed |
| 262 | + |
| 263 | +- Confirm username and password are correct |
| 264 | +- Sandbox passwords are auto-generated - copy carefully |
| 265 | +- Try resetting the password in the sandbox console |
| 266 | + |
| 267 | +#### Tool execution errors |
| 268 | + |
| 269 | +- Check the |
| 270 | + [MCP Neo4j documentation](https://mcp.pipedream.com/app/neo4j_auradb) for |
| 271 | + correct parameter formats |
| 272 | +- Ensure node IDs exist before creating relationships |
| 273 | +- Verify Cypher syntax in your queries |
| 274 | + |
| 275 | +## Learn more |
| 276 | + |
| 277 | +- [Neo4j Documentation](https://neo4j.com/docs/) |
| 278 | +- [Cypher Query Language](https://neo4j.com/docs/cypher-manual/current/) |
| 279 | +- [MCP Neo4j AuraDB Server](https://mcp.pipedream.com/app/neo4j_auradb) |
| 280 | +- [Graph Data Science Library](https://neo4j.com/docs/graph-data-science/current/) |
0 commit comments