mcp-memgraph 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ from .server import (
2
+ run_query,
3
+ get_configuration,
4
+ get_index,
5
+ get_constraint,
6
+ get_schema,
7
+ get_storage,
8
+ get_triggers,
9
+ get_betweenness_centrality,
10
+ get_page_rank,
11
+ )
12
+
13
+ __all__ = [
14
+ "run_query",
15
+ "get_configuration",
16
+ "get_index",
17
+ "get_constraint",
18
+ "get_schema",
19
+ "get_storage",
20
+ "get_triggers",
21
+ "get_betweenness_centrality",
22
+ "get_page_rank",
23
+ ]
mcp_memgraph/server.py ADDED
@@ -0,0 +1,137 @@
1
+ from mcp.server.fastmcp import FastMCP
2
+
3
+ from memgraph_toolbox.api.memgraph import Memgraph
4
+ from memgraph_toolbox.tools.cypher import CypherTool
5
+ from memgraph_toolbox.tools.config import ShowConfigTool
6
+ from memgraph_toolbox.tools.index import ShowIndexInfoTool
7
+ from memgraph_toolbox.tools.constraint import ShowConstraintInfoTool
8
+ from memgraph_toolbox.tools.schema import ShowSchemaInfoTool
9
+ from memgraph_toolbox.tools.storage import ShowStorageInfoTool
10
+ from memgraph_toolbox.tools.trigger import ShowTriggersTool
11
+ from memgraph_toolbox.tools.betweenness_centrality import BetweennessCentralityTool
12
+ from memgraph_toolbox.tools.page_rank import PageRankTool
13
+ from memgraph_toolbox.utils.logging import logger_init
14
+
15
+
16
+ from typing import Any, Dict, List
17
+
18
+ # Configure logging
19
+ logger = logger_init("mcp-memgraph")
20
+
21
+ # Initialize FastMCP server
22
+ mcp = FastMCP("mcp-memgraph")
23
+
24
+ MEMGRAPH_URI = "bolt://localhost:7687"
25
+ MEMGRAPH_USER = ""
26
+ MEMGRAPH_PASSWORD = ""
27
+
28
+ # Initialize Memgraph client
29
+ db = Memgraph(
30
+ uri=MEMGRAPH_URI,
31
+ username=MEMGRAPH_USER,
32
+ password=MEMGRAPH_PASSWORD,
33
+ )
34
+
35
+
36
+ @mcp.tool()
37
+ def run_query(query: str) -> List[Dict[str, Any]]:
38
+ """Run a Cypher query on Memgraph"""
39
+ logger.info(f"Running query: {query}")
40
+ try:
41
+ result = CypherTool(db=db).call({"query": query})
42
+ return result
43
+ except Exception as e:
44
+ return [f"Error running query: {str(e)}"]
45
+
46
+
47
+ @mcp.tool()
48
+ def get_configuration() -> List[Dict[str, Any]]:
49
+ """Get Memgraph configuration information"""
50
+ logger.info("Fetching Memgraph configuration...")
51
+ try:
52
+ config = ShowConfigTool(db=db).call({})
53
+ return config
54
+ except Exception as e:
55
+ return [f"Error fetching configuration: {str(e)}"]
56
+
57
+
58
+ @mcp.tool()
59
+ def get_index() -> List[Dict[str, Any]]:
60
+ """Get Memgraph index information"""
61
+ logger.info("Fetching Memgraph index...")
62
+ try:
63
+ index = ShowIndexInfoTool(db=db).call({})
64
+ return index
65
+ except Exception as e:
66
+ return [f"Error fetching index: {str(e)}"]
67
+
68
+
69
+ @mcp.tool()
70
+ def get_constraint() -> List[Dict[str, Any]]:
71
+ """Get Memgraph constraint information"""
72
+ logger.info("Fetching Memgraph constraint...")
73
+ try:
74
+ constraint = ShowConstraintInfoTool(db=db).call({})
75
+ return constraint
76
+ except Exception as e:
77
+ return [f"Error fetching constraint: {str(e)}"]
78
+
79
+
80
+ @mcp.tool()
81
+ def get_schema() -> List[Dict[str, Any]]:
82
+ """Get Memgraph schema information"""
83
+ logger.info("Fetching Memgraph schema...")
84
+ try:
85
+ schema = ShowSchemaInfoTool(db=db).call({})
86
+ return schema
87
+ except Exception as e:
88
+ return [f"Error fetching schema: {str(e)}"]
89
+
90
+
91
+ @mcp.tool()
92
+ def get_storage() -> List[Dict[str, Any]]:
93
+ """Get Memgraph storage information"""
94
+ logger.info("Fetching Memgraph storage...")
95
+ try:
96
+ storage = ShowStorageInfoTool(db=db).call({})
97
+ return storage
98
+ except Exception as e:
99
+ return [f"Error fetching storage: {str(e)}"]
100
+
101
+
102
+ @mcp.tool()
103
+ def get_triggers() -> List[Dict[str, Any]]:
104
+ """Get Memgraph triggers information"""
105
+ logger.info("Fetching Memgraph triggers...")
106
+ try:
107
+ triggers = ShowTriggersTool(db=db).call({})
108
+ return triggers
109
+ except Exception as e:
110
+ return [f"Error fetching triggers: {str(e)}"]
111
+
112
+
113
+ @mcp.tool()
114
+ def get_betweenness_centrality() -> List[Dict[str, Any]]:
115
+ """Get betweenness centrality information"""
116
+ logger.info("Fetching betweenness centrality...")
117
+ try:
118
+ betweenness = BetweennessCentralityTool(db=db).call({})
119
+ return betweenness
120
+ except Exception as e:
121
+ return [f"Error fetching betweenness centrality: {str(e)}"]
122
+
123
+
124
+ @mcp.tool()
125
+ def get_page_rank() -> List[Dict[str, Any]]:
126
+ """Get page rank information"""
127
+ logger.info("Fetching page rank...")
128
+ try:
129
+ page_rank = PageRankTool(db=db).call({})
130
+ return page_rank
131
+ except Exception as e:
132
+ return [f"Error fetching page rank: {str(e)}"]
133
+
134
+
135
+ if __name__ == "__main__":
136
+ logger.info("Starting FastMCP server...")
137
+ mcp.run(transport="stdio")
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-memgraph
3
+ Version: 0.1.0
4
+ Summary: MCP integration and utilities for Memgraph MCP server
5
+ Project-URL: Homepage, https://github.com/memgraph/ai-toolkit
6
+ Project-URL: Source, https://github.com/memgraph/ai-toolkit/tree/main/integrations/mcp-memgraph
7
+ Project-URL: Issues, https://github.com/memgraph/ai-toolkit/issues
8
+ Author-email: antejavor <ante.javor@memgraph.io>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: graph,integration,mcp,memgraph,toolkit
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: httpx>=0.28.1
20
+ Requires-Dist: mcp[cli]>=1.3.0
21
+ Requires-Dist: memgraph-toolbox
22
+ Requires-Dist: neo4j>=5.28.1
23
+ Provides-Extra: test
24
+ Requires-Dist: anthropic; extra == 'test'
25
+ Requires-Dist: mcp[cli]>=1.3.0; extra == 'test'
26
+ Requires-Dist: pytest-asyncio>=0.20.3; extra == 'test'
27
+ Requires-Dist: pytest>=8.3.5; extra == 'test'
28
+ Requires-Dist: python-dotenv>=1.0.1; extra == 'test'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # 🚀 Memgraph MCP Server
32
+
33
+ Memgraph MCP Server is a lightweight server implementation of the Model Context Protocol (MCP) designed to connect Memgraph with LLMs.
34
+
35
+ ![mcp-server](./mcp-server.png)
36
+
37
+ ## ⚡ Quick start
38
+
39
+ > 📹 [Memgraph MCP Server Quick Start video](https://www.youtube.com/watch?v=0Tjw5QWj_qY)
40
+
41
+ ### 1. Run Memgraph MCP Server
42
+
43
+ 1. Install [`uv`](https://docs.astral.sh/uv/getting-started/installation/) and create `venv` with `uv venv`. Activate virtual environment with `.venv\Scripts\activate`.
44
+ 2. Install dependencies: `uv add "mcp[cli]" httpx`
45
+ 3. Run Memgraph MCP server: `uv run server.py`.
46
+
47
+ ### 2. Run MCP Client
48
+
49
+ 1. Install [Claude for Desktop](https://claude.ai/download).
50
+ 2. Add the Memgraph server to Claude config:
51
+
52
+ **MacOS/Linux**
53
+
54
+ ```
55
+ code ~/Library/Application\ Support/Claude/claude_desktop_config.json
56
+ ```
57
+
58
+ **Windows**
59
+
60
+ ```
61
+ code $env:AppData\Claude\claude_desktop_config.json
62
+ ```
63
+
64
+ Example config:
65
+
66
+ ```
67
+ {
68
+ "mcpServers": {
69
+ "mpc-memgraph": {
70
+ "command": "/Users/katelatte/.local/bin/uv",
71
+ "args": [
72
+ "--directory",
73
+ "/Users/katelatte/projects/mcp-memgraph",
74
+ "run",
75
+ "server.py"
76
+ ]
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ > [!NOTE]
83
+ > You may need to put the full path to the uv executable in the command field. You can get this by running `which uv` on MacOS/Linux or `where uv` on Windows. Make sure you pass in the absolute path to your server.
84
+
85
+ ### 3. Chat with the database
86
+
87
+ 1. Run Memgraph MAGE:
88
+ ```
89
+ docker run -p 7687:7687 memgraph/memgraph-mage --schema-info-enabled=True
90
+ ```
91
+ The `--schema-info-enabled` configuration setting is set to `True` to allow LLM to run `SHOW SCHEMA INFO` query.
92
+ 2. Open Claude Desktop and see the Memgraph tools and resources listed. Try it out! (You can load dummy data from [Memgraph Lab](https://memgraph.com/docs/data-visualization) Datasets)
93
+
94
+ ## 🔧Tools
95
+
96
+ ### run_query()
97
+
98
+ Run a Cypher query against Memgraph.
99
+
100
+ ## 🗃️ Resources
101
+
102
+ ### get_schema()
103
+
104
+ Get Memgraph schema information (prerequisite: `--schema-info-enabled=True`).
105
+
106
+ ## 🗺️ Roadmap
107
+
108
+ The Memgraph MCP Server is just at its beginnings. We're actively working on expanding its capabilities and making it even easier to integrate Memgraph into modern AI workflows.
@@ -0,0 +1,7 @@
1
+ mcp_memgraph/__init__.py,sha256=Kpg32aj6VDEIBvqIzDkLG8mbs5kQWqkOj5qLdeq7zps,407
2
+ mcp_memgraph/server.py,sha256=kJOfhbo9S2e6Ib-X78aqTeJojtQtkIIfEV6OPaneRxY,4071
3
+ mcp_memgraph-0.1.0.dist-info/METADATA,sha256=8grufJGuCXWqNkvMmtrA74aB-fomev573Woh-20x1ek,3486
4
+ mcp_memgraph-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ mcp_memgraph-0.1.0.dist-info/entry_points.txt,sha256=iOKnAtGNhVtiUjWaULMDWXTsuisdmnHadzKC0FQjQuM,58
6
+ mcp_memgraph-0.1.0.dist-info/licenses/LICENSE,sha256=Zs4MZAXqusfO2KGQoAOuIqEUtojbyIYIkiJQ0BTt45o,1065
7
+ mcp_memgraph-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mcp-memgraph = mcp_memgraph.server:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Memgraph
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.