
Memgraph AI Toolkit: A Codebase for Graph-Powered Applications
Introduction
With the introduction of structured outputs and function calling in large language models (LLMs), developers can now integrate dynamic function execution directly into their application pipelines. LLMs can invoke functions to fetch real-time data or output structured JSON, which can then be passed along to the next model call.
These capabilities support high-level frameworks like LangGraph, LlamaIndex, and the Model Context Protocol (MCP), enabling the development of sophisticated, agent-based workflows.
Within this context, a function is typically wrapped as a tool, a stateless and reusable component that an agent (LLM) can invoke to perform a specific task.
For example, a run_cypher_query()
tool allows an agent to execute Cypher queries when interacting with a graph database like Memgraph.
To streamline the development of these tools across multiple frameworks, we’ve introduced the Memgraph Toolbox, a central part of the Memgraph AI Toolkit.
Memgraph Toolbox
LLM-Powered Agents can autonomously decide which tools to use based on the prompt context or user queries. Given Memgraph’s capabilities as a graph database, agents have many ways to interact with the graph, from exploring schema and running queries to calculating graph algorithms.
To avoid duplicating tool implementations across different frameworks and repositories, the Memgraph Toolbox offers a shared collection of Python-based tools that adhere to the DRY principle. This toolbox can be reused across LangGraph, LlamaIndex, MCP, and other agentic environments.
Installation
To install the toolbox:
uv pip install -e memgraph-toolbox
Example Usage
If you take a look at the trigger tool, you will see something like this:
from typing import Any, Dict, List
from ..api.memgraph import Memgraph
from ..api.tool import BaseTool
class ShowTriggersTool(BaseTool):
"""
Tool for showing trigger information from Memgraph.
"""
def __init__(self, db: Memgraph):
super().__init__(
name="show_triggers",
description="Shows trigger information from a Memgraph database",
input_schema={"type": "object", "properties": {}, "required": []},
)
self.db = db
def call(self, arguments: Dict[str, Any]) -> List[Dict[str, Any]]:
"""Execute the SHOW TRIGGERS query and return the results."""
trigger_info = self.db.query("SHOW TRIGGERS")
return trigger_info
Each tool has its own unique implementation of a call
and each constructor has a name, description and input schema.
Here’s a quick example to verify that the tool is working:
from memgraph_toolbox.tools.trigger import ShowTriggersTool
from memgraph_toolbox.api.memgraph import Memgraph
# Connect to Memgraph
db = Memgraph()
# Use the ShowTriggersTool
tool = ShowTriggersTool(db)
triggers = tool.call({})
print(triggers)
Make sure you have a running Memgraph instance with appropriate configuration (e.g., existing triggers).
This is a direct call of the tool. To see how this tools gets called from the LLM in the LangGraph or MCP, take a look at our docs.
Moving MCP and LangGraph into the AI Toolkit
If you missed our previous releases, here’s the background:
We have moved the Memgraph LangChain integration and the MCP server into a single monorepo, AI toolkit.
To avoid extra complexity in maintaining multiple repositories that share the same toolbox, we’ve meshed them together for now while we determine how they fit into the bigger picture and evolve.
Currently Supported Tools
The toolbox supports a growing list of tools and is now fully integrated across LangChain and MCP:
RunQueryTool
— Execute Cypher queries on Memgraph.RunShowIndexInfoTool
— Retrieve index metadata.RunShowSchemaInfoTool
— Fetch schema definitions.RunShowConfigTool
— View database configuration settings.RunShowStorageInfoTool
— Inspect storage engine details.RunShowTriggersTool
— List all configured triggers.RunShowConstraintInfoTool
— Review database constraints.RunBetweennessCentralityTool
— Compute betweenness centrality of nodes.RunPageRankMemgraphTool
— Calculate PageRank on the graph.
Contribute or Build With Us
The Memgraph AI Toolkit is open-source and lives under the Memgraph GitHub organization:
🔗 https://github.com/memgraph/ai-toolkit
If you’re building LangGraph workflows, graph-native RAG pipelines, or agent-based systems using Memgraph, we’d love your feedback. Contributions and issues are always welcome. Join Memgraph community on Discord to connect with other developers!