Query modules

Memgraph Lab provides support for Query modules, which are collections of custom procedures written in C, C++, Python and Rust that extend Memgraph’s Cypher query language functionality. These procedures allow you to execute more advanced logic and operations directly from within your Cypher queries. There are two types of query modules:

  • Built-in modules, which ship with Memgraph and are available by default.
  • External modules, such as those provided through MAGE, Memgraph’s open-source algorithm library.

The MAGE library includes a wide range of optimized graph algorithms (like PageRank, community detection, node similarity, etc.), utilities and transformations to solve real-world graph problems.

Manage query modules

In Memgraph Lab, you can access query modules by navigating to the Query modules section. There you can:

  • Explore modules: See a list of all currently loaded modules and search across modules
  • Expand modules: Click the arrow icon to reveal available procedures and transformations
  • View details: Check procedure signatures, expected input/output variables, and data types
  • Test procedures: Run procedures by copying the provided example code snippet
  • Delete modules: Remove any custom modules you no longer need

For more details, visit our docs to learn how to manage query modules.

Custom query modules

Memgraph also allows you to create your own custom query modules using Python, directly within Memgraph Lab. This makes it super easy to prototype and test new logic without any external setup. To create a new module:

  1. Navigate to Query modules
  2. Click on New module
  3. Give your module a name
  4. Use the built-in editor to write your Python code
  5. Save your module

Once saved, Memgraph automatically scans the module and registers any procedures you’ve defined. You’ll be able to call them using Cypher immediately. Modules created this way are saved on the file system in the following path:

/var/lib/memgraph/internal_modules

This internal directory is scanned on startup and whenever modules are refreshed via the UI. You can use these modules just like any other by calling them with the CALL statement:

CALL my_module.my_procedure()

Whether you’re running standard procedures or developing new ones for specific business logic, query modules give you the flexibility and power to handle any graph challenge.