File tree Expand file tree Collapse file tree 4 files changed +37
-2
lines changed
Expand file tree Collapse file tree 4 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 11# Changelog - [ 0.3.0] - yyyy-mm-dd
22
33### New Features
4-
4+ 1 . Add a new get_relationship_properties_keys tool.
55
66### Bug Fixes
77
Original file line number Diff line number Diff line change @@ -197,3 +197,15 @@ def get_node_properties_keys(gds: GraphDataScience):
197197 if df .empty :
198198 return []
199199 return df ["properties_keys" ].iloc [0 ]
200+
201+
202+ def get_relationship_properties_keys (gds : GraphDataScience ):
203+ with projected_graph (gds ):
204+ query = """
205+ MATCH (n)-[r]->(m)
206+ RETURN DISTINCT keys(properties(r)) AS properties_keys
207+ """
208+ df = gds .run_cypher (query )
209+ if df .empty :
210+ return []
211+ return df ["properties_keys" ].iloc [0 ]
Original file line number Diff line number Diff line change 1212from .community_algorithm_specs import community_tool_definitions
1313from .path_algorithm_specs import path_tool_definitions
1414from .registry import AlgorithmRegistry
15- from .gds import count_nodes , get_node_properties_keys
15+ from .gds import count_nodes , get_node_properties_keys , get_relationship_properties_keys
1616
1717logger = logging .getLogger ("mcp_server_neo4j_gds" )
1818
@@ -80,6 +80,13 @@ async def handle_list_tools() -> list[types.Tool]:
8080 "type" : "object" ,
8181 },
8282 ),
83+ types .Tool (
84+ name = "get_relationship_properties_keys" ,
85+ description = """Get all relationship properties keys in the database""" ,
86+ inputSchema = {
87+ "type" : "object" ,
88+ },
89+ ),
8390 ]
8491 + centrality_tool_definitions
8592 + community_tool_definitions
@@ -105,6 +112,10 @@ async def handle_call_tool(
105112 result = get_node_properties_keys (gds )
106113 return [types .TextContent (type = "text" , text = serialize_result (result ))]
107114
115+ elif name == "get_relationship_properties_keys" :
116+ result = get_relationship_properties_keys (gds )
117+ return [types .TextContent (type = "text" , text = serialize_result (result ))]
118+
108119 else :
109120 handler = AlgorithmRegistry .get_handler (name , gds )
110121 result = handler .execute (arguments or {})
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ async def test_list_tools(mcp_client):
2525 # Basic tools
2626 "count_nodes" ,
2727 "get_node_properties_keys" ,
28+ "get_relationship_properties_keys" ,
2829 # Centrality algorithms
2930 "article_rank" ,
3031 "articulation_points" ,
@@ -97,3 +98,14 @@ async def test_get_node_properties_keys(mcp_client):
9798 "display_name" ,
9899 "longitude" ,
99100 ]
101+
102+
103+ @pytest .mark .asyncio
104+ async def test_get_relationship_properties_keys (mcp_client ):
105+ result = await mcp_client .call_tool ("get_relationship_properties_keys" )
106+
107+ assert len (result ) == 1
108+ result_text = result [0 ]["text" ]
109+ properties_keys = json .loads (result_text )
110+
111+ assert properties_keys == ["distance" , "line" , "time" ]
You can’t perform that action at this time.
0 commit comments