Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions integrations/mcp-memgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ Equivalent to running `SHOW STORAGE INFO`.
List all database triggers.
Equivalent to running `SHOW TRIGGERS`.

### get_procedures()

List all available Memgraph procedures (query modules).
Returns information about all available procedures including MAGE algorithms and custom query modules. Each procedure includes its name, signature, and whether it performs write operations.
Use this to discover available graph algorithms and utility functions before executing them.
Equivalent to running `CALL mg.procedures() YIELD *`.

### get_betweenness_centrality()

Compute betweenness centrality on the entire graph.
Expand Down
2 changes: 1 addition & 1 deletion integrations/mcp-memgraph/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
"httpx>=0.28.1",
"mcp[cli]>=1.9.3",
"neo4j>=5.28.1",
"memgraph-toolbox>=0.1.8",
"memgraph-toolbox>=0.1.9",
"pytest>=8.3.5",
"fastmcp>=2.13.0.2",
]
Expand Down
2 changes: 2 additions & 0 deletions integrations/mcp-memgraph/src/mcp_memgraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
get_schema,
get_storage,
get_triggers,
get_procedures,
get_betweenness_centrality,
get_page_rank,
get_node_neighborhood,
Expand All @@ -23,6 +24,7 @@
"get_schema",
"get_storage",
"get_triggers",
"get_procedures",
"get_betweenness_centrality",
"get_page_rank",
"get_node_neighborhood",
Expand Down
17 changes: 17 additions & 0 deletions integrations/mcp-memgraph/src/mcp_memgraph/servers/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from memgraph_toolbox.tools.schema import ShowSchemaInfoTool
from memgraph_toolbox.tools.storage import ShowStorageInfoTool
from memgraph_toolbox.tools.trigger import ShowTriggersTool
from memgraph_toolbox.tools.procedures import ShowProceduresTool
from memgraph_toolbox.tools.betweenness_centrality import (
BetweennessCentralityTool,
)
Expand Down Expand Up @@ -161,6 +162,22 @@ def get_triggers() -> List[Dict[str, Any]]:
return [{"error": f"Error fetching triggers: {str(e)}"}]


@mcp.tool()
def get_procedures() -> List[Dict[str, Any]]:
"""List all available Memgraph procedures (query modules).

Returns information about all available procedures including MAGE algorithms
and custom query modules. Each procedure includes its name, signature, and
whether it performs write operations. Use this to discover available graph
algorithms and utility functions before executing them."""
logger.info("Fetching Memgraph procedures...")
try:
procedures = ShowProceduresTool(db=db).call({})
return procedures
except Exception as e:
return [{"error": f"Error fetching procedures: {str(e)}"}]


@mcp.tool()
def get_betweenness_centrality() -> List[Dict[str, Any]]:
"""Get betweenness centrality information"""
Expand Down
1 change: 1 addition & 0 deletions integrations/mcp-memgraph/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ async def test_tools_and_resources():
"get_page_rank",
"get_node_neighborhood",
"search_node_vectors",
"get_procedures",
]
expected_resources = []

Expand Down
8 changes: 4 additions & 4 deletions integrations/mcp-memgraph/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion memgraph-toolbox/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "memgraph-toolbox"
version = "0.1.8"
version = "0.1.9"
description = "Memgraph toolbox library for Memgraph AI tools and utilities"
readme = "README.md"
authors = [
Expand Down
30 changes: 30 additions & 0 deletions memgraph-toolbox/src/memgraph_toolbox/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ..tools.schema import ShowSchemaInfoTool
from ..tools.storage import ShowStorageInfoTool
from ..tools.trigger import ShowTriggersTool
from ..tools.procedures import ShowProceduresTool
from ..utils.logger import logger_init

logger = logger_init("test-tools")
Expand Down Expand Up @@ -311,3 +312,32 @@ def test_node_neighborhood_tool():
assert isinstance(result, list)
assert len(result) == 2
memgraph_client.query(f"MATCH (n:{label}) DETACH DELETE n;")


def test_show_procedures_tool():
"""Test the ShowProcedures tool."""

url = "bolt://localhost:7687"
user = ""
password = ""

memgraph_client = Memgraph(url=url, username=user, password=password)

procedures_tool = ShowProceduresTool(db=memgraph_client)
assert "show_procedures" in procedures_tool.name

result = procedures_tool.call({})

assert isinstance(result, list)
# Memgraph should always have some built-in procedures
assert len(result) >= 1

# Verify the structure of the returned data
first_procedure = result[0]
assert "name" in first_procedure
assert "signature" in first_procedure
assert "is_write" in first_procedure

# Verify that mg.procedures is in the list (it's a built-in procedure)
procedure_names = [proc["name"] for proc in result]
assert "mg.procedures" in procedure_names
35 changes: 35 additions & 0 deletions memgraph-toolbox/src/memgraph_toolbox/tools/procedures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import Any, Dict, List

from ..api.memgraph import Memgraph
from ..api.tool import BaseTool


class ShowProceduresTool(BaseTool):
"""
Tool for listing all available Memgraph procedures (query modules).

This tool queries the Memgraph database to retrieve information about
all available procedures from MAGE and custom query modules.
"""

def __init__(self, db: Memgraph):
super().__init__(
name="show_procedures",
description=(
"Lists all available Memgraph procedures (query modules) including "
"MAGE algorithms and custom query modules. Returns procedure name, "
"signature, and whether it's a read-only operation. Use this to "
"discover available graph algorithms and utility functions."
),
input_schema={"type": "object", "properties": {}, "required": []},
)
self.db = db

def call(self, arguments: Dict[str, Any]) -> List[Dict[str, Any]]:
"""Execute the mg.procedures() query and return the available procedures."""
procedures = self.db.query(
"CALL mg.procedures() YIELD name, signature, is_write "
"RETURN name, signature, is_write "
"ORDER BY name"
)
return procedures
8 changes: 8 additions & 0 deletions memgraph-toolbox/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.